itkwidgets
Interactive Jupyter widgets to visualize images, point sets, and meshes.
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
SimpleITK.Image
NumPy array point sets
itk.PointSet
vtk.vtkPolyData point sets
pyvista.PolyData point sets
itk.Mesh
itk.PolyLineParametricPath
vtk.vtkPolyData
vtk.vtkStructuredGrid
vtk.vtkUnstructuredGrid
vtk.vtkActor
vtk.vtkVolume
vtk.vtkAssembly
pyvista.PolyData
pyvista.StructuredGrid
pyvista.UnstructuredGrid
vtkplotter.Actor
vtkplotter.Assembly
skan.csr.Skeleton
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
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 jupyter-matplotlib jupyterlab-datawidgets 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:
ImageJ ImgLib2 images (requires conda and a local Fiji installation)
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. In one terminal, start Jupyter:
cd itkwidgets jupyter notebook
In another terminal, put Webpack in watch mode to rebuild any Javascript changes when you save a Javascript file:
cd itkwidgets npm run watch
If 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 --watch
Metadata
Release files for itkwidgets 0.25.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| itkwidgets-0.25.0.tar.gz | 1.8 MB | Without provenance | Details for itkwidgets-0.25.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| itkwidgets-0.25.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for itkwidgets-0.25.0-py2.py3-none-any.whl |
Total release size: 5.3 MB
Release files / itkwidgets-0.25.0.tar.gz
| Download URL | itkwidgets-0.25.0.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3469c626c1262e8f173d52475bf2717c80f571d1b85565f3a1f92698bd86c718
|
|
BLAKE2b-256 checksum How to use checksums |
446cb7e99271f08609e07a2bd39ac093fce57f9baddba3bb54bc1762a6294ead
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0.post20200113 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.6
|
Release files / itkwidgets-0.25.0-py2.py3-none-any.whl
| Download URL | itkwidgets-0.25.0-py2.py3-none-any.whl |
|---|---|
| Size | 3.6 MB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e3a3941dd1d5ffe5af75949866ff7ce42ace1a8536eee40017c880eecc71fbef
|
|
BLAKE2b-256 checksum How to use checksums |
caf3b7e827fe1fa622e4bb10a9a35d0a06b964311d98c9b5aeb3cd426c673c3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0.post20200113 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.6
|
Security for itkwidgets 0.25.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.