pycellfit package¶
Submodules¶
pycellfit.utils module¶
Top-level utility functions for pycellfit module.
-
pycellfit.utils.
read_segmented_image
(file_name, visualize=False)[source]¶ Displays the segmented image using matplotlib
Parameters: - file_name (str) – file name of a segmented image in .tif format
- visualize (bool) – if true, then image will be plotted using matplotlib.pyplot
Raises: TypeError – only accepts tif/tiff files as input
Returns: array of pixel values
Return type: numpy.ndarray
pycellfit.junction module¶
-
class
pycellfit.junction.
Junction
(coordinates, cells_set)[source]¶ Bases:
object
-
cell_labels
¶
-
coordinates
¶
-
degree
¶
-
edges
¶ set of labels of edges connected to this node
-
id_iter
= count(0)¶
-
remove_edge
(edge_label)[source]¶ Remove an edge and tension vector connected to this node
Parameters: - self –
- edge_label –
-
tension_vectors
¶ returns list of Tension vectors connected to this node
-
x
¶
-
y
¶
-
pycellfit.edge module¶
-
class
pycellfit.edge.
Edge
(start_node, end_node, intermediate_points, cells)[source]¶ Bases:
object
-
angular_position
(coordinates)[source]¶ given a (x,y) coordinate, the angular position in radians from 0 to 2*pi around the fit circle is returned
Parameters: coordinates – Returns:
-
center
¶
-
corresponding_tension_vector
¶
-
cw_around_circle
¶ true if the edge (start_node to end_node) goes clockwise around the fit circle, false if ccw
Returns:
-
end_node
¶
-
id_iter
= count(0)¶
-
length
¶
-
linear
¶
-
location
¶
-
radius
¶
-
split_line_multiple
(length=None, n_pieces=None)[source]¶ Splits a ogr wkbLineString into multiple sub-strings, either of a specified <<length>> or a specified <<n_pieces>>.
line should be an ogr LineString Geometry Length should be a float or int. n_pieces should be an int. Either length or n_pieces should be specified.
Returns a list of ogr wkbLineString Geometries.
-
split_line_single
(line, length)[source]¶ Returns two ogr line geometries, one which is the first length <<length>> of <<line>>, and one one which is the remainder.
line should be a ogr LineString Geometry. length should be an integer or float.
-
start_node
¶
-
xc
¶
-
yc
¶
-
pycellfit.tension_vector module¶
pycellfit.cell module¶
-
class
pycellfit.cell.
Cell
(pixel_value)[source]¶ Bases:
object
-
approximate_cell_center
()[source]¶ approximates the coordinates of the center of the cell by averaging the coordinates of points on the perimeter (edge) of the cell
Returns: approximate center of the cell Return type: tuple
-
label
¶ the label of a Cell is it’s unique pixel value. It is assigned when the Cell object is created.
Returns:
-
neighboring_cell_labels
¶
-
number_of_edge_points
¶ returns the number of edge points in edge_point_list
Returns: number of edge points
-
pycellfit.mesh module¶
-
class
pycellfit.mesh.
Mesh
(array_of_pixels)[source]¶ Bases:
object
-
number_of_cells
¶ returns the number of cells in the mesh
Returns: number of cells in mesh Return type: int
-
number_of_edges
¶ returns the number of edges in the mesh
Returns: number of edges in the mesh Return type: int
-
number_of_junctions
¶ returns the number of junctions in the mesh
Returns: number of junctions in the mesh Return type: int
-
number_of_quad_junctions
¶ returns the number of quad junctions in the mesh
Returns: number of edges in the mesh Return type: int
-
number_of_triple_junctions
¶ counts and outputs the number of triple junctions in the mesh
:return number of triple junctions in mesh :rtype: int
-
pycellfit.constrained_circle_fit module¶
pycellfit.circle_fit_helpers module¶
pycellfit.segmentation_transform module¶
functions to convert between watershed and skeleton segmented images
-
pycellfit.segmentation_transform.
skeleton_to_watershed
(skeleton_image_array, region_value=0, boundary_value=255, keep_boundaries=False)[source]¶ converts a segmented skeleton image (all regions are same value with region boundaries being a second value) to a watershed segmented image (each region has a unique value and there are no boundary pixels, background region has value of zero)
Parameters: - skeleton_image_array (np.ndarray) – 2D numpy array with pixel values of a skeleton segmented image
- region_value (float) – value of pixels in regions in skeleton_segmented images (default is 0)
- boundary_value (float) – value of boundary pixels of regions in skeleton_segmented images (default is 255)
- keep_boundaries (bool) – if True, watershed image will keep boundaries in returned result
Returns: watershed_image_array
Rtype watershed_image_array: np.ndarray
-
pycellfit.segmentation_transform.
watershed_to_skeleton
(watershed_image_array, region_value=0, boundary_value=255)[source]¶ converts a watershed segmented image (no boundaries between regions and each region has a different pixel value, background region has value of zero) to a skeleton segmented image (each region has the same pixel value and are separated by boundaries of a second value)
Parameters: - watershed_image_array (numpy.ndarray) – 2D numpy array with pixel values of a watershed segmented image
- region_value (float) – desired value of all regions in the output (skeleton segmented) array
- boundary_value (float) – desired value of boundary pixels in the output (skeleton segmented) array
Returns: skeleton_image_array
Rtype skeleton_image_array: np.ndarray
pycellfit.segmentation_transform_utils module¶
-
pycellfit.segmentation_transform_utils.
fill_region
(array_of_pixels, position, new_value)[source]¶ fills a region of a 2D numpy array with the same value
Parameters: - array_of_pixels (np.ndarray) – 2D numpy array of all pixel values
- position (tuple) – tuple with (row, col) location of pixel in the region to modify
- new_value (float) – new value for pixel at position and all pixels in same region
Returns: None