Skip to content

Commit 690d0ba

Browse files
authored
Merge pull request #55 from C-Achard/general_improvements
WIP : General improvements
2 parents 84b80b3 + b26244c commit 690d0ba

34 files changed

+5599
-1065
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ __pycache__/
77
*.so
88

99
# unwanted results files
10-
*.csv
10+
*.tif
11+
napari_cellseg3d/_tests/res/*.csv
1112

1213
# Distribution / packaging
1314
.Python
@@ -90,7 +91,8 @@ venv/
9091

9192
########
9293
#project specific
93-
#dataset, weights, old logos
94+
#dataset, weights, old logos, requirements
9495
/napari_cellseg3d/models/dataset/
9596
/napari_cellseg3d/models/saved_weights/
9697
/docs/res/logo/old_logo/
98+
/reqs/

docs/res/code/interface.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ make_group
1818
**************************************
1919
.. autofunction:: napari_cellseg3d.interface::make_group
2020

21+
add_to_group
22+
**************************************
23+
.. autofunction:: napari_cellseg3d.interface::add_to_group
2124

22-
make_container_widget
25+
make_container
2326
**************************************
24-
.. autofunction:: napari_cellseg3d.interface::make_container_widget
27+
.. autofunction:: napari_cellseg3d.interface::make_container
2528

2629

2730
make_button

docs/res/code/model_framework.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Class : ModelFramework
1212
Methods
1313
**********************
1414
.. autoclass:: napari_cellseg3d.model_framework::ModelFramework
15-
:members: __init__,load_dataset_paths,save_log,get_model, get_loss,display_status_report,load_dataset_paths,create_train_dataset_dict, load_image_dataset, load_label_dataset,load_results_path,load_model_path,get_device, update_default, remove_from_viewer
15+
:members: __init__,toggle_visibility, load_dataset_paths,save_log, save_log_to_path,get_model, get_loss,display_status_report,load_dataset_paths,create_train_dataset_dict, load_image_dataset, load_label_dataset,load_results_path,load_model_path,get_device, update_default, remove_from_viewer
1616
:noindex:
1717

1818

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/code/plugin_convert.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Class : ConvertUtils
1111
Methods
1212
**********************
1313
.. autoclass:: napari_cellseg3d.plugin_convert::ConvertUtils
14-
:members: __init__, build, folder_to_semantic, layer_to_semantic, folder_to_instance, layer_to_instance, layer_remove_small, folder_remove_small ,check_ready_folder, check_ready_layer :noindex:
14+
:members: __init__, build, folder_to_semantic, layer_to_semantic, folder_to_instance, layer_to_instance, layer_remove_small, folder_remove_small , check_ready_layer,check_ready_folder
1515
:noindex:
1616

1717
Attributes

docs/res/code/utils.rst

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

16+
time_difference
17+
**************************************
18+
.. autofunction:: napari_cellseg3d.utils::time_difference
19+
1620
get_time_filepath
1721
**************************************
1822
.. autofunction:: napari_cellseg3d.utils::get_time_filepath
@@ -29,6 +33,14 @@ dice_coeff
2933
**************************************
3034
.. autofunction:: napari_cellseg3d.utils::dice_coeff
3135

36+
sphericity_volume_area
37+
**************************************
38+
.. autofunction:: napari_cellseg3d.utils::sphericity_volume_area
39+
40+
sphericity_axis
41+
**************************************
42+
.. autofunction:: napari_cellseg3d.utils::sphericity_axis
43+
3244
normalize_x
3345
**************************************
3446
.. autofunction:: napari_cellseg3d.utils::normalize_x

docs/res/guides/inference_module_guide.rst

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,74 @@ Interface and functionalities
3131

3232
* **Loading data** :
3333

34-
| When launching the module, you will be asked to provide an image folder containing all the volumes you'd like to be labeled.
35-
| All images with the chosen (**.tif** or **.tiff** currently supported) extension in this folder will be labeled.
36-
| You can then choose an output folder, where all the results will be saved.
34+
| When launching the module, you will be asked to provide an **image folder** containing all the volumes you'd like to be labeled.
35+
| All images with the chosen extension (**.tif** or **.tiff** currently supported) in this folder will be labeled.
36+
| You can then choose an **output folder**, where all the results will be saved.
3737
3838

3939
* **Model choice** :
4040

41-
| You can then choose one of the provided models above, which will be used for inference.
42-
| You may also choose to load custom weights rather than the pre-trained ones, simply ensure they are compatible (e.g. produced from the training module for the same model)
41+
| You can then choose one of the provided **models** above, which will be used for inference.
42+
| You may also choose to **load custom weights** rather than the pre-trained ones, simply ensure they are **compatible** (e.g. produced from the training module for the same model)
43+
44+
.. note::
45+
Currently the SegResNet model requires you to provide the size of the images the model was trained with due to the VAE module.
46+
Provided weights use a size of 128, please leave it as is if you're not using custom weights.
47+
48+
* **Inference parameters** :
49+
50+
| You can choose to use inference on the whole image at once, which generally yields better performance at the cost of more memory,
51+
| or you can use a specific window size to run inference on smaller chunks one by one, for lower memory usage.
52+
| You can also choose to keep the dataset in the RAM rather than the VRAM (cpu vs cuda device) to avoid running out of VRAM
53+
| if you have several images.
4354
4455

4556
* **Anisotropy** :
4657

47-
| If you want to see your results without anisotropy when you have anisotropic images, you can specify that you have anisotropic data
48-
| and set the resolution of your image in micron, this wil save and show the results without anisotropy.
58+
| If you want to see your results without **anisotropy** when you have anisotropic images, you can specify that you have anisotropic data
59+
| and set the **resolution of your imaging method in micron**, this wil save and show the results without anisotropy.
4960
5061

5162
* **Thresholding** :
5263

53-
| You can perform thresholding to binarize your labels, all values beneath the confidence threshold will be set to 0 using this.
54-
| If you wish to use instance segmentation it is recommended to use thresholding.
64+
| You can perform thresholding to **binarize your labels**,
65+
| all values beneath the **confidence threshold** will be set to 0 using this.
5566
5667
* **Instance segmentation** :
5768

58-
| You can convert the semantic segmentation into instance labels by using either the watershed or connected components method.
69+
| You can convert the semantic segmentation into instance labels by using either the `watershed`_ or `connected components`_ method.
5970
| You can set the probability threshold from which a pixel is considered as a valid instance, as well as the minimum size in pixels for objects. All smaller objects will be removed.
6071
| Instance labels will be saved (and shown if applicable) separately from other results.
6172
73+
74+
.. _watershed: https://scikit-image.org/docs/dev/auto_examples/segmentation/plot_watershed.html
75+
.. _connected components: https://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.label
76+
77+
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+
6297
* **Viewing results** :
6398

64-
| You can also select whether you'd like to see the results in napari afterwards.
65-
| By default the first image processed will be displayed, but you can choose to display up to ten at once. You can also request to see the originals.
99+
| You can also select whether you'd like to **see the results** in napari afterwards.
100+
| By default the first image processed will be displayed, but you can choose to display up to **ten at once**.
101+
| You can also request to see the originals.
66102
67103

68104
When you are done choosing your parameters, you can press the **Start** button to begin the inference process.

docs/res/guides/metrics_module_guide.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@ The Dice coefficient is defined as :
1111

1212
It is a measure of similarity between two sets- :math:`0` indicating no similarity and :math:`1` complete similarity.
1313

14-
You will need to provide two folders : one for ground truth labels and one for predicition labels.
14+
You will need to provide the following parameters:
15+
16+
* Two folders : one for ground truth labels and one for prediction labels.
17+
18+
* The threshold below which the score is considered insufficient.
19+
Any pair below that score will be shown on the viewer; and be displayed in red in the plot.
20+
21+
* Whether to automatically determine the best orientation for the computation by rotating and flipping;
22+
use this if your images do not have the same orientation.
23+
24+
.. note::
25+
Due to changes in orientation of images after running inference, the utility can rotate and flip images randomly to find the best Dice coefficient
26+
to compensate. If you have small images with a very large number of labels, this can lead to an inexact metric being computed.
27+
Images with a low score might be in the wrong orientation as well when displayed for comparison.
1528

1629
.. important::
1730
This utility assumes that **predictions are padded to a power of two already.** Ground truth labels can be smaller,
@@ -22,10 +35,6 @@ Once you are ready, press the "Compute Dice" button. This will plot the Dice sco
2235
Pairs with a low score will be displayed on the viewer for checking, ground truth in **blue**, low score prediction in **red**.
2336

2437

25-
.. note::
26-
Due to changes in orientation of images after running inference, the utility will rotate and flip images to find the best Dice coefficient
27-
to compensate. If you have small images with a very large number of labels, this can lead to an inexact metric being computed.
28-
Images with a low score might be in the wrong orientation as well when displayed for comparison.
2938

3039

3140
Source code

docs/res/guides/review_module_guide.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Reviewer module guide
44
=================================
55

66
This module allows you to review your labels, from predictions or manual labeling,
7-
and correct them if needed. It then saves the status of each file in a csv, for easier monitoring.
7+
and correct them if needed. It then saves the status of each file in a csv, as well as the time taken per slice review, for easier monitoring.
88

99

1010

@@ -17,13 +17,13 @@ Launching the review process
1717
Folders can be stacks of either **.png** or **.tif** files, ideally numbered with the index of the slice at the end.
1818

1919
.. note::
20-
Only single .tif files or folder of several .png or .tif are supported.
20+
Only single .tif files or folder of several .png or .tif are currently supported.
2121

22-
* Model name :
22+
* Csv file name :
2323
You can then provide a model name, which will be used to name the csv file recording the status of each slice.
2424

2525
If a corresponding csv file exists already, it will be used. If not, a new one will be created.
26-
If you choose to create a new dataset, a new csv will be created no matter what,
26+
If you choose to create a new dataset, a new csv will always be created,
2727
with a trailing number if several copies of it already exists.
2828

2929
* Start :

0 commit comments

Comments
 (0)