1- ITK Python Package
2- ==================
1+ # ITK Python Package
32
43This project provides a ` setup.py ` script to build ITK Python binary
54packages and infrastructure to build ITK external module Python
65packages.
76
8- ITK is an open-source, cross-platform system that provides developers
7+ The Insight Toolkit ( ITK) is an open-source, cross-platform system that provides developers
98with an extensive suite of software tools for image analysis.
9+ More information is available on the [ ITK website] ( https://itk.org/ )
10+ or at the [ ITK GitHub homepage] ( https://github.com/insightSoftwareConsortium/ITK ) .
1011
11- Installation
12- ------------
12+ ## Using ITK Python Packages
1313
14- To install the ITK Python package:
14+ ITKPythonPackage scripts can be used to produce [ Python] ( https://www.python.org/ ) packages
15+ for ITK and ITK external modules. The resulting packages can be
16+ hosted on the [ Python Package Index (PyPI)] ( https://pypi.org/ )
17+ for easy distribution.
18+
19+ ### Installation
20+
21+ To install baseline ITK Python packages:
1522
1623``` sh
17- pip install itk
24+ > pip install itk
1825```
1926
20- Usage
21- -----
27+ To install ITK external module packages:
2228
23- ### Simple example script
29+ ``` sh
30+ > pip install itk-< module_name>
31+ ```
32+
33+ ### Using ITK in Python scripts
2434
2535``` python
2636 import itk
@@ -36,15 +46,97 @@ Usage
3646 itk.imwrite(median, output_filename)
3747```
3848
49+ ### Other Resources for Using ITK in Python
50+
3951See also the [ ITK Python Quick Start
4052Guide] ( https://itkpythonpackage.readthedocs.io/en/master/Quick_start_guide.html ) .
41- There are also many [ downloadable examples documented in
42- Sphinx] ( https://itk.org/ITKExamples/search.html?q=Python ) .
53+ There are also many [ downloadable examples on the ITK examples website] ( https://examples.itk.org/search.html?q=Python ) .
4354
4455For more information on ITK's Python wrapping, [ an introduction is
4556provided in the ITK Software
4657Guide] ( https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch3.html#x32-420003.7 ) .
4758
59+ ## Building with ITKPythonPackage
60+
61+ ITK reusable workflows are available to build and package Python wheels as
62+ part of Continuous Integration (CI) via Github Actions runners.
63+ Those workflows can handle the overhead of fetching, configuring, and
64+ running ITKPythonPackage build scripts for most ITK external modules.
65+ See [ ITKRemoteModuleBuildTestPackageAction] ( https://github.com/InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction )
66+ for more information.
67+
68+ For special cases where ITK reusable workflows are not a good fit,
69+ ITKPythonPackage scripts can be directly used to build Python wheels
70+ to target Windows, Linux, and MacOS platforms. See
71+ [ ITKPythonPackage ReadTheDocs] ( https://itkpythonpackage.readthedocs.io/en/master/Build_ITK_Module_Python_packages.html )
72+ documentation for more information on building wheels by hand.
73+
74+ ## Frequently Asked Questions
75+
76+ ### What target platforms and architectures are supported?
77+
78+ ITKPythonPackage currently supports building wheels for the following platforms and architectures:
79+ - Windows 10 x86_64 platforms
80+ - Windows 11 x86_64 platforms
81+ - MacOS 10.9+ x86_64 platforms
82+ - MacOS 11.0+ arm64 platforms
83+ - Linux glibc 2.17+ (E.g. Ubuntu 18.04+) x86_64 platforms
84+ - _ Coming Soon: Linux ARM platforms_
85+
86+ ### What should I do if my target platform/architecture does not appear on the list above?
87+
88+ Please open an issue in the [ ITKPythonPackage issue tracker] ( https://github.com/InsightSoftwareConsortium/ITKPythonPackage/issues )
89+ for discussion, and consider contributing either time or funding to support
90+ development. The ITK open source ecosystem is driven through contributions from its community members.
91+
92+ ### What is an ITK external module?
93+
94+ The Insight Toolkit consists of several baseline module groups for image analysis
95+ including filtering, I/O, registration, segmentation, and more. Community members
96+ can extend ITK by developing an ITK "external" module which stands alone in a separate
97+ repository and its independently built and tested. An ITK external module which
98+ meets community standards for documentation and maintenance may be included in the
99+ ITK build process as an ITK "remote" module to make it easier to retrieve and build.
100+
101+ Visit [ ITKModuleTemplate] ( https://github.com/insightSoftwareConsortium/ITKmoduletemplate )
102+ to get started creating a new ITK external module.
103+
104+ ### How can I make my ITK C++ filters available in Python?
105+
106+ ITK uses SWIG to wrap C++ filters for use in Python.
107+ See [ Chapter 9 in the ITK Software Guide] ( https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch9.html )
108+ or visit [ ITKModuleTemplate] ( https://github.com/insightSoftwareConsortium/ITKmoduletemplate )
109+ to get started on writing ` .wrap ` files.
110+
111+ After you've added wrappings for your external module C++ filters
112+ you may build and distribute Python packages automatically with
113+ [ ITKRemoteModuleBuildTestPackageAction] ( https://github.com/InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction )
114+ or manually with ITKPythonPackage scripts.
115+
116+ ### What makes building ITK external module wheels different from building ITK wheels?
117+
118+ In order to build an ITK external module you must have first built ITK for the same target platform.
119+ However, building ITK modules and wrapping them for Python can take a very long time!
120+ To avoid having to rebuilt ITK before building every individual external module,
121+ artifacts from the ITK build process (headers, source files, wrapper outputs, and more) are
122+ packaged and cached as [ ITKPythonBuilds] ( https://github.com/insightSoftwareConsortium/ITKpythonbuilds )
123+ releases.
124+
125+ In order to build Python wheels for an ITK external module, ITKPythonPackage scripts
126+ first fetch the appropriate ITK Python build artifacts along with other necessary
127+ tools. Then, the module can be built, packaged, and distributed on [ PyPI] ( https://pypi.org/ ) .
128+
129+ ### My external module has a complicated build process. Is it supported by ITKPythonPackage?
130+
131+ Start by consulting the [ ITKPythonPackage ReadTheDocs] ( https://itkpythonpackage.readthedocs.io/en/master/Build_ITK_Module_Python_packages.html )
132+ documentation and the [ ITKPythonPackage issue tracker] ( https://github.com/InsightSoftwareConsortium/ITKPythonPackage/issues )
133+ for discussion related to your specific issue.
134+
135+ If you aren't able to find an answer for your specific case, please start a discussion the
136+ [ ITK Discourse forum] ( https://discourse.itk.org/ ) for help.
137+
138+ ## Additional Information
139+
48140- Free software: Apache Software license
49141- Documentation: < http://itkpythonpackage.readthedocs.org >
50142- Source code: < https://github.com/InsightSoftwareConsortium/ITKPythonPackage >
0 commit comments