Recently, the Insight Toolkit (ITK) was made available in binary Python packages. While these packages make the core high-performance, multi-dimensional image analysis capabilities more accessible in Python, the brilliant researchers in the broader ITK community have additional advanced algorithms to contribute. They can now distribute extensions to the toolkit as Python packages from ITK Modules! This post describes how to generate Windows, macOS, and Linux Python packages from ITK External Modules. For more information, see the official documentation.

First, create ITK module scaffolding if it does not exist.

python -m pip install cookiecutter
python -m cookiecutter gh:InsightSoftwareConsortium/ITKModuleTemplate
# Fill in the information requested at the prompt

Then, add your classes and wrapping configuration. Reference documentation on how to populate the module can be found in the ITK Software Guide.

After enabling builds for the GitHub repository with a CircleCI, TravisCI, and AppVeyor account, Python wheel packages will be available for Windows, macOS, and Linux with the continuous integration builds.

When ready to distribute a new release, upload the packages to the Python Package Index (PyPI). Essentially, register for an account on, then upload the packages downloaded from the GitHub CI services with the commands:

python -m pip install twine
python -m twine upload dist/*

The binaries could also rebuilt or repackaged and distributed on conda-forge.

ITKTextureFeatures on PyPI.

A few example module packages are already available: itk-texturefeatures, itk-anisotropicdiffusionlbr, itk-ultrasound, itk-morphologicalcontourinterpolation, and itk-isotropicwavelets.

The itk-isotropicwavelets package can be installed with the commands:

 python -m pip install --upgrade pip
 python -m pip install itk-isotropicwavelets

Packaging questions or new module packages can be shared in the ITK Discourse forum.

Enjoy ITK!

Leave a Reply