Fitting
This module provides functionality around fitting the Model to given data.
Computes a 2D array where the two masks differ. |
|
Calculates the penalty based on difference in colors. |
|
Computes a 2D penalty array which accounts if cells are related. |
|
Uses the |
Extracts a list of position from a given mask. |
|
Converts positions in pixel units to units of length (typically µm). |
|
Converts positions in length units (typically µm) to pixel units. |
- area_diff_mask(mask1, mask2) ndarray
Calculates a 2D array with entries 1 whenever colors differ and 0 if not.
- Parameters:
mask1 (np.ndarray) – Mask of segmented cells at one time-point
mask2 (np.ndarray) – Mask of segmented cells at other time-point
- Returns:
A 2D array with entries of value 1 where a difference was calculated.
- Return type:
np.ndarray
- convert_cell_pos_to_pixels(cell_pos: ndarray, domain_size: ndarray | tuple[float, float] | float, image_resolution: tuple[int, int] | ndarray)
Converts the position of a cell (collection of vertices) from length units (typically µm) to pixels.
Warning
This function performs only an approximate inverse to the
convert_pixel_to_position()
function. When converting from floating-point values to pixels and back rounding errors will be introcued.- Parameters:
cell_pos (np.ndarray) – Array of shape (N,2) containing the position of the cells vertices.
domain_size (float) – The overall edge length of the domain (typically in µm).
image_resolution (tuple[int, int] | np.ndarray) – A tuple containing the resolution of the image. Typically, the values for width and height are identical.
- Returns:
The converted position of the cell.
- Return type:
np.ndarray
- convert_pixel_to_position(pos_pixel: ndarray, domain_size: ndarray | tuple[float, float] | float, image_resolution: tuple[float, float])
Contains identical arguments as the
convert_cell_pos_to_pixels()
function and performs the approximate inverse operation.Warning
This function performs only an approximate inverse to the
convert_cell_pos_to_pixels()
function. When converting from floating-point values to pixels and back rounding errors will be introcued.- Returns:
The converted position of the cell.
- Return type:
np.ndarray
- extract_positions(mask: ndarray, n_vertices: int = 8) list[ndarray]
Extracts positions from a mask for each sub-mask associated to a single cell. To read more about the used methods, visit the Fitting-Methods page.
- Parameters:
mask (np.ndarray) – Array of shape
(D1, D2, 3)
, (D1, D2, 1) or (D1, D2) containing pixel values of a mask for multiple cells.n_vertices (int) – Number of vertices which should be extracted from each given cell-mask.
- Returns:
- A list containing arrays of shape
(n_vertices, 2)
containing the individual positions of the cells.
- A list containing arrays of shape
- Return type:
list[np.ndarray]
- penalty_area_diff(mask1, mask2) float
Calculates the penalty between two masks based on differences in color values (See also:
area_diff_mask()
).- Parameters:
mask1 (np.ndarray) – Mask of segmented cells at one time-point
mask2 (np.ndarray) – Mask of segmented cells at other time-point
- Returns:
The penalty
- Return type:
float
- penalty_area_diff_account_parents(mask1: ndarray, mask2: ndarray, cell_container: CellContainer, parent_penalty: float = 0.5) float
Calculates the penalty between two masks while accounting for relations between parent and child cells.
- Parameters:
mask1 (np.ndarray) – Mask of segmented cells at one time-point
mask2 (np.ndarray) – Mask of segmented cells at other time-point
cell_container (CellContainer) – See
CellContainer
parent_penalty (float) – Penalty value when one cell is daughter of other. Should be between 0 and 1.
- Returns:
A 2D array containing penalty values between 0 and 1.
- Return type:
np.ndarray
- points_along_polygon(polygon: list[ndarray] | ndarray, n_vertices: int = 8) ndarray
Returns evenly-spaced points along the given polygon. The initial and final point are always included.
- Parameters:
np.ndarray (polygon(list[np.ndarray] |) – Ordered points which make up the polygon.
n_vertices (int) – Number of vertices which should be extracted.
- Returns:
Array containing all extracted points (along the 0th axis).
- Return type:
np.ndarray
- parents_diff_mask(mask1, mask2, cell_container, parent_penalty=0.5)
Calculates the difference between two masks and applies a lower value where one cell is the daughter of the other.
- Parameters:
mask1 (np.ndarray) – Mask of segmented cells at one time-point
mask2 (np.ndarray) – Mask of segmented cells at other time-point
cell_container (CellContainer) – See
CellContainer
parent_penalty (float) – Penalty value when one cell is daughter of other. Should be between 0 and 1.