|
| 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