napari-imagegrains Statistical analysis: properties#
This widget allows you to post-process the segmentation results in order to compute statistical information about imagegrains.
Explore statistical analysis#
Segmented images can be analyzed statistically. For this purpose, you need to select an image folder and a folder with the corresponding prediction masks. The Prediction selection
section provides you with the possibility to enter a prediction string that is used as filter for the files in the predictions folder. A model string allows you to specify the model used for the prediction (if necessary).
In order to explore statistical analysis, click on the image list to select an image. Both the image and the corresponding prediction mask are displayed in the viewer. Now click on Run on image
. The result is plotted in the Analysis
section of the view.
By clicking on the floppy disk
symbol, you can save the plot of the selected parameter to the location you like.
In addition to the plot, the viewer generates a table with the complete statistical information for the image. It has one column for each parameter that is computed: label
, area
, orientation
, ell: b-axis (px)
, ell: a-axis (px)
, centerpoint y
, centerpoint x
, local centerpoint y
, and local centerpoint x
. For illustration purposes, a part of the table is displayed here as a pandas dataframe.
label | area | orientation | ell: b-axis (px) | ell: a-axis (px) | centerpoint y | centerpoint x | local centerpoint y | local centerpoint x | |
---|---|---|---|---|---|---|---|---|---|
0 | 1.0 | 140.0 | -1.456676 | 9.193372 | 19.925992 | 3.507143 | 27.371429 | 3.507143 | 9.371429 |
1 | 2.0 | 5381.0 | -1.380151 | 58.363628 | 121.854692 | 31.017655 | 84.660472 | 31.017655 | 62.660472 |
2 | 3.0 | 630.0 | 1.526123 | 17.095266 | 50.007787 | 6.433333 | 174.265079 | 6.433333 | 24.265079 |
3 | 4.0 | 627.0 | 1.502609 | 19.346094 | 43.055323 | 7.604466 | 302.685805 | 7.604466 | 20.685805 |
4 | 5.0 | 230.0 | -1.565825 | 8.792599 | 34.414801 | 3.165217 | 402.160870 | 3.165217 | 16.160870 |
5 | 6.0 | 549.0 | -1.058981 | 20.970834 | 33.443747 | 14.400729 | 485.200364 | 12.400729 | 15.200364 |
6 | 7.0 | 1215.0 | -0.196652 | 34.458467 | 45.646380 | 31.734979 | 330.127572 | 20.734979 | 17.127572 |
7 | 8.0 | 230.0 | -0.378509 | 14.335330 | 20.789856 | 22.578261 | 504.782609 | 9.578261 | 7.782609 |
8 | 9.0 | 125.0 | -1.311817 | 9.707114 | 16.701560 | 29.240000 | 306.208000 | 5.240000 | 8.208000 |
9 | 10.0 | 291.0 | 0.452555 | 16.412361 | 24.052767 | 42.298969 | 6.790378 | 12.298969 | 6.790378 |
10 | 11.0 | 366.0 | 0.034718 | 17.470407 | 26.992054 | 41.639344 | 139.628415 | 11.639344 | 8.628415 |
11 | 12.0 | 901.0 | 1.396543 | 23.613033 | 49.200566 | 41.124306 | 197.899001 | 11.124306 | 22.899001 |
12 | 13.0 | 77.0 | 0.978670 | 8.697770 | 11.435476 | 37.415584 | 360.129870 | 4.415584 | 5.129870 |
13 | 14.0 | 3342.0 | -0.978780 | 45.610652 | 94.597451 | 68.049970 | 428.989826 | 34.049970 | 39.989826 |
14 | 15.0 | 157.0 | -0.839069 | 13.251299 | 15.163923 | 48.528662 | 274.579618 | 6.528662 | 6.579618 |
15 | 16.0 | 790.0 | -0.713245 | 22.963008 | 44.239165 | 60.259494 | 384.718987 | 17.259494 | 15.718987 |
16 | 17.0 | 429.0 | -0.461369 | 20.241218 | 28.516126 | 62.491841 | 8.484848 | 12.491841 | 8.484848 |
17 | 18.0 | 83.0 | 0.700750 | 9.707985 | 10.870825 | 58.373494 | 155.445783 | 4.373494 | 4.445783 |
18 | 19.0 | 142.0 | -1.134908 | 9.710793 | 18.828938 | 60.901408 | 343.718310 | 5.901408 | 8.718310 |
19 | 20.0 | 2926.0 | 0.618101 | 56.899248 | 66.266548 | 87.053999 | 294.823308 | 31.053999 | 29.823308 |
You can explore the plots of the various parameters now. Change the analysis parameter, for example from area
to ell: a-axis (px)
. You will see the corresponding plot.
If you need to change the scale (default is 1 pixel/millimeter), activate the Scale
checkbox and change the scale, for example to 10 pixel/ millimeter. Click Run on image
and select ell: a-axis (mm)
in the dropdown menu of the Analysis
section. You see the adapted plot with the chosen millimeter scale. Be aware that the table generated earlier is updated. It now contains two more columns, ell: a-axis(mm)
and ell: b-axis (mm)
with the rescaled values.
label | area | orientation | ell: b-axis (px) | ell: a-axis (px) | centerpoint y | centerpoint x | local centerpoint y | local centerpoint x | ell: a-axis (mm) | ell: b-axis (mm) | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1.0 | 140.0 | -1.456676 | 9.193372 | 19.925992 | 3.507143 | 27.371429 | 3.507143 | 9.371429 | 199.259923 | 91.933723 |
1 | 2.0 | 5381.0 | -1.380151 | 58.363628 | 121.854692 | 31.017655 | 84.660472 | 31.017655 | 62.660472 | 1218.546921 | 583.636278 |
2 | 3.0 | 630.0 | 1.526123 | 17.095266 | 50.007787 | 6.433333 | 174.265079 | 6.433333 | 24.265079 | 500.077865 | 170.952662 |
3 | 4.0 | 627.0 | 1.502609 | 19.346094 | 43.055323 | 7.604466 | 302.685805 | 7.604466 | 20.685805 | 430.553228 | 193.460943 |
4 | 5.0 | 230.0 | -1.565825 | 8.792599 | 34.414801 | 3.165217 | 402.160870 | 3.165217 | 16.160870 | 344.148008 | 87.925994 |
5 | 6.0 | 549.0 | -1.058981 | 20.970834 | 33.443747 | 14.400729 | 485.200364 | 12.400729 | 15.200364 | 334.437469 | 209.708343 |
6 | 7.0 | 1215.0 | -0.196652 | 34.458467 | 45.646380 | 31.734979 | 330.127572 | 20.734979 | 17.127572 | 456.463802 | 344.584670 |
7 | 8.0 | 230.0 | -0.378509 | 14.335330 | 20.789856 | 22.578261 | 504.782609 | 9.578261 | 7.782609 | 207.898557 | 143.353295 |
8 | 9.0 | 125.0 | -1.311817 | 9.707114 | 16.701560 | 29.240000 | 306.208000 | 5.240000 | 8.208000 | 167.015605 | 97.071135 |
9 | 10.0 | 291.0 | 0.452555 | 16.412361 | 24.052767 | 42.298969 | 6.790378 | 12.298969 | 6.790378 | 240.527666 | 164.123612 |
10 | 11.0 | 366.0 | 0.034718 | 17.470407 | 26.992054 | 41.639344 | 139.628415 | 11.639344 | 8.628415 | 269.920545 | 174.704073 |
11 | 12.0 | 901.0 | 1.396543 | 23.613033 | 49.200566 | 41.124306 | 197.899001 | 11.124306 | 22.899001 | 492.005659 | 236.130332 |
12 | 13.0 | 77.0 | 0.978670 | 8.697770 | 11.435476 | 37.415584 | 360.129870 | 4.415584 | 5.129870 | 114.354762 | 86.977700 |
13 | 14.0 | 3342.0 | -0.978780 | 45.610652 | 94.597451 | 68.049970 | 428.989826 | 34.049970 | 39.989826 | 945.974505 | 456.106524 |
14 | 15.0 | 157.0 | -0.839069 | 13.251299 | 15.163923 | 48.528662 | 274.579618 | 6.528662 | 6.579618 | 151.639225 | 132.512994 |
15 | 16.0 | 790.0 | -0.713245 | 22.963008 | 44.239165 | 60.259494 | 384.718987 | 17.259494 | 15.718987 | 442.391646 | 229.630081 |
16 | 17.0 | 429.0 | -0.461369 | 20.241218 | 28.516126 | 62.491841 | 8.484848 | 12.491841 | 8.484848 | 285.161262 | 202.412185 |
17 | 18.0 | 83.0 | 0.700750 | 9.707985 | 10.870825 | 58.373494 | 155.445783 | 4.373494 | 4.445783 | 108.708248 | 97.079848 |
18 | 19.0 | 142.0 | -1.134908 | 9.710793 | 18.828938 | 60.901408 | 343.718310 | 5.901408 | 8.718310 | 188.289380 | 97.107930 |
19 | 20.0 | 2926.0 | 0.618101 | 56.899248 | 66.266548 | 87.053999 | 294.823308 | 31.053999 | 29.823308 | 662.665481 | 568.992484 |
Fitting ellipses and contours#
You can fit ellipses to the objects displayed in the images by clicking Display fit
having the (default) ellipse
option selected. You will see the fitted ellipses and the small and large ellipse axes displayed.
Alternatively, you can select the display fit option mask_outline
in order to see the contours of the objects together with the large and small axes.
Continue exploration with another image#
You can continue your exploration by selecting another image from the image list. The GUI is refreshed. Click Run on image
. You obtain updated data: a new plot for the parameter and the scale selected and a new data table with the computation results of all parameters.
label | area | orientation | ell: b-axis (px) | ell: a-axis (px) | centerpoint y | centerpoint x | local centerpoint y | local centerpoint x | ell: a-axis (mm) | ell: b-axis (mm) | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1.0 | 2024.0 | 0.678452 | 38.376972 | 69.674880 | 24.733202 | 178.959980 | 24.733202 | 28.959980 | 696.748803 | 383.769721 |
1 | 2.0 | 356.0 | 1.495168 | 11.379690 | 43.314820 | 4.264045 | 246.500000 | 4.264045 | 22.500000 | 433.148202 | 113.796905 |
2 | 3.0 | 9043.0 | 1.393541 | 76.181379 | 159.363830 | 55.233772 | 68.796307 | 53.233772 | 68.796307 | 1593.638299 | 761.813789 |
3 | 4.0 | 684.0 | 1.179391 | 24.462879 | 35.938455 | 20.409357 | 373.334795 | 13.409357 | 17.334795 | 359.384546 | 244.628787 |
4 | 5.0 | 20179.0 | -1.235987 | 119.862382 | 246.477057 | 100.567719 | 421.975916 | 93.567719 | 123.975916 | 2464.770570 | 1198.623815 |
5 | 6.0 | 776.0 | 1.247763 | 26.350713 | 38.210081 | 22.252577 | 127.110825 | 14.252577 | 18.110825 | 382.100812 | 263.507132 |
6 | 7.0 | 2396.0 | -0.542597 | 47.521846 | 65.238575 | 38.836811 | 228.969950 | 30.836811 | 25.969950 | 652.385753 | 475.218457 |
7 | 8.0 | 283.0 | -0.075805 | 16.969598 | 22.132615 | 37.558304 | 406.554770 | 11.558304 | 8.554770 | 221.326147 | 169.695976 |
8 | 9.0 | 1607.0 | -0.985657 | 42.552610 | 48.915681 | 52.005600 | 380.457996 | 25.005600 | 23.457996 | 489.156810 | 425.526101 |
9 | 10.0 | 245.0 | 0.174745 | 14.737184 | 21.286693 | 39.502041 | 155.906122 | 9.502041 | 6.906122 | 212.866933 | 147.371840 |
10 | 11.0 | 240.0 | -0.161810 | 16.429740 | 18.727491 | 44.666667 | 130.579167 | 8.666667 | 7.579167 | 187.274908 | 164.297403 |
11 | 12.0 | 141.0 | 0.061559 | 11.469134 | 15.736936 | 52.361702 | 301.709220 | 7.361702 | 5.709220 | 157.369362 | 114.691340 |
12 | 13.0 | 556.0 | -0.353134 | 25.915958 | 28.201607 | 60.803957 | 413.643885 | 13.803957 | 12.643885 | 282.016068 | 259.159578 |
13 | 14.0 | 380.0 | -0.722441 | 18.802522 | 25.856247 | 59.992105 | 157.621053 | 11.992105 | 10.621053 | 258.562468 | 188.025220 |
14 | 15.0 | 517.0 | 1.167611 | 17.065827 | 39.301020 | 70.001934 | 201.628627 | 10.001934 | 19.628627 | 393.010198 | 170.658266 |
15 | 16.0 | 1441.0 | 1.543631 | 30.957643 | 60.614168 | 98.086745 | 172.376128 | 16.086745 | 30.376128 | 606.141678 | 309.576426 |
16 | 17.0 | 284.0 | -0.254670 | 17.382077 | 20.911184 | 93.126761 | 302.383803 | 10.126761 | 9.383803 | 209.111837 | 173.820770 |
17 | 18.0 | 152.0 | 1.547690 | 11.396499 | 17.240679 | 90.092105 | 270.019737 | 5.092105 | 8.019737 | 172.406786 | 113.964992 |
18 | 19.0 | 203.0 | 1.227951 | 15.115707 | 17.597611 | 94.206897 | 252.044335 | 6.206897 | 8.044335 | 175.976106 | 151.157070 |
19 | 20.0 | 300.0 | -0.958100 | 14.251070 | 30.258609 | 108.276667 | 253.386667 | 11.276667 | 12.386667 | 302.586095 | 142.510700 |
Interactive table#
The table generated when you click on Run on image
is interactive. In the napari viewer, on the left side, activate the checkbox show selected
. If you click on any sample in the table now, you will see the corresponding object highlighted in the viewer.
Analyze entire folder#
Open a new viewer instance, select an image folder and a folder containing the prediction masks an click Run on folder
. You obtain a plot of the selected (default) parameter displayed in the viewer. For each image in the folder you obtain a csv file
with the entire table information instead of individual tables. These csv files
are stored in your export folder and named in accordance with the prediction masks.
Here as well, you can browse through the plots of the parameters you are interested in (e.g. orientation
). Be aware that the plots represent the sum of the objects in all images in the folder now.
With Load for folder
you can reload the data generated in this section in case that you have to restart the application.