A setup script to generate ITK Python Wheels

Overview

ITK Python Package

This project provides a setup.py script to build ITK Python binary packages and infrastructure to build ITK external module Python packages.

ITK is an open-source, cross-platform system that provides developers with an extensive suite of software tools for image analysis.

Installation

To install the ITK Python package:

    $ pip install itk

Usage

Simple example script

    import itk
    import sys

    input_filename = sys.argv[1]
    output_filename = sys.argv[2]

    image = itk.imread(input_filename)

    median = itk.median_image_filter(image, radius=2)

    itk.imwrite(median, output_filename)

See also the ITK Python Quick Start Guide. There are also many downloadable examples documented in Sphinx.

For more information on ITK's Python wrapping, an introduction is provided in the ITK Software Guide.

Comments
  • Add support for shared libraries dependencies in remote modules

    Add support for shared libraries dependencies in remote modules

    We want to package the OpenCL ICD loader in particular in dependent remote modules.

    We can build on the shared library support in 5.3rc1 for TBB.

    For the platform-specific wheel fix-up tools, auditwheel (Linux), delocate (macOS), delvewheel (Windows) we need to add support for additional shared libraries. Mostly, this should be making the scripts that expose the path to local libraries with environmental variables allow appending to that variable, then set this variable to the path to the OpenCL ICD loader library in the remote module GitHub CI configuration.

    E.g.:

    https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/ad3f8d0c3dcb0e1b959924b4ceea8e832d612758/scripts/internal/manylinux-build-module-wheels.sh#L14

    ->

    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/work/oneTBB-prefix/lib64
    

    For Windows:

    https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/ad3f8d0c3dcb0e1b959924b4ceea8e832d612758/scripts/windows_build_wheels.py#L225-L228

    We may need to change this script to enable passing addition paths as a CLI argument. Also, we will likely need to adjust the strategy since delvewheel patches itk/__init__.py.

    For macOS:

    https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/ad3f8d0c3dcb0e1b959924b4ceea8e832d612758/scripts/macpython-build-module-wheels.sh#L29

    opened by thewtex 17
  • Source path directory too long

    Source path directory too long

    When attempting to install via the pip: pip install itk

    I receive the following error:

    ITK source code directory path length is too long (${n} > 50).
    Please move the ITK source code directory to a directory with a shorter path.
    

    According to this article (https://public.kitware.com/pipermail/community/2013-December/004475.html), the check is due to Visual Studio and truncation of commands.

    Is there a way to specify the build and install directory? In addition, the build files in skbuild are fairly long as it is so I could only place the ITKPythonPackage directory in my D: drive for it to work.

    If there is not a way to specify the build and install directory, I propose this option be added and documentation be added to the front page.

    opened by addisonElliott 14
  • COMP: Ensure tbb library is built with the expected deployment target

    COMP: Ensure tbb library is built with the expected deployment target

    This commit is a follow-up of these commits:

    • a5f774ba5 (ENH: Add TBB support to Linux wheels)
    • 374c744a1 (ENH: Add macOS wheel TBB support)
    • 037a326c1 (ENH: Build macOS module wheels with TBB support)

    It ensures that oneTBB is built specifying the non-default options expected by oneTBB ^1 and it should ensure the library can be loaded on macOS >= 10.9.

    See https://discourse.itk.org/t/itk-5-3rc4-post3-failure-to-load-libtbb-library-observed-on-macos-10-13/5405/1#suggested-path-forward-3

    opened by jcfr 13
  • delocate is failing on Python files

    delocate is failing on Python files

    Interestingly, delocate-listdeps has recently started to fail when building module packages:

    +/Users/Kitware/Dashboards/ITK/ITKPythonPackage/scripts/../venvs/2.7/bin/delocate-listdeps /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp34-cp34m-macosx_10_6_x86_64.whl /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp35-cp35m-macosx_10_6_x86_64.whl /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp36-cp36m-macosx_10_6_x86_64.whl
    /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl:
    Traceback (most recent call last):
      File "/Users/Kitware/Dashboards/ITK/ITKPythonPackage/scripts/../venvs/2.7/bin/delocate-listdeps", line 61, in <module>
        main()
      File "/Users/Kitware/Dashboards/ITK/ITKPythonPackage/scripts/../venvs/2.7/bin/delocate-listdeps", line 44, in main
        lib_dict = wheel_libs(path)
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/libsana.py", line 161, in wheel_libs
        lib_dict = tree_libs(tmpdir, filt_func)
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/libsana.py", line 54, in tree_libs
        for install_name in get_install_names(depending_libpath):
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/tools.py", line 173, in get_install_names
        if not _line0_says_object(lines[0], filename):
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/tools.py", line 143, in _line0_says_object
        raise InstallNameError('Unexpected first line: ' + line0)
    delocate.tools.InstallNameError: Unexpected first line: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: '/private/var/folders/bb/n7t3rs157850byt_jfdcq9k80000gn/T/tmp_NF5m6/itk/itkFourierStripeArtifactImageFilterPython.py': The file was not recognized as a valid object file
    

    CC: @jcfr @matthew-brett

    opened by thewtex 10
  • Add support for multiple manylinux versions

    Add support for multiple manylinux versions

    Motivation for this change is to build wheels with C++ ABI compatible with Slicer built using newer g++ having _GLIBCXX_USE_CXX11_ABI defaulting to 1.

    See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

    Note that the latest Slicer release (5.0) is built using centos7 based ^1 environment having _GLIBCXX_USE_CXX11_ABI set to 0.

    We should likely build wheels using both manylinux2014 and manylinux_2_28.

    As of 2022.06.22, this pull-request uses 2_24, as commented ^2 by @henryiii, I will instead update dockcross ^3 to add 2_28 based image (instead of 2_24).

    References:

    • https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
    • https://discuss.python.org/t/how-to-set-glibcxx-use-cxx11-abi-for-manylinux2014-and-manylinux2010-wheels/10551
    • https://github.com/pytorch/pytorch/issues/51039
    • https://github.com/pypa/manylinux/issues/1012
    • https://github.com/dockcross/dockcross/pull/705
    opened by jcfr 9
  • itkHelpers.py missing in itk python 5.2.0

    itkHelpers.py missing in itk python 5.2.0

    Unable to find itkHelpers.py in the installation and got python error: ModuleNotFoundError: No module named 'itkHelpers'

    itk python 5.2.0 installed via pip install itk

    opened by yliu7366 8
  • import _ITKPyBasePython failed

    import _ITKPyBasePython failed

    my Env: win10 64 bits python 3.6 itk 5.1.0

    my err: File "C:\Users\haoch\AppData\Local\Programs\Python\Python36\lib\site-packages\itk\Configuration..\ITKPyBasePython.py", line 15, in import _ITKPyBasePython ImportError: DLL load failed:

    when I use itk.imread(path),then the error occured what can I do?

    opened by xiaoxifei1223 8
  • Latest manylinux images missing `sudo`

    Latest manylinux images missing `sudo`

    Summary

    Local and CI tests in relation to https://github.com/InsightSoftwareConsortium/ITKPythonPackage/pull/233 fail to build on Linux. The issue appears to originate from the dockcross manylinux image.

    Observed behavior

    Building wheels for x64 using manylinux_2_28
    ++ type ninja
    ++ MANYLINUX_VERSION=_2_28
    ++ echo 'Building wheels for x64 using manylinux_2_28'
    + sudo ldconfig
    /opt/rh/gcc-toolset-12/root/usr/bin/sudo: line 41: /usr/bin/sudo: No such file or directory
    Error: Process completed with exit code 127.
    

    See log: https://github.com/InsightSoftwareConsortium/ITKSplitComponents/actions/runs/3583756532/jobs/6029570633

    Expected behavior

    Build succeeds.

    Steps to Reproduce

    > MANYLINUX_VERSION=_2_28
    > IMAGE_TAG=20221128-2024e4b
    
    # Generate dockcross scripts
    > docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
    > chmod u+x /tmp/dockcross-manylinux-x64
    
    # Launch container
    > /tmp/dockcross-manylinux-x64 bash
    
    # Try to run any command with sudo
    >> sudo ldconfig
    /opt/rh/gcc-toolset-12/root/usr/bin/sudo: line 41: /usr/bin/sudo: No such file or directory
    
    # Try to find sudo in /usr/bin
    >> ls /usr/bin | grep sudo
    # no results
    

    Other Notes

    Possibly related to the most recent image tag update: https://github.com/InsightSoftwareConsortium/ITKPythonPackage/pull/230

    Investigation shows that sudo works in the previous dockcross image:

    > IMAGE_TAG=20221108-102ebcc
    > docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
    > chmod u+x /tmp/dockcross-manylinux-x64
    > /tmp/dockcross-manylinux-x64 bash
    >> sudo ldconfig
    >> sudo echo "sudo works"
    sudo works
    
    opened by tbirdso 6
  • ENH: Add build script update step to download script

    ENH: Add build script update step to download script

    Several related updates:

    • Adds update step to apply build script patches to ITKPythonBuilds packages
    • Exposes manylinux parameters and resolves issue where wrong image was used with specialized tarballs
    • Reverts manylinux image tag while awaiting fix for sudo issue tracked in https://github.com/InsightSoftwareConsortium/ITKPythonPackage/issues/235 and https://github.com/dockcross/dockcross/issues/746

    These changes are tested at https://github.com/InsightSoftwareConsortium/ITKSplitComponents/actions/runs/3586129456

    opened by tbirdso 6
  • CMake version ignored

    CMake version ignored

    Despite explicitly getting CMake 3.24 in the CI, an older version is used during some stage resulting in insufficient version error:

    -- Configuring done
    -- Generating done
    -- Build files have been written to: /work/_cmake_test_compile/build
    CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
      CMake 3.24 or higher is required.  You are running version 3.23.1
    
    
    -- Configuring incomplete, errors occurred!
      File "/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 544, in setup
        env = cmkr.configure(cmake_args,
      File "/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/cmaker.py", line 221, in configure
        raise SKBuildError(
    An error occurred while configuring with CMake.
      Command:
    
        "cmake" "/work" "-G" "Ninja" "-DCMAKE_INSTALL_PREFIX:PATH=/work/_skbuild/linux-x86_64-3.8/cmake-install" "-DPYTHON_EXECUTABLE:FILEPATH=/opt/python/cp38-cp38/bin/python" "-DPYTHON_VERSION_STRING:STRING=3.8.13" "-DPYTHON_INCLUDE_DIR:PATH=/opt/_internal/cpython-3.8.13/include/python3.8" "-DPYTHON_LIBRARY:FILEPATH=libpython3.8.a" "-DSKBUILD:BOOL=TRUE" "-DCMAKE_MODULE_PATH:PATH=/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/resources/cmake" "-DITK_DIR:PATH=/work/ITK-cp38-cp38-manylinux_2_28_x64" "-DITK_USE_SYSTEM_SWIG:BOOL=ON" "-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel" "-DSWIG_EXECUTABLE:FILEPATH=/work/ITK-cp38-cp38-manylinux_2_28_x64/Wrapping/Generators/SwigInterface/swig/bin/swig" "-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-linux-gnu" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DBUILD_TESTING:BOOL=OFF" "-DPython3_EXECUTABLE:FILEPATH=/opt/python/cp38-cp38/bin/python" "-DPython3_INCLUDE_DIR:PATH=/opt/python/cp38-cp38/bin/../include/python3.8" "-DCMAKE_BUILD_TYPE:STRING=Release"
    

    This might be a problem in https://github.com/python-cmake-buildsystem/python-cmake-buildsystem.

    opened by dzenanz 6
  • TimeVaryingDiffeomorphisms in ITKPythonPackage

    TimeVaryingDiffeomorphisms in ITKPythonPackage

    Hello I wanted to know if the itkpythonpackage provides bindings for the deformable registration components of itk. So far i havent found this using google search.

    Thansk

    opened by cakeinspace 6
  • COMP: Consolidate Linux ARM build script

    COMP: Consolidate Linux ARM build script

    Several quality-of-life fixes and updates for ARM support:

    • Consolidates ARM module script with x86_64 module script for easier maintenance and comparison between procedures. Internal ARM script is preserved as a wrapper around generic internal build script.
    • Splits MANYLINUX_VERSION variable into MANYLINUX_VERSION prefix and TARGET_ARCH postfix to better reflect available images.
    • Uses sudo to avoid permissions failure when running docker or cleaning up files on ARM systems

    Applies changes introduced by @thewtex in https://github.com/InsightSoftwareConsortium/ITKPythonPackage/pull/234.

    Tests have passed at https://github.com/InsightSoftwareConsortium/ITKSplitComponents/actions/runs/3736106376/jobs/6340059855. Note that ARM builds on Github Actions runners are significantly slower than x86/x64 builds due to emulation. ITKSplitComponents Linux jobs previously completed in ~10 minutes and now complete in ~30 minutes with the addition of ARM wheels.

    co-authored-by: Matt McCormick [email protected]

    opened by tbirdso 9
  • fail to build release 5.2rc03 on ArchLinux

    fail to build release 5.2rc03 on ArchLinux

    Error log:

    CMake Error at Wrapping/CMakeUtilityFunctions.cmake:40 (math):
      math cannot parse the expression: ")
    
      set(ITK_WRAP_VECTOR_COMPONENTS + 1": syntax error, unexpected
      exp_CLOSEPARENT (1).
    Call Stack (most recent call first):
      Wrapping/WrapBasicTypes.cmake:55 (INCREMENT)
      Wrapping/ConfigureWrapping.cmake:131 (include)
      Wrapping/CMakeLists.txt:97 (include)
    
    
    CMake Warning (dev) at Wrapping/CMakeUtilityFunctions.cmake:40 (math):
      Unexpected character in expression at position 1: "
    
    Call Stack (most recent call first):
      Wrapping/WrapBasicTypes.cmake:63 (INCREMENT)
      Wrapping/ConfigureWrapping.cmake:131 (include)
      Wrapping/CMakeLists.txt:97 (include)
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    CMake Error at Wrapping/WrapBasicTypes.cmake:73 (message):
      ITK_WRAP_VECTOR_COMPONENTS must include ITK_WRAP_IMAGE_DIMS
    Call Stack (most recent call first):
      Wrapping/ConfigureWrapping.cmake:131 (include)
      Wrapping/CMakeLists.txt:97 (include)
    

    See the complete build log here

    opened by hubutui 20
Releases(v5.3.0)
Owner
Insight Software Consortium
Community development of the Insight Toolkit (ITK)
Insight Software Consortium
Implementation of 'lightweight' GAN, proposed in ICLR 2021, in Pytorch. High resolution image generations that can be trained within a day or two

512x512 flowers after 12 hours of training, 1 gpu 256x256 flowers after 12 hours of training, 1 gpu Pizza 'Lightweight' GAN Implementation of 'lightwe

Phil Wang 1.5k Jan 02, 2023
Code for the paper: Adversarial Training Against Location-Optimized Adversarial Patches. ECCV-W 2020.

Adversarial Training Against Location-Optimized Adversarial Patches arXiv | Paper | Code | Video | Slides Code for the paper: Sukrut Rao, David Stutz,

Sukrut Rao 32 Dec 13, 2022
RL agent to play μRTS with Stable-Baselines3

Gym-μRTS with Stable-Baselines3/PyTorch This repo contains an attempt to reproduce Gridnet PPO with invalid action masking algorithm to play μRTS usin

Oleksii Kachaiev 24 Nov 11, 2022
Implementation of "Generalizable Neural Performer: Learning Robust Radiance Fields for Human Novel View Synthesis"

Generalizable Neural Performer: Learning Robust Radiance Fields for Human Novel View Synthesis Abstract: This work targets at using a general deep lea

163 Dec 14, 2022
A benchmark dataset for mesh multi-label-classification based on cube engravings introduced in MeshCNN

Double Cube Engravings This script creates a dataset for multi-label mesh clasification, with an intentionally difficult setup for point cloud classif

Yotam Erel 1 Nov 30, 2021
Nested cross-validation is necessary to avoid biased model performance in embedded feature selection in high-dimensional data with tiny sample sizes

Pruner for nested cross-validation - Sphinx-Doc Nested cross-validation is necessary to avoid biased model performance in embedded feature selection i

1 Dec 15, 2021
A PyTorch implementation of EfficientDet.

A PyTorch impl of EfficientDet faithful to the original Google impl w/ ported weights

Ross Wightman 1.4k Jan 07, 2023
Python code for loading the Aschaffenburg Pose Dataset.

Aschaffenburg Pose Dataset (APD) This repository contains Python code for loading and filtering the Aschaffenburg Pose Dataset. The dataset itself and

1 Nov 26, 2021
Code release for NeuS

NeuS We present a novel neural surface reconstruction method, called NeuS, for reconstructing objects and scenes with high fidelity from 2D image inpu

Peng Wang 813 Jan 04, 2023
RLHive: a framework designed to facilitate research in reinforcement learning.

RLHive is a framework designed to facilitate research in reinforcement learning. It provides the components necessary to run a full RL experiment, for both single agent and multi agent environments.

88 Jan 05, 2023
UniMoCo: Unsupervised, Semi-Supervised and Full-Supervised Visual Representation Learning

UniMoCo: Unsupervised, Semi-Supervised and Full-Supervised Visual Representation Learning This is the official PyTorch implementation for UniMoCo pape

dddzg 49 Jan 02, 2023
First-Order Probabilistic Programming Language

FOPPL: A First-Order Probabilistic Programming Language This is an implementation of FOPPL, an S-expression based probabilistic programming language d

Renato Costa 23 Dec 20, 2022
Artificial Neural network regression model to predict the energy output in a combined cycle power plant.

Energy_Output_Predictor Artificial Neural network regression model to predict the energy output in a combined cycle power plant. Abstract Energy outpu

1 Feb 11, 2022
Learning Logic Rules for Document-Level Relation Extraction

LogiRE Learning Logic Rules for Document-Level Relation Extraction We propose to introduce logic rules to tackle the challenges of doc-level RE. Equip

41 Dec 26, 2022
A Re-implementation of the paper "A Deep Learning Framework for Character Motion Synthesis and Editing"

What is This This is a simple re-implementation of the paper "A Deep Learning Framework for Character Motion Synthesis and Editing"(1). Only Sections

102 Dec 14, 2022
Breast Cancer Classification Model is applied on a different dataset

Breast Cancer Classification Model is applied on a different dataset

1 Feb 04, 2022
This is the official PyTorch implementation of our paper: "Artistic Style Transfer with Internal-external Learning and Contrastive Learning".

Artistic Style Transfer with Internal-external Learning and Contrastive Learning This is the official PyTorch implementation of our paper: "Artistic S

51 Dec 20, 2022
Genetic Programming in Python, with a scikit-learn inspired API

Welcome to gplearn! gplearn implements Genetic Programming in Python, with a scikit-learn inspired and compatible API. While Genetic Programming (GP)

Trevor Stephens 1.3k Jan 03, 2023
This is an official pytorch implementation of Lite-HRNet: A Lightweight High-Resolution Network.

Lite-HRNet: A Lightweight High-Resolution Network Introduction This is an official pytorch implementation of Lite-HRNet: A Lightweight High-Resolution

HRNet 675 Dec 25, 2022
Code for the ICASSP-2021 paper: Continuous Speech Separation with Conformer.

Continuous Speech Separation with Conformer Introduction We examine the use of the Conformer architecture for continuous speech separation. Conformer

Sanyuan Chen (陈三元) 81 Nov 28, 2022