Skip to content

Commit b26244c

Browse files
committed
cell stats notebook + docs
1 parent 39a472f commit b26244c

File tree

4 files changed

+104
-4
lines changed

4 files changed

+104
-4
lines changed

docs/res/code/model_instance_seg.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ binary_watershed
1313
**************************************
1414
.. autofunction:: napari_cellseg3d.model_instance_seg::binary_watershed
1515

16+
volume_stats
17+
**************************************
18+
.. autofunction:: napari_cellseg3d.model_instance_seg::volume_stats
19+
1620
clear_small_objects
1721
**************************************
1822
.. autofunction:: napari_cellseg3d.model_instance_seg::clear_small_objects

docs/res/guides/inference_module_guide.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@ Interface and functionalities
7575
.. _connected components: https://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.label
7676

7777

78+
* **Computing objects statistics** :
79+
80+
You can choose to compute various stats from the labels and save them to a csv for later use.
81+
This includes, for each object :
82+
83+
* Object volume (pixels)
84+
* :math:`X,Y,Z` coordinates of the centroid
85+
* Sphericity
86+
87+
And more general statistics :
88+
89+
* Image size
90+
* Total image volume (pixels)
91+
* Total object (labeled) volume (pixels)
92+
* Filling ratio (fraction of the volume that is labeled)
93+
* The number of labeled objects
94+
95+
In the ``notebooks`` folder you can find an example of plotting cell statistics using the result csv.
96+
7897
* **Viewing results** :
7998

8099
| You can also select whether you'd like to **see the results** in napari afterwards.

napari_cellseg3d/model_instance_seg.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,24 @@ def to_semantic(image, is_file_path=False):
172172

173173

174174
def volume_stats(volume_image):
175+
"""Computes various statistics from instance labels and returns them in a dict.
176+
Currently provided :
177+
178+
* "Volume": volume of each object
179+
* "Centroid": x,y,z centroid coordinates for each object
180+
* "Sphericity (axes)": sphericity computed from semi-minor and semi-major axes
181+
* "Image size": size of the image
182+
* "Total image volume": volume in pixels of the whole image
183+
* "Total object volume (pixels)": total labeled volume in pixels
184+
* "Filling ratio": ratio of labeled over total pixel volume
185+
* "Number objects": total number of unique labeled objects
186+
187+
Args:
188+
volume_image: instance labels image
189+
190+
Returns:
191+
dict: Statistics described above
192+
"""
175193

176194
properties = regionprops(volume_image)
177195
number_objects = np.amax(volume_image)
Lines changed: 63 additions & 4 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)