Calculate cell statistics — epitools.analysis.cell_statistics#
This module contains functions for calculating region-based properties of labelled images using skimage.
- epitools.analysis.cell_statistics.calculate_cell_statistics(image, labels, pixel_spacing, id_cells=None)#
Calculate the region based properties of a timeseries of segmented images.
- Currently the following statistics are calculated for each frame of the timeseries:
area
perimeter
number of neighbours
skimage.measure.regionprops_tableis used to calculated the area and perimeter.skimage.graph.RAGis used to create a graph of neighbouring cells at each frame, from which the number of neighbours of each cell is calculated.- Parameters:
image (napari.types.ImageData) – napari.types.ImageData Timeseries of images (TYX or TZYX) for which to calculate the cell statistics.
labels (napari.types.LabelsData) – napari.types.LabelsData Labelled input image, must be the same shape as
image. Labels with value 0 are ignored.pixel_spacing (tuple[float, ...]) – tuple[float, …] The pixel spacing in each dimension of the image.
id_cells (list[int] | None) – list[int], optional The cell IDs to calculate statistics for. If not provided, statistics will be calculated for all cells.
- Return type:
tuple[list[dict[str, npt.NDArray]], list[skimage.graph.RAG]]
Note
It is assumed that the first dimension of both
imageandlabelscorresponds to time.- Returns:
- list[dict[str, np.NDArray]]
List of dictionaries, where each dictionary contains the cell statistics for a single frame. The dictionary keys are: area; perimeter; neighbours.
- list[skimage.graph.RAG]
List of the network graphs constructed for each frame of the timeseries
- Parameters:
image (napari.types.ImageData)
labels (napari.types.LabelsData)
pixel_spacing (tuple[float, ...])
id_cells (list[int] | None)
- Return type:
tuple[list[dict[str, npt.NDArray]], list[skimage.graph.RAG]]