Skip to content

Commit 5d5fc43

Browse files
committed
DOC: LabelMap example updates
1 parent fa25a93 commit 5d5fc43

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

examples/LabelMap.ipynb

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,9 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"metadata": {},
7-
"outputs": [
8-
{
9-
"name": "stdout",
10-
"output_type": "stream",
11-
"text": [
12-
"Requirement already satisfied: itk-io in /home/matt/bin/miniconda3/envs/itkwidgets/lib/python3.7/site-packages (5.1.0.post1)\r\n",
13-
"Requirement already satisfied: itk-core==5.1.0.post1 in /home/matt/bin/miniconda3/envs/itkwidgets/lib/python3.7/site-packages (from itk-io) (5.1.0.post1)\r\n"
14-
]
15-
}
16-
],
7+
"outputs": [],
178
"source": [
189
"# Install dependencies for this example\n",
1910
"# Note: This does not include itkwidgets, itself\n",
@@ -23,22 +14,23 @@
2314
},
2415
{
2516
"cell_type": "code",
26-
"execution_count": 1,
17+
"execution_count": 37,
2718
"metadata": {},
2819
"outputs": [],
2920
"source": [
3021
"from urllib.request import urlretrieve\n",
3122
"import os\n",
3223
"\n",
3324
"import itk\n",
25+
"import numpy as np\n",
3426
"\n",
3527
"from itkwidgets import view\n",
3628
"import itkwidgets"
3729
]
3830
},
3931
{
4032
"cell_type": "code",
41-
"execution_count": 2,
33+
"execution_count": 41,
4234
"metadata": {},
4335
"outputs": [],
4436
"source": [
@@ -55,7 +47,7 @@
5547
},
5648
{
5749
"cell_type": "code",
58-
"execution_count": 3,
50+
"execution_count": 42,
5951
"metadata": {},
6052
"outputs": [],
6153
"source": [
@@ -65,15 +57,15 @@
6557
},
6658
{
6759
"cell_type": "code",
68-
"execution_count": 21,
60+
"execution_count": 43,
6961
"metadata": {
7062
"scrolled": true
7163
},
7264
"outputs": [
7365
{
7466
"data": {
7567
"application/vnd.jupyter.widget-view+json": {
76-
"model_id": "37dcf1f9c89b4f9c8e7ab039d3f38dde",
68+
"model_id": "a588b530f15c4d3ba2b1b13a04b8d6f5",
7769
"version_major": 2,
7870
"version_minor": 0
7971
},
@@ -98,20 +90,16 @@
9890
},
9991
{
10092
"cell_type": "code",
101-
"execution_count": 5,
93+
"execution_count": 17,
10294
"metadata": {},
10395
"outputs": [],
10496
"source": [
105-
"names = [(0, 'Background'), (1, 'First cell'), (2, 'Second cell')]\n",
106-
"viewer.label_map_names = names"
97+
"label_count = len(np.unique(itk.array_view_from_image(label_map)))\n",
98+
"label_weights = np.ones((label_count,), dtype=np.float32)\n",
99+
"label_weights[1] = 0.1\n",
100+
"label_weights[2] = 0.2\n",
101+
"viewer.label_map_weights = label_weights"
107102
]
108-
},
109-
{
110-
"cell_type": "code",
111-
"execution_count": null,
112-
"metadata": {},
113-
"outputs": [],
114-
"source": []
115103
}
116104
],
117105
"metadata": {

0 commit comments

Comments
 (0)