Skip to content

Commit

Permalink
DOC: LabelMap example updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Jun 3, 2020
1 parent fa25a93 commit 5d5fc43
Showing 1 changed file with 14 additions and 26 deletions.
40 changes: 14 additions & 26 deletions examples/LabelMap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: itk-io in /home/matt/bin/miniconda3/envs/itkwidgets/lib/python3.7/site-packages (5.1.0.post1)\r\n",
"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"
]
}
],
"outputs": [],
"source": [
"# Install dependencies for this example\n",
"# Note: This does not include itkwidgets, itself\n",
Expand All @@ -23,22 +14,23 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"from urllib.request import urlretrieve\n",
"import os\n",
"\n",
"import itk\n",
"import numpy as np\n",
"\n",
"from itkwidgets import view\n",
"import itkwidgets"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 41,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -55,7 +47,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -65,15 +57,15 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 43,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "37dcf1f9c89b4f9c8e7ab039d3f38dde",
"model_id": "a588b530f15c4d3ba2b1b13a04b8d6f5",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -98,20 +90,16 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"names = [(0, 'Background'), (1, 'First cell'), (2, 'Second cell')]\n",
"viewer.label_map_names = names"
"label_count = len(np.unique(itk.array_view_from_image(label_map)))\n",
"label_weights = np.ones((label_count,), dtype=np.float32)\n",
"label_weights[1] = 0.1\n",
"label_weights[2] = 0.2\n",
"viewer.label_map_weights = label_weights"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 5d5fc43

Please sign in to comment.