{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Introduction to the Insight Toolkit (ITK)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Learning Objectives\n", "\n", "* Learn how to **run** cells in **a Jupyter Notebook**\n", "* Run a segmentation example that demonstrates **ITK**'s ability to provide **insight into images**\n", "* Understand the **purpose and capabilities** of the toolkit" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Jupyter Notebooks" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "These are [Jupyter Notebooks](https://jupyter.org/), an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text.\n", "\n", "To run cells in the notebook, press *shift + enter*.\n", "\n", "For more information, see the [Notebook Help](https://nbviewer.jupyter.org/github/ipython/ipython/blob/3.x/examples/Notebook/Index.ipynb)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Insight Into Images" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2023-04-04T16:11:06.942152Z", "start_time": "2023-04-04T16:11:06.936143Z" }, "slideshow": { "slide_type": "slide" }, "tags": [] }, "outputs": [], "source": [ "import itk\n", "\n", "from packaging.version import parse\n", "from importlib.metadata import version\n", "\n", "if parse(version('itk')) < parse('5.3'):\n", " raise ValueError(\"ITK greater than version 5.3.0 is required for this notebook\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "from itkwidgets import view" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "slideshow": { "slide_type": "fragment" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "window.connectPlugin && window.connectPlugin(\"f81e438f-d312-4839-a364-2dd525f37a6e\")" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "file_name = \"data/brainweb165a10f17.mha\"\n", "image = itk.imread(file_name, itk.ctype(\"float\"))\n", "view(image, gradient_opacity=0.5)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "slideshow": { "slide_type": "subslide" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "window.connectPlugin && window.connectPlugin(\"f81e438f-d312-4839-a364-2dd525f37a6e\")" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Smooth the image\n", "smoothed = itk.curvature_flow_image_filter(\n", " image, number_of_iterations=6, time_step=0.005\n", ")\n", "view(smoothed, gradient_opacity=0.5)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "slideshow": { "slide_type": "subslide" }, "tags": [] }, "outputs": [], "source": [ "# Segment the white matter with a 3D region-growing algorithm\n", "confidence_connected = itk.ConfidenceConnectedImageFilter.New(smoothed)\n", "confidence_connected.SetMultiplier(2.5)\n", "confidence_connected.SetNumberOfIterations(5)\n", "confidence_connected.SetInitialNeighborhoodRadius(2)\n", "confidence_connected.SetReplaceValue(255)\n", "\n", "confidence_connected.AddSeed([118, 133, 92])\n", "confidence_connected.AddSeed([63, 135, 94])\n", "confidence_connected.AddSeed([63, 157, 90])\n", "confidence_connected.AddSeed([111, 150, 90])\n", "confidence_connected.AddSeed([111, 50, 88])\n", "confidence_connected.Update()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "slideshow": { "slide_type": "subslide" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "window.connectPlugin && window.connectPlugin(\"f81e438f-d312-4839-a364-2dd525f37a6e\")" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "view(\n", " image=smoothed,\n", " label_image=confidence_connected.GetOutput(),\n", " gradient_opacity=0.5\n", ")" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## History of ITK" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Insight into Images\n", "\n", "![Visible Human Head Rendering](data/VisibleHumanHeadRender.png)\n", "\n", "http://itk.org" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### History\n", "\n", "In 1999, the US National Institute of Health’s (NIH) National Library of Medicine (NLM) started a project to support the Visible Human Project.\n", "\n", "![Visible Human Logo](data/VisibleHumanLogo.png)\n", "\n", "![Visible Human Slice](data/VisibleHumanSlice.png)\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Goals\n", "\n", "* Collect best-of-the-best image analysis algorithms for reproducible science.\n", "* Provide a software resource for teaching medical image analysis algorithms.\n", "* Establish a foundation for future research.\n", "* Support commercial applications.\n", "* Create conventions for future work.\n", "* Grow a self-sustaining community of software users and developers." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Continued Development\n", "\n", "* Development has progressed since 1999\n", "* Contributions from over 267 developers\n", "* Over 1.6 million lines of code\n", "* Downloaded over 500,000 times\n", "\n", "![ITK contributors](data/itk-contributors.png)\n", "\n", "ITK contributors locations for the 4.8 and 4.9 releases." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Features" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### N-Dimensional Image Filtering\n", "\n", "![Filtering](data/Filtering.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Filtering Algorithms Classes\n", "\n", "* Fast marching methods\n", "* Convolution\n", "* Image gradient\n", "* Denoising\n", "* Thresholding\n", "* Mathematical morphology\n", "* Smoothing\n", "* Image features\n", "* Image statistics\n", "* Bias correction\n", "* Image grid operations\n", "* ...." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Segmentation\n", "\n", "\"Image segmentation is the process of partitioning a digital image into multiple segments, i.e. sets of pixels. The goal of segmentation is to simplify and/or change the representation of an image into something that is more meaningful and easier to analyze.\"\n", "\n", "Source: [Wikipedia](https://en.wikipedia.org/wiki/Image_segmentation)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Segmentation\n", "\n", "![Segmentation](data/SegmentationLevelSet.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Segmentation\n", "\n", "![Segmentation](data/Segmentation1.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Segmentation\n", "\n", "![Segmentation](data/Segmentation2.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Segmentation\n", "\n", "![Segmentation](data/Segmentation3.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Segmentation\n", "\n", "![Segmentation](data/Segmentation4.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Segmentation\n", "\n", "![Segmentation](data/Segmentation5.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Registration\n", "\n", "\"Image registration is the process of transforming different sets of data into one coordinate system. [...] Registration is necessary in order to be able to compare or integrate the data obtained from these different measurements.\"\n", "\n", "Source: [Wikipedia](https://en.wikipedia.org/wiki/Image_registration)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Registration\n", "\n", "![Registration](data/Registration.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Other Data Structures\n", "\n", "* Mesh's\n", "* Transforms's\n", "* SpatialObject's\n", "* Path's\n", "* LabelMap's\n", "\n", "![Mesh](data/Mesh.png)\n", "\n", "![Transform](data/Transformation.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### ITK Resources\n", "\n", "* ITK Software Guide: https://www.itk.org/ItkSoftwareGuide.pdf\n", "\n", "* Discourse Discussion: https://discourse.itk.org\n", "\n", "* Sphinx Examples: https://www.itk.org/ITKExamples\n", "\n", "* `ITK/Examples/` directory in the ITK source code repository\n", "\n", "* Doxygen: http://www.itk.org/Doxygen/html/index.html\n", "\n", "* Kitware: https://www.kitware.com/" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Kitware, Inc\n", "\n", "\n", "![Kitware ITK](data/KitwareITK.jpg)\n", "\n", "![Kitware overview](data/KitwareOverview.jpg)\n", "\n", "- Collaborative, Open Source, Scientific Software Development\n", "- Carrboro, NC, near University of North Carolina-Chapel Hill, in the Research Triangle" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Enjoy ITK!" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 4 }