Package: itkwidgets
InteractiveJupyterwidgets to visualize images, point sets, and meshes on the web.Key Features:Visualize 2D and 3D images, point sets, and geometry, e.g. meshes, inJupyterSupport forNumPy arrayimagesitk.ImageDask arrayimagesvtk.vtkImageDatapyvista.UniformGridvedo.Volumepyimagej ImageJ / Fiji / ImageJ2 imagesAdditional NumPy array-like objectsSimpleITK.ImageNumPy array point setsitk.PointSetitk.PointBasedSpatialObjectvtk.vtkPolyDatapoint setspyvista.PolyDatapoint setsitk.Meshitk.PolyLineParametricPathvtk.vtkPolyDatavtk.vtkStructuredGridvtk.vtkUnstructuredGridvtk.vtkActorvtk.vtkVolumevtk.vtkAssemblypyvista.PolyDatapyvista.StructuredGridpyvista.UnstructuredGridvedo.Actorvedo.Assemblyskan.csr.SkeletonExquisite volume renderingTri-plane volume slicingInnovative, powerful opacity transfer function / window / level widgetLabel image segmentation 2D and 3D renderingAnisotropic voxel spacing supportedImage line profile widgetImage statistics widgetCompare images widgetWidgets to select solid colors for geometry or colormaps when point data or
cell data is availableVisualize point sets as points or spheres and interactively adjust the point
sizeCombine with otheripywidgetsto quickly create graphical interfaces
that interactively provide insights into data algorithmsThese widgets are designed to support spatial analysis with theInsight Toolkit
(ITK), but they work equally well with other spatial analysis tools
in the scientific Python ecosystem.These widgets are built onitk.jsandvtk.js.Examples on BinderData types:Binder: 2D ITK ImagesBinder: 3D ITK ImagesBinder: 3D Label ImagesBinder: Dask Array imagesBinder: Large volumesBinder: NumPy array images (processed with SciPy)Binder: NumPy array images (processed with scikit-image)Binder: NumPy array for image with anisotropic spacingBinder: NumPy array point setsBinder: ITK MeshBinder: ITK PointBasedSpatialObjectBinder: skan segmentation skeletonBinder: skan segmentation skeletonRecipes:Binder: Compare images with a checkerboard patternBinder: Compare images side by sideBinder: Examine a line profileBinder: Inspect image label statisticsBinder: Interactively explore algorithm parametersBinder: Record a videoBinder: Restore a volume opacity transfer functionBinder: Select a region of interestBinder: Specify camera parametersBinder: Specify a colormapInstallationTo install the widgets for the Jupyter Notebook with pip:pip install itkwidgetsFor Jupyter Lab, additionally, run:jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib jupyterlab-datawidgets itkwidgetsNoteJupyterLab 3 support is not yet available. JupyterLab 2 or the Jupyter
Notebook are possible alternatives.UsageIn Jupyter, import theviewfunction:from itkwidgets import viewThen, call theviewfunction at the end of a cell, passing in the image to
examine:view(image)For information on additional options, see theviewfunction docstring:view?Other available widgets:itkwidgets.line_profile: Plot an intensity line profile.itkwidgets.checkerboard: Compare two images in a checkerboard pattern.itkwidgets.compare: Compare two images side-by-side.Using within a Docker ContainerYou can useitkwidgetsfrom within a docker container with jupyterlab.
To create a local docker image:Installdockerand build the docker image with:git clone https://github.com/InsightSoftwareConsortium/itkwidgets
cd itkwidgets/docker
IMAGE=itkwidgets:0.1.0
docker build -t $IMAGE .Then run the docker container with:EXAMPLESDIR=`pwd`/../examples
docker run -it --rm -v $EXAMPLESDIR:/home/jovyan -p 8888:8888 itkwidgets:0.1.0Finally, connect to your notebook athttp://127.0.0.1:8888/labAdvanced UsageTheitkwidgetsare based onipywidgets.
As a consequence, widgets traits can be queried, assigned, or observed with
theviewerobject returned by theviewfunction.itkwidgetscan
be combined with otheripywidgetsto quickly explore algorithm parameters,
create graphical interfaces, or create data visualization dashboards.Mouse ControlsLeft click + dragRotateRight click + dragorshift + left click + dragPanMouse wheelorcontrol + left click + dragorpinchZoomAlt + left click + drag left-rightChange color transfer function windowShift + left click + drag top-bottomChange color transfer function levelShift + alt + left click + drag top-bottomChange primary Gaussian volume opacity transfer function magnitudeKeyboard ShortcutsKeyboard shortcuts take effect when the mouse is positioned inside the viewer.
All shortcuts are prefixed withAlt+. Corresponding keys for the Dvorak
keyboard layout have the same effect.Alt + 1X-plane modeAlt + 2Y-plane modeAlt + 3Z-plane modeAlt + 4Volume rendering modeAlt + qToggle user interfaceAlt + wToggle region of interest (ROI) selection widgetAlt + eReset ROIAlt + rReset cameraAlt + sToggle slicing planes in volume rendering modeAlt + fToggle fullscreenExamplesAfter installation, try the following examples that demonstrate how to visualize:2D ITK Images3D ITK Images3D Label mapsDask Array imagesLarge volumesImageJ ImgLib2 images(requirescondaand a localFijiinstallation)NumPy array images (processed with SciPy)NumPy array images (processed with scikit-image)NumPy array for image with anisotropic spacingVTK vtkImageDatapyvista UniformGridNumPy array point setsITK MeshITK PointBasedSpatialObjectVTK vtkPolyDataVTK vtkUnstructuredGridpyvista PolyDatapyvista StructuredGridpyvista UnstructuredGridpyvista LiDARvedo actors and volumesskan segmentation skeletonor how to:Compares images with a checkerboard patternCompares images side by sideExamine a line profileInspect image label statisticsInteractively explore algorithm parametersRecord a videoRestore a volume opacity transfer functionSelect a region of interestSpecify camera parametersSpecify a colormapTroubleshootingIOPub data rate exceeded.If you experience the notebook warning:IOPub data rate exceeded.
The notebook server will temporarily stop sending output
to the client in order to avoid crashing it.
To change this limit, set the config variable
`--NotebookApp.iopub_data_rate_limit`.Set the notebook configuration value:jupyter notebook --NotebookApp.iopub_data_rate_limit=1e12Scrolling in JupyterLabCell output scrolls by default in JupyterLab. To disable scrolling, right click
in the region to the left of the output and selectDisable Scrolling for
Outputs.‘Permission denied’ during installationIfPermission deniederrors occur during installation, install the Python
package withuserpermission via:pip install –user itkwidgetsFor JupyterLab extension installation, configure JupyterLab to use your user
application directory by setting the environmental variable,JUPYTERLAB_DIR:export JUPYTERLAB_DIR=$HOME/.local/share/jupyter/labCheck that this is picked up in the value of theApplication directoryreported by:jupyter lab pathThen, install the extension as usual:jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib jupyterlab-datawidgets itkwidgetsHackingParticipation is welcome! For a development installation (requiresNode.js):git clone https://github.com/InsightSoftwareConsortium/itkwidgets.git
cd itkwidgets
python -m pip install -r requirements-dev.txt -r requirements.txt
python -m pip install -e .
jupyter nbextension install --py --symlink --sys-prefix itkwidgets
jupyter nbextension enable --py --sys-prefix itkwidgets
jupyter nbextension enable --py --sys-prefix widgetsnbextension
python -m pytest
python -m pytest --nbmake examples/*.ipynbThe above commands will setup your system for development with the Jupyter
Notebook. In one terminal, start Jupyter:cd itkwidgets
jupyter notebookIn another terminal, put Webpack in watch mode to rebuild any Javascript
changes when you save a Javascript file:cd itkwidgets
npm run watchIf Python code is changed, restart the kernel to see the changes. If
Javascript code is changed, reload the page after to Webpack has finished
building.To develop for Jupyter Lab, additionally run:jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib jupyterlab-datawidgets jupyter-webrtc
jupyter labextension install ./js
jupyter lab --watchNoteHistorical note: this project was previously nameditk-jupyter-widgets, but it was renamed toitkwidgetsto be consistent with the package name.WarningThis project is under active development. Its API and behavior may change at any time. We mean it.