Welcome to the Insight Toolkit Distributed Registration framework! We are excited that you are here! Join us as a contributing member of the community.
There are two ways to contribute as part of the ITK and itk-dreg community:
- Contribute features or fixes to the
itk-dregproject directly; or - Create a new community extension to plug in to the
itk-dregframework.
We recommend creating a new community extension for most new features.
You will need the following to get started:
- A PC for development;
- Git version control;
- Python 3.9 or later (we recommend 3.11);
We recommend that new developers follow the ITK contributing guidelines to get started with Git development.
We recommend developing in a Python virtual environment. Refer to the following:
- If you are using Anaconda, refer to Anaconda's environments documentation.
- Otherwise, refer to Python virtual environment documentation.
We currently use flit to manage itk-dreg dependencies and installation. Open a shell prompt and activate your virtual environment, then run the following commands to install dependencies from PyPI and create a symbolic link to your local itk-dreg changes:
On Linux:
itk-dreg > cd src
itk-dreg/src > python -m pip install --upgrade pip
itk-dreg/src > flit install --symlink --extras developOn Windows:
itk-dreg > cd src
itk-dreg/src > python -m pip install --upgrade pip
itk-dreg/src > flit install --pth-file --extras developFollow the ITK development workflow to guide your local development:
- If you are contributing to
itk-dreg, fork the repository under your GitHub user account. - Clone the repository or add a new remote for your user fork.
- Navigate to the repository directory on your PC and create a new development branch with
git checkout -b <my-branch-name> - Develop locally.
- Commit changes ("make a checkpoint") with
git commit. Use standard prefixes in your commit message. - When your changes are ready, create a pull request on the
itk-dregrepository.
Proposed changes must meet two principle criteria to be eligible for merge into itk-dreg:
- The change must be reviewed and approved by an
itk-dregmaintainer. Review is subjective and includes criteria such as:
- Is the change reasonable?
- Does the change belong in
itk-dregor in a community extension module? - Is the change reasonably tested to ensure correctness?
- Does the change meet community standards?
- Does the change meet code quality standards?
- Continuous integration workflows for the changes must pass, including linting and automated testing.
Pull request integration is at the discretion of itk-dreg maintainers. The following are best practices to improve the likelihood
of a successful pull request integration:
- Communicate your work early and often. We advise opening an issue or a draft pull request early in development to solicit community discussion and guidance.
- Write and run unit tests early and often to police code correctness.
itk-dregusespytestfor automated testing:
itk-dreg > pytest # runs all tests
itk-dreg > pytest -k <your-test-name> -vvv -s # runs your test with verbose output- Use linting tools to improve code quality.
itk-dregusesruffandblackfor linting:
itk-dreg > python -m ruff check ./src
itk-dreg > python -m black ./srcRefer to developer documentation for additional development and debugging suggestions.
itk-dreg provides three major components:
- A virtual interface specifying inputs and outputs for registration and reduction methods;
- A scheduling apparatus that receives implementations of the virtual interface and connects them to create and run a distributed registration method;
- Two concrete implementations of the virtual interface:
- A registration approach based on ITKElastix that receives two subimages and outputs a forward transform; and
- A result reduction method that receives a set of registration results and outputs a
itk.DisplacementFieldTransformthat is valid over the whole input image.
Many existing approaches exist in literature for image-to-image registration. We can extend the itk-dreg framework
to swap out the itk_dreg.elastix and itk_dreg.reduce_dfield approaches (3) for alternate methods.
Each extension should be distributed in its own Python module that depends on itk-dreg. Follow these steps to set up
a new itk-dreg extension:
- Create a GitHub repository to hold the module.
- Create a Python project. We recommend
hatchorflitbuild systems for getting started. - Add a dependency on the latest version of
itk-dregto yourpyproject.toml.
You are now ready to write your extension. itk-dreg provides three registration interface for extension.
You may choose to extend any or all of these interfaces. Visit
registration_interface.py for more information in
the docstring for each interface.
-
ConstructReaderMethod: A method to generate anitk.ImageFileReaderto stream an image subregion for a given registration task. Usually the defaultitk_dregimplementation is sufficient, but can be extended in the event of domain-specific metadata parsing. For instance, the Lightsheet Registration notebook provides an extended reader to parse nonstandard lightsheet orientation metadata before registration occurs. -
BlockPairRegistrationMethod: A method to register a fixed and moving subimage together.itk-dregimplements theitk_dreg.elastixsubmodule to perform pairwise subimage registration with ITKElastix. Returns a result including at least a status code and a forward transform result. -
ReduceResultsMethod: A method to receive a collection of subimage domains with their corresponding forward transform results and return a singleitk.Transformforward transform mapping from the fixed to moving image domain.itk-dregimplements theitk_dreg.reduce_dfieldsubmodule to sample piecewise transform results into a single output deformation field.
Once you've written your class or classes you may use them with the itk-dreg registration framework directly:
import itk_dreg.register
import my_dreg_extension
... # set up methods, data
registration_schedule = itk_dreg.register.register_images(
fixed_reader_ctor=my_dreg_extension.my_construct_streaming_reader_method,
moving_reader_ctor=my_dreg_extension.my_construct_streaming_reader_method,
block_registration_method=my_dreg_extension.my_block_pair_registration_method_subclass,
reduce_method=my_dreg_extension.my_postprocess_registration_method_subclass,
fixed_chunk_size=(x,y,z),
initial_transform=my_initial_transform,
overlap_factors=[a,b,c]
)
result = registration_schedule.registration_result.compute()
... # Resample, save the result, etcWe suggest using pytest, ruff, and black for testing and linting during development. We also suggest adding
example scripts and/or Jupyter Notebooks in the examples/ repository of your project to aid in user understanding
and adoption.
itk-dreg is part of the Insight Toolkit tools ecosystem for medical image processing. We encourage developers to
reach out to the ITK community with questions on the ITK Discourse forums. Those
interested in custom or commercial development should reach out to Kitware to learn more.
Happy coding!