Skip to main content

Interactive Jupyter widgets to visualize images, point sets, and meshes in 2D and 3D

Project description

License PyPI Build status https://mybinder.org/badge.svg

Interactive Jupyter widgets to visualize images, point sets, and meshes.

itkwidgets chest CT in JupyterLab

Key Features:

  • Visualize 2D and 3D images, point sets, and geometry, e.g. meshes, in Jupyter

  • Support for

    • NumPy array images

    • itk.Image

    • Dask array images

    • vtk.vtkImageData

    • pyvista.UniformGrid

    • vtkplotter.Volume

    • ImageJ / Fiji / ImageJ2 images

    • Additional NumPy array-like objects

    • NumPy array point sets

    • itk.PointSet

    • vtk.vtkPolyData point sets

    • pyvista.PolyData point sets

    • itk.Mesh

    • vtk.vtkPolyData

    • vtk.vtkStructuredGrid

    • vtk.vtkUnstructuredGrid

    • vtk.vtkActor

    • vtk.vtkVolume

    • vtk.vtkAssembly

    • pyvista.PolyData

    • pyvista.StructuredGrid

    • pyvista.UnstructuredGrid

    • vtkplotter.Actor

    • vtkplotter.Assembly

  • Exquisite volume rendering

  • Tri-plane volume slicing

  • Innovative, powerful opacity transfer function / window / level widget

  • Anisotropic voxel spacing supported

  • Image line profile widget

  • Widgets to select solid colors for geometry or colormaps when point data or cell data is availble

  • Visualize point sets as points or spheres and interactively adjust the point size

  • Combine with other ipywidgets to quickly create graphical interfaces that interactively provide insights into data algorithms

itkwidgets demo

These widgets are designed to support spatial analysis with the Insight Toolkit (ITK), but they work equally well with other spatial analysis tools in the scientific Python ecosystem.

These widgets are built on itk.js and vtk.js.

Examples on Binder

Data types:

Tasks:

Installation

To install the widgets for the Jupyter Notebook with pip:

pip install itkwidgets

or with conda:

conda install -c conda-forge itkwidgets

For Jupyter Lab, additionally run:

jupyter labextension install @jupyter-widgets/jupyterlab-manager itkwidgets

Usage

In Jupyter, import the view function:

from itkwidgets import view

Then, call the view function at the end of a cell, passing in the image to examine:

view(image)

For information on additional options, see the view function docstring:

view?

Other available widgets:

  • itkwidgets.line_profile: Plot an intensity line profile.

  • itkwidgets.checkerboard: Compare two images in a checkerboard pattern.

Advanced Usage

The itkwidgets are based on ipywidgets. As a consequence, widgets traits can be queried, assigned, or observed with the viewer object returned by the view function. itkwidgets can be combined with other ipywidgets to quickly explore algorithm parameters, create graphical interfaces, or create data visualization dashboards.

Mouse Controls

Left click + drag

Rotate

Right click + drag or shift + left click + drag

Pan

Mouse wheel or control + left click + drag or pinch

Zoom

Alt + left click + drag left-right

Change color transfer function window

Shift + left click + drag top-bottom

Change color transfer function level

Shift + alt + left click + drag top-bottom

Change primary Gaussian volume opacity transfer function magnitude

Keyboard Shortcuts

Keyboard shortcuts take effect when the mouse is positioned inside the viewer. All shortcuts are prefixed with Alt+. Corresponding keys for the Dvorak keyboard layout have the same effect.

Alt + 1

X-plane mode

Alt + 2

Y-plane mode

Alt + 3

Z-plane mode

Alt + 4

Volume rendering mode

Alt + q

Toggle user interface

Alt + w

Toggle region of interest (ROI) selection widget

Alt + e

Reset ROI

Alt + r

Reset camera

Alt + s

Toggle slicing planes in volume rendering mode

Alt + f

Toggle fullscreen

Examples

After installation, try the following examples that demonstrate how to visualize:

or how to:

Troubleshooting

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=1e12

Hacking

Participation is welcome! For a development installation (requires Node.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

The above commands will setup your system for development with the Jupyter Notebook. To develop for Jupyter Lab, additionally run:

jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install ./js

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itkwidgets-0.21.1.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

itkwidgets-0.21.1-py2.py3-none-any.whl (3.4 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file itkwidgets-0.21.1.tar.gz.

File metadata

  • Download URL: itkwidgets-0.21.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8

File hashes

Hashes for itkwidgets-0.21.1.tar.gz
Algorithm Hash digest
SHA256 3d781e2a4d500038363e3872c8b2857e49328f006da21be665725bce08960db1
MD5 25e0aa6a76ebe9d69e526ccc2e8d062c
BLAKE2b-256 045bf539f02503d0c98b4d46bc63db886d26b324b6e33eb7c3a861eebcf00861

See more details on using hashes here.

File details

Details for the file itkwidgets-0.21.1-py2.py3-none-any.whl.

File metadata

  • Download URL: itkwidgets-0.21.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8

File hashes

Hashes for itkwidgets-0.21.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d1d24c004b52266547f5bf6484a2086bca9dc724a496e09e517ff4cb270ba523
MD5 5fdcb45b517e23689406411b91f6838f
BLAKE2b-256 02eaedf678be247d4222534bfe69eb150b52776b5ed0e5612b70f2bb6a74ffcb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page