Skip to content

Commit 379da47

Browse files
committed
ENH: Add label_statistics widget
1 parent 8681486 commit 379da47

File tree

6 files changed

+348
-9
lines changed

6 files changed

+348
-9
lines changed

README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ Interactive Jupyter_ widgets to visualize images, point sets, and meshes.
7878
- Exquisite volume rendering
7979
- Tri-plane volume slicing
8080
- Innovative, powerful opacity transfer function / window / level widget
81-
- Label map segmentation 2D and 3D rendering
81+
- Label image segmentation 2D and 3D rendering
8282
- Anisotropic voxel spacing supported
8383
- Image line profile widget
84+
- Image statistics widget
8485
- Compare images widget
8586
- Widgets to select solid colors for geometry or colormaps when point data or
8687
cell data is availble
@@ -119,12 +120,14 @@ Data types:
119120
- `Binder: ITK Mesh <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/Mesh.ipynb>`_
120121
- `Binder: ITK PointBasedSpatialObject <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/PointBasedSpatialObject.ipynb>`_
121122
- `Binder: skan segmentation skeleton <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/SegmentationSkeleton.ipynb>`_
123+
- `Binder: skan segmentation skeleton <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/SegmentationSkeleton.ipynb>`_
122124

123125
Recipes:
124126

125127
- `Binder: Compare images with a checkerboard pattern <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/Checkerboard.ipynb>`_
126128
- `Binder: Compare images side by side <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/CompareImages.ipynb>`_
127129
- `Binder: Examine a line profile <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/LineProfile.ipynb>`_
130+
- `Binder: Inspect image label statistics <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/ImageLabelStatistics.ipynb>`_
128131
- `Binder: Interactively explore algorithm parameters <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/InteractiveParameterExploration.ipynb>`_
129132
- `Binder: Record a video <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/RecordAVideo.ipynb>`_
130133
- `Binder: Restore a volume opacity transfer function <https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/master?urlpath=lab/tree/examples/VolumeOpacityTransferFunction.ipynb>`_
@@ -290,6 +293,7 @@ or how to:
290293
- `Compares images with a checkerboard pattern <https://github.com/InsightSoftwareConsortium/itkwidgets/blob/master/examples/Checkerboard.ipynb>`_
291294
- `Compares images side by side <https://github.com/InsightSoftwareConsortium/itkwidgets/blob/master/examples/CompareImages.ipynb>`_
292295
- `Examine a line profile <https://github.com/InsightSoftwareConsortium/itkwidgets/blob/master/examples/LineProfile.ipynb>`_
296+
- `Inspect image label statistcs <https://github.com/InsightSoftwareConsortium/itkwidgets/blob/master/examples/ImageLabelStatistics.ipynb>`_
293297
- `Interatively explore algorithm parameters <https://github.com/InsightSoftwareConsortium/itkwidgets/blob/master/examples/InteractiveParameterExploration.ipynb>`_
294298
- `Record a video <https://github.com/InsightSoftwareConsortium/itkwidgets/blob/master/examples/RecordAVideo.ipynb>`_
295299
- `Restore a volume opacity transfer function <https://github.com/InsightSoftwareConsortium/itkwidgets/blob/master/examples/VolumeOpacityTransferFunction.ipynb>`_
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"# Install dependencies for this example\n",
10+
"# Note: This does not include itkwidgets, itself\n",
11+
"import sys\n",
12+
"!{sys.executable} -m pip install -U itk plotly"
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": 1,
18+
"metadata": {},
19+
"outputs": [],
20+
"source": [
21+
"from urllib.request import urlretrieve\n",
22+
"import os\n",
23+
"\n",
24+
"import itk\n",
25+
"import numpy as np\n",
26+
"\n",
27+
"from itkwidgets import label_statistics, view\n",
28+
"import itkwidgets"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": 2,
34+
"metadata": {},
35+
"outputs": [],
36+
"source": [
37+
"# Download data\n",
38+
"# Source: Simulated nuclei of HL60 cells stained with Hoescht\n",
39+
"# Dr. V. Ulman and Dr. D. Svoboda. Centre for Biomedical Image Analysis (CBIA),\n",
40+
"# http://doi.org/10.1109/TMI.2016.2606545\n",
41+
"file_name = 'Fluo-N3DH-SIM+-01-t148.nrrd'\n",
42+
"if not os.path.exists(file_name):\n",
43+
" url = 'https://data.kitware.com/api/v1/file/5f20d3a79014a6d84e462462/download'\n",
44+
" urlretrieve(url, file_name)\n",
45+
"label_file_name = 'Fluo-N3DH-SIM+-01_GT-SEG-man_seg148.nrrd'\n",
46+
"if not os.path.exists(label_file_name):\n",
47+
" url = 'https://data.kitware.com/api/v1/file/5f20d3a69014a6d84e462457/download'\n",
48+
" urlretrieve(url, label_file_name)"
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": 3,
54+
"metadata": {},
55+
"outputs": [],
56+
"source": [
57+
"image = itk.imread(file_name)\n",
58+
"binary_labels = itk.imread(label_file_name)\n",
59+
"\n",
60+
"label_image = itk.connected_component_image_filter(binary_labels)"
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": 4,
66+
"metadata": {},
67+
"outputs": [],
68+
"source": [
69+
"# A few viewer settings that work nicely with this dataset.\n",
70+
"opacity_gaussians = [[{'position': 0.17082204155374883,\n",
71+
" 'height': 1,\n",
72+
" 'width': 0.17082204155374883,\n",
73+
" 'xBias': 0.06522802840370252,\n",
74+
" 'yBias': 0.40466784651165977}]]\n",
75+
"camera = np.array([[ 6.6004913e+01, 4.5845730e+01, 1.1898222e+02],\n",
76+
" [ 4.0518013e+01, 2.3266140e+01, 1.5647539e+01],\n",
77+
" [-2.4525525e-02, 9.7789967e-01, -2.0763110e-01]], dtype=np.float32)"
78+
]
79+
},
80+
{
81+
"cell_type": "code",
82+
"execution_count": 5,
83+
"metadata": {},
84+
"outputs": [
85+
{
86+
"data": {
87+
"application/vnd.jupyter.widget-view+json": {
88+
"model_id": "3c1d54940fec4eb08e648bbef430b721",
89+
"version_major": 2,
90+
"version_minor": 0
91+
},
92+
"text/plain": [
93+
"AppLayout(children=(Viewer(camera=array([[ 6.6004913e+01, 4.5845730e+01, 1.1898222e+02],\n",
94+
" [ 4.0518013e…"
95+
]
96+
},
97+
"metadata": {},
98+
"output_type": "display_data"
99+
}
100+
],
101+
"source": [
102+
"label_statistics(image=image,\n",
103+
" label_image=label_image,\n",
104+
" histogram=True,\n",
105+
" opacity_gaussians=opacity_gaussians,\n",
106+
" camera=camera)"
107+
]
108+
},
109+
{
110+
"cell_type": "markdown",
111+
"metadata": {},
112+
"source": [
113+
"Select label markers from the statistics graph in the lower left to highlight them in the image visualization and provide their intensity histograms."
114+
]
115+
}
116+
],
117+
"metadata": {
118+
"kernelspec": {
119+
"display_name": "Python 3",
120+
"language": "python",
121+
"name": "python3"
122+
},
123+
"language_info": {
124+
"codemirror_mode": {
125+
"name": "ipython",
126+
"version": 3
127+
},
128+
"file_extension": ".py",
129+
"mimetype": "text/x-python",
130+
"name": "python",
131+
"nbconvert_exporter": "python",
132+
"pygments_lexer": "ipython3",
133+
"version": "3.7.6"
134+
}
135+
},
136+
"nbformat": 4,
137+
"nbformat_minor": 4
138+
}

0 commit comments

Comments
 (0)