Now that Slicer PR-6564 adding support for building ITK with a custom namespace has been integrated, installing SimpleITK from wheels should be possible.
Pros:
- Reduced build time by a factor x2 (and probably more on windows)
- Version of SimpleITK bundled in Slicer may be update-able using
pip
, this would allow to install a newer SimpleITK in a released Slicer distribution. - Reduced build-system complexity by removing external projects
Swig
,PCRE
andSimpleITK
and introducingpython-SimpleITK
Cons:
- Fixes integrated in ITK C++ that is used to build Slicer may not be immediately be available in the nightly build, they may only be available once new SimpleITK wheels are released.
Questions
Assuming SimpleITK wheels can be used, should we move forward with this proposal ?
Should we distribute SimpleFilters as a standalone extension and further reduce the size of the main Slicer package ?
_SimpleITK.cpython-39-x86_64-linux-gnu.so
is259M
on Linux_SimpleITK.cpython-39-darwin.so
is201M
on macOS_SimpleITK.cp39-win_amd64.pyd
is10M
on Windows
Rational for smaller library on Windows:
# SimpleITK has large internal libraries, which take an extremely long # time to link on windows when they are static. Creating shared # SimpleITK internal libraries can reduce linking time. Also the size # of the debug libraries are monstrous. Using shared libraries for # debug, reduce disc requirements, and can improve linking # times. However, these shared libraries take longer to load than the # monolithic target from static libraries.
Source: Slicer@ff8f546e4 (COMP: Adding option for SimpleITK as a shared library)
Preliminary testing
After removing ITK_AUTOLOAD_PATH
from the environment, the SimpleITK package could successfully be installed & imported on Linux (Ubuntu 20.04.4).
import os
del os.environ["ITK_AUTOLOAD_PATH"]
import SimpleITK
That said, attempting to apply a filter by leveraging the SlicerSimpleFilter
module failed with the following error:
Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:97:
sitk::ERROR: The file "slicer:0x561741d91310#vtkMRMLScalarVolumeNode1" does not exist.
This means that we should revisit how the SlicerSimpleFilter
module access volume node information by instead passing numpy array by leveraging vtk.util.numpy_support
like what is done in itk.vtk_image_from_image/itk.image_from_vtk_image or sitk2vtk.py/vtk2sitk.py