voxelmorph 0.2__tar.gz → 0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. voxelmorph-0.3/PKG-INFO +245 -0
  2. {voxelmorph-0.2 → voxelmorph-0.3}/README.md +74 -19
  3. voxelmorph-0.3/pyproject.toml +42 -0
  4. {voxelmorph-0.2 → voxelmorph-0.3}/setup.py +3 -10
  5. voxelmorph-0.3/tests/test_functional.py +1402 -0
  6. voxelmorph-0.3/tests/test_imports.py +1 -0
  7. voxelmorph-0.3/tests/test_models.py +245 -0
  8. voxelmorph-0.3/tests/test_modules.py +444 -0
  9. voxelmorph-0.3/tests/test_neurite_integration.py +180 -0
  10. voxelmorph-0.3/voxelmorph/__init__.py +53 -0
  11. voxelmorph-0.3/voxelmorph/functional.py +1296 -0
  12. voxelmorph-0.3/voxelmorph/nn/__init__.py +29 -0
  13. voxelmorph-0.3/voxelmorph/nn/functional.py +826 -0
  14. voxelmorph-0.3/voxelmorph/nn/losses.py +80 -0
  15. voxelmorph-0.3/voxelmorph/nn/models.py +280 -0
  16. voxelmorph-0.3/voxelmorph/nn/modules.py +287 -0
  17. voxelmorph-0.3/voxelmorph/py/__init__.py +15 -0
  18. {voxelmorph-0.2/voxelmorph → voxelmorph-0.3/voxelmorph/py}/generators.py +54 -39
  19. {voxelmorph-0.2 → voxelmorph-0.3}/voxelmorph/py/utils.py +48 -21
  20. voxelmorph-0.3/voxelmorph.egg-info/PKG-INFO +245 -0
  21. voxelmorph-0.3/voxelmorph.egg-info/SOURCES.txt +24 -0
  22. {voxelmorph-0.2 → voxelmorph-0.3}/voxelmorph.egg-info/requires.txt +3 -2
  23. voxelmorph-0.2/PKG-INFO +0 -17
  24. voxelmorph-0.2/voxelmorph/__init__.py +0 -59
  25. voxelmorph-0.2/voxelmorph/py/__init__.py +0 -1
  26. voxelmorph-0.2/voxelmorph/tf/__init__.py +0 -4
  27. voxelmorph-0.2/voxelmorph/tf/layers.py +0 -539
  28. voxelmorph-0.2/voxelmorph/tf/losses.py +0 -359
  29. voxelmorph-0.2/voxelmorph/tf/networks.py +0 -1242
  30. voxelmorph-0.2/voxelmorph/tf/utils/__init__.py +0 -1
  31. voxelmorph-0.2/voxelmorph/tf/utils/utils.py +0 -800
  32. voxelmorph-0.2/voxelmorph/torch/__init__.py +0 -4
  33. voxelmorph-0.2/voxelmorph/torch/layers.py +0 -97
  34. voxelmorph-0.2/voxelmorph/torch/losses.py +0 -117
  35. voxelmorph-0.2/voxelmorph/torch/modelio.py +0 -77
  36. voxelmorph-0.2/voxelmorph/torch/networks.py +0 -305
  37. voxelmorph-0.2/voxelmorph/torch/utils.py +0 -1
  38. voxelmorph-0.2/voxelmorph.egg-info/PKG-INFO +0 -17
  39. voxelmorph-0.2/voxelmorph.egg-info/SOURCES.txt +0 -24
  40. {voxelmorph-0.2 → voxelmorph-0.3}/LICENSE.md +0 -0
  41. {voxelmorph-0.2 → voxelmorph-0.3}/setup.cfg +0 -0
  42. {voxelmorph-0.2 → voxelmorph-0.3}/voxelmorph.egg-info/dependency_links.txt +0 -0
  43. {voxelmorph-0.2 → voxelmorph-0.3}/voxelmorph.egg-info/top_level.txt +0 -0
@@ -0,0 +1,245 @@
1
+ Metadata-Version: 2.4
2
+ Name: voxelmorph
3
+ Version: 0.3
4
+ Summary: Image Registration with Convolutional Networks
5
+ Home-page: https://github.com/voxelmorph/voxelmorph
6
+ Author: Adrian V. Dalca, Malte Hoffmann, Andrew Hoopes
7
+ License-Expression: Apache-2.0
8
+ Project-URL: GitHub, https://github.com/voxelmorph/voxelmorph
9
+ Project-URL: PyPI, https://pypi.org/project/voxelmorph/
10
+ Keywords: python,pytorch,medical-imaging,registration,medical-image-computing
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE.md
17
+ Requires-Dist: torch
18
+ Requires-Dist: scikit-image
19
+ Requires-Dist: packaging
20
+ Requires-Dist: numpy
21
+ Requires-Dist: scipy
22
+ Requires-Dist: nibabel
23
+ Requires-Dist: h5py
24
+ Requires-Dist: neurite>=0.2
25
+ Dynamic: home-page
26
+ Dynamic: license-file
27
+ Dynamic: requires-python
28
+
29
+ # VoxelMorph: learning-based image registration
30
+
31
+ **VoxelMorph** is a general purpose library for learning-based tools for alignment/registration, and more generally modelling with deformations.
32
+
33
+ > ⚠️ **Warning**: VoxelMorph pytorch is under active development. Interfaces may change.
34
+
35
+ > **For users who want to use the stable TensorFlow version**, pull or clone the [`dev-tensorflow`](https://github.com/voxelmorph/voxelmorph/tree/dev-tensorflow) branch.
36
+
37
+ ## Install
38
+
39
+ Install the published package from PyPI:
40
+
41
+ ```
42
+ pip install voxelmorph
43
+ ```
44
+
45
+ To work from a source checkout, clone this repository and install the requirements listed in `setup.py`.
46
+
47
+ ### Pre-commit hooks
48
+
49
+ This repo uses `pre-commit` to run `pycodestyle` before commits.
50
+
51
+ Install once after cloning:
52
+
53
+ ```bash
54
+ pip install pre-commit
55
+ pre-commit install
56
+ ```
57
+
58
+ You can also run the check manually:
59
+
60
+ ```bash
61
+ pre-commit run pycodestyle --all-files
62
+ ```
63
+
64
+ # Tutorial
65
+
66
+ We have several VoxelMorph tutorials:
67
+ - the main [VoxelMorph tutorial](http://tutorial.voxelmorph.net/) explains VoxelMorph and learning-based registration
68
+ - a [deformable SynthMorph demo](https://colab.research.google.com/drive/1zaDnAJGUokS0knqWttuTgrRJMb6zxukI?usp=sharing) showing how to train a registration model without data
69
+ - an [affine SynthMorph demo](https://colab.research.google.com/drive/1QClknfaZIYklBjmBy-nUn83h85bpo8r0?usp=sharing) on learning anatomy-aware and acquisition-agnostic affine registration
70
+ - a [CT-to-MRI SynthMorph demo](https://colab.research.google.com/drive/1aWbFiyQw5mtJbTglpniAOMimGo_l8BYP?usp=drive_link) clipping the Hounsfield scale for multi-modal registration
71
+ - a [SynthMorph shapes demo](https://colab.research.google.com/drive/14s2h0j_Aoncp587vmpjsQBe6PQTxyVP5) that walks through the steps of running a trained 3D shapes model
72
+ - a [tutorial on training VoxelMorph](https://colab.research.google.com/drive/1ZefmWXBupRNsnIbBbGquhVDsk-7R7L1S?usp=sharing) on [OASIS data](https://github.com/adalca/medical-datasets/blob/master/neurite-oasis.md), which we processed and released for free for HyperMorph
73
+ - an [additional small tutorial](https://colab.research.google.com/drive/1V0CutSIfmtgDJg1XIkEnGteJuw0u7qT-#scrollTo=h1KXYz-Nauwn) on warping annotations together with images
74
+ - another tutorial on [template (atlas) construction](https://colab.research.google.com/drive/1SkQbrWTQHpQFrG4J2WoBgGZC9yAzUas2?usp=sharing) with VoxelMorph
75
+ - visualize [warp](https://colab.research.google.com/drive/1F8f1imh5WfyBv-crllfeJBFY16-KHl9c?usp=sharing) as warped grid
76
+ - [inverting warps](https://colab.research.google.com/drive/1juAJRYhPPDNbO9yRtlc0VGhbIFSuhpJ2?usp=sharing) that are not diffeomorphisms
77
+
78
+
79
+ # Instructions
80
+
81
+ To use the VoxelMorph library from source, clone this repository and install the requirements listed in `setup.py`.
82
+
83
+ > **Note**: For source development, install from GitHub instead:
84
+
85
+ ```
86
+ pip install git+https://github.com/voxelmorph/voxelmorph.git
87
+ ```
88
+
89
+ ## Pre-trained models
90
+
91
+ See list of pre-trained models available [here](data/readme.md#models).
92
+
93
+ ## Training
94
+
95
+ If you would like to train your own model, you will likely need to customize some of the data-loading code in `voxelmorph/generators.py` for your own datasets and data formats. However, it is possible to run many of the example scripts out-of-the-box, assuming that you provide a list of filenames in the training dataset. Training data can be in the NIfTI, MGZ, or npz (numpy) format, and it's assumed that each npz file in your data list has a `vol` parameter, which points to the image data to be registered, and an optional `seg` variable, which points to a corresponding discrete segmentation (for semi-supervised learning). It's also assumed that the shape of all training image data is consistent, but this, of course, can be handled in a customized generator if desired.
96
+
97
+ For a given image list file `/images/list.txt` and output directory `/models/output`, the following script will train an image-to-image registration network (described in MICCAI 2018 by default) with an unsupervised loss. Model weights will be saved to a path specified by the `--model-dir` flag.
98
+
99
+ ```
100
+ ./scripts/tf/train.py --img-list /images/list.txt --model-dir /models/output --gpu 0
101
+ ```
102
+
103
+ The `--img-prefix` and `--img-suffix` flags can be used to provide a consistent prefix or suffix to each path specified in the image list. Image-to-atlas registration can be enabled by providing an atlas file, e.g. `--atlas atlas.npz`. If you'd like to train using the original dense CVPR network (no diffeomorphism), use the `--int-steps 0` flag to specify no flow integration steps. Use the `--help` flag to inspect all of the command line options that can be used to fine-tune network architecture and training.
104
+
105
+
106
+ ## Registration
107
+
108
+ If you simply want to register two images, you can use the `register.py` script with the desired model file. For example, if we have a model `model.h5` trained to register a subject (moving) to an atlas (fixed), we could run:
109
+
110
+ ```
111
+ ./scripts/tf/register.py --moving moving.nii.gz --fixed atlas.nii.gz --moved warped.nii.gz --model model.h5 --gpu 0
112
+ ```
113
+
114
+ This will save the moved image to `warped.nii.gz`. To also save the predicted deformation field, use the `--save-warp` flag. Both npz or nifty files can be used as input/output in this script.
115
+
116
+
117
+ ## Testing (measuring Dice scores)
118
+
119
+ To test the quality of a model by computing dice overlap between an atlas segmentation and warped test scan segmentations, run:
120
+
121
+ ```
122
+ ./scripts/tf/test.py --model model.h5 --atlas atlas.npz --scans scan01.npz scan02.npz scan03.npz --labels labels.npz
123
+ ```
124
+
125
+ Just like for the training data, the atlas and test npz files include `vol` and `seg` parameters and the `labels.npz` file contains a list of corresponding anatomical labels to include in the computed dice score.
126
+
127
+
128
+ ## Parameter choices
129
+
130
+
131
+ ### CVPR version
132
+
133
+ For the CC loss function, we found a reg parameter of 1 to work best. For the MSE loss function, we found 0.01 to work best.
134
+
135
+
136
+ ### MICCAI version
137
+
138
+ For our data, we found `image_sigma=0.01` and `prior_lambda=25` to work best.
139
+
140
+ In the original MICCAI code, the parameters were applied after the scaling of the velocity field. With the newest code, this has been "fixed", with different default parameters reflecting the change. We recommend running the updated code. However, if you'd like to run the very original MICCAI2018 mode, please use `xy` indexing and `use_miccai_int` network option, with MICCAI2018 parameters.
141
+
142
+
143
+ ## Spatial transforms and integration
144
+
145
+ - The spatial transform code, found at `voxelmorph.layers.SpatialTransformer`, accepts N-dimensional affine and dense transforms, including linear and nearest neighbor interpolation options. Note that original development of VoxelMorph used `xy` indexing, whereas we are now emphasizing `ij` indexing.
146
+
147
+ - For the MICCAI2018 version, we integrate the velocity field using `voxelmorph.layers.VecInt`. By default we integrate using scaling and squaring, which we found efficient.
148
+
149
+
150
+ # VoxelMorph papers
151
+
152
+ If you use VoxelMorph or some part of the code, please cite (see [bibtex](citations.bib)):
153
+
154
+ * HyperMorph, avoiding the need to tune registration hyperparameters:
155
+
156
+ **Learning the Effect of Registration Hyperparameters with HyperMorph**
157
+ Andrew Hoopes, [Malte Hoffmann](https://malte.cz), Bruce Fischl, [John Guttag](https://people.csail.mit.edu/guttag/), [Adrian V. Dalca](http://adalca.mit.edu)
158
+ MELBA: Machine Learning for Biomedical Imaging. 2022. [eprint arXiv:2203.16680](https://arxiv.org/abs/2203.16680)
159
+
160
+ **HyperMorph: Amortized Hyperparameter Learning for Image Registration.**
161
+ Andrew Hoopes, [Malte Hoffmann](https://malte.cz), Bruce Fischl, [John Guttag](https://people.csail.mit.edu/guttag/), [Adrian V. Dalca](http://adalca.mit.edu)
162
+ IPMI: Information Processing in Medical Imaging. 2021. [eprint arXiv:2101.01035](https://arxiv.org/abs/2101.01035)
163
+
164
+ * [SynthMorph](https://synthmorph.voxelmorph.net), avoiding the need to have data at training (!):
165
+
166
+ **Anatomy-aware and acquisition-agnostic joint registration with SynthMorph.**
167
+ [Malte Hoffmann](https://malte.cz), Andrew Hoopes, Douglas N. Greve, Bruce Fischl, [Adrian V. Dalca](http://adalca.mit.edu)
168
+ Imaging Neuroscience. 2024. [eprint arXiv:2301.11329](https://arxiv.org/abs/2301.11329)
169
+
170
+ **Anatomy-specific acquisition-agnostic affine registration learned from fictitious images.**
171
+ [Malte Hoffmann](https://malte.cz), Andrew Hoopes, Bruce Fischl, [Adrian V. Dalca](http://adalca.mit.edu)
172
+ SPIE Medical Imaging: Image Processing. 2023.
173
+
174
+ **SynthMorph: learning contrast-invariant registration without acquired images.**
175
+ [Malte Hoffmann](https://malte.cz), Benjamin Billot, [Juan Eugenio Iglesias](https://scholar.harvard.edu/iglesias), Bruce Fischl, [Adrian V. Dalca](http://adalca.mit.edu)
176
+ IEEE TMI: Transactions on Medical Imaging. 2022. [eprint arXiv:2004.10282](https://arxiv.org/abs/2004.10282)
177
+
178
+ * For the atlas formation model:
179
+
180
+ **Learning Conditional Deformable Templates with Convolutional Networks**
181
+ [Adrian V. Dalca](http://adalca.mit.edu), [Marianne Rakic](https://mariannerakic.github.io/), [John Guttag](https://people.csail.mit.edu/guttag/), [Mert R. Sabuncu](http://sabuncu.engineering.cornell.edu/)
182
+ NeurIPS 2019. [eprint arXiv:1908.02738](https://arxiv.org/abs/1908.02738)
183
+
184
+ * For the diffeomorphic or probabilistic model:
185
+
186
+ **Unsupervised Learning of Probabilistic Diffeomorphic Registration for Images and Surfaces**
187
+ [Adrian V. Dalca](http://adalca.mit.edu), [Guha Balakrishnan](http://people.csail.mit.edu/balakg/), [John Guttag](https://people.csail.mit.edu/guttag/), [Mert R. Sabuncu](http://sabuncu.engineering.cornell.edu/)
188
+ MedIA: Medial Image Analysis. 2019. [eprint arXiv:1903.03545](https://arxiv.org/abs/1903.03545)
189
+
190
+ **Unsupervised Learning for Fast Probabilistic Diffeomorphic Registration**
191
+ [Adrian V. Dalca](http://adalca.mit.edu), [Guha Balakrishnan](http://people.csail.mit.edu/balakg/), [John Guttag](https://people.csail.mit.edu/guttag/), [Mert R. Sabuncu](http://sabuncu.engineering.cornell.edu/)
192
+ MICCAI 2018. [eprint arXiv:1805.04605](https://arxiv.org/abs/1805.04605)
193
+
194
+ * For the original CNN model, MSE, CC, or segmentation-based losses:
195
+
196
+ **VoxelMorph: A Learning Framework for Deformable Medical Image Registration**
197
+ [Guha Balakrishnan](http://people.csail.mit.edu/balakg/), [Amy Zhao](http://people.csail.mit.edu/xamyzhao/), [Mert R. Sabuncu](http://sabuncu.engineering.cornell.edu/), [John Guttag](https://people.csail.mit.edu/guttag/), [Adrian V. Dalca](http://adalca.mit.edu)
198
+ IEEE TMI: Transactions on Medical Imaging. 2019.
199
+ [eprint arXiv:1809.05231](https://arxiv.org/abs/1809.05231)
200
+
201
+ **An Unsupervised Learning Model for Deformable Medical Image Registration**
202
+ [Guha Balakrishnan](http://people.csail.mit.edu/balakg/), [Amy Zhao](http://people.csail.mit.edu/xamyzhao/), [Mert R. Sabuncu](http://sabuncu.engineering.cornell.edu/), [John Guttag](https://people.csail.mit.edu/guttag/), [Adrian V. Dalca](http://adalca.mit.edu)
203
+ CVPR 2018. [eprint arXiv:1802.02604](https://arxiv.org/abs/1802.02604)
204
+
205
+
206
+ # Notes
207
+ - **keywords**: machine learning, convolutional neural networks, alignment, mapping, registration
208
+ - **data in papers**:
209
+ In our initial papers, we used publicly available data, but unfortunately we cannot redistribute it (due to the constraints of those datasets). We do a certain amount of pre-processing for the brain images we work with, to eliminate sources of variation and be able to compare algorithms on a level playing field. In particular, we perform FreeSurfer `recon-all` steps up to skull stripping and affine normalization to Talairach space, and crop the images via `((48, 48), (31, 33), (3, 29))`.
210
+
211
+ We encourage users to download and process their own data. See [a list of medical imaging datasets here](https://github.com/adalca/medical-datasets). Note that you likely do not need to perform all of the preprocessing steps, and indeed VoxelMorph has been used in other work with other data.
212
+
213
+
214
+ # Creation of deformable templates
215
+
216
+ To experiment with this method, please use `train_template.py` for unconditional templates and `train_cond_template.py` for conditional templates, which use the same conventions as VoxelMorph (please note that these files are less polished than the rest of the VoxelMorph library).
217
+
218
+ We've also provided an unconditional atlas in `data/generated_uncond_atlas.npz.npy`.
219
+
220
+ Models in h5 format weights are provided for [unconditional atlas here](http://people.csail.mit.edu/adalca/voxelmorph/atlas_creation_uncond_NCC_1500.h5), and [conditional atlas here](http://people.csail.mit.edu/adalca/voxelmorph/atlas_creation_cond_NCC_1022.h5).
221
+
222
+ **Explore the atlases [interactively here](http://voxelmorph.mit.edu/atlas_creation/)** with tipiX!
223
+
224
+
225
+ # SynthMorph
226
+
227
+ SynthMorph is a strategy for learning registration without acquired imaging data, producing powerful networks agnostic to contrast induced by MRI ([eprint arXiv:2004.10282](https://arxiv.org/abs/2004.10282)). For a video and a demo showcasing the steps of generating random label maps from noise distributions and using these to train a network, visit [synthmorph.voxelmorph.net](https://synthmorph.voxelmorph.net).
228
+
229
+ We provide model files for a ["shapes" variant](https://surfer.nmr.mgh.harvard.edu/ftp/data/voxelmorph/synthmorph/shapes-dice-vel-3-res-8-16-32-256f.h5) of SynthMorph, that we train using images synthesized from random shapes only, and a ["brains" variant](https://surfer.nmr.mgh.harvard.edu/ftp/data/voxelmorph/synthmorph/brains-dice-vel-0.5-res-16-256f.h5), that we train using images synthesized from brain label maps. We train the brains variant by optimizing a loss term that measures volume overlap of a [selection of brain labels](https://surfer.nmr.mgh.harvard.edu/ftp/data/voxelmorph/synthmorph/fs-labels.npy). For registration with either model, please use the `register.py` script with the respective model weights.
230
+
231
+ Accurate registration requires the input images to be min-max normalized, such that voxel intensities range from 0 to 1, and to be resampled in the affine space of a [reference image](https://surfer.nmr.mgh.harvard.edu/ftp/data/voxelmorph/synthmorph/ref.nii.gz). The affine registration can be performed with a variety of packages, and we choose FreeSurfer. First, we skull-strip the images with [SAMSEG](https://surfer.nmr.mgh.harvard.edu/fswiki/Samseg), keeping brain labels only. Second, we run [mri_robust_register](https://surfer.nmr.mgh.harvard.edu/fswiki/mri_robust_register):
232
+
233
+ ```
234
+ mri_robust_register --mov in.nii.gz --dst out.nii.gz --lta transform.lta --satit --iscale
235
+ mri_robust_register --mov in.nii.gz --dst out.nii.gz --lta transform.lta --satit --iscale --ixform transform.lta --affine
236
+ ```
237
+
238
+ where we replace `--satit --iscale` with `--cost NMI` for registration across MRI contrasts.
239
+
240
+
241
+ # Data
242
+ While we cannot release most of the data used in the VoxelMorph papers as they prohibit redistribution, we thorough processed and [re-released OASIS1](https://github.com/adalca/medical-datasets/blob/master/neurite-oasis.md) while developing [HyperMorph](http://hypermorph.voxelmorph.net/). We now include a quick [VoxelMorph tutorial](https://colab.research.google.com/drive/1ZefmWXBupRNsnIbBbGquhVDsk-7R7L1S?usp=sharing) to train VoxelMorph on neurite-oasis data.
243
+
244
+ # Contact
245
+ For any code-related problems or questions please [open an issue](https://github.com/voxelmorph/voxelmorph/issues/new?labels=voxelmorph) or [start a discussion](https://github.com/voxelmorph/voxelmorph/discussions) of general registration/VoxelMorph topics.
@@ -1,18 +1,61 @@
1
- # voxelmorph: Learning-Based Image Registration
1
+ # VoxelMorph: learning-based image registration
2
2
 
3
- **voxelmorph** is a general purpose library for learning-based tools for alignment/registration, and more generally modelling with deformations.
3
+ **VoxelMorph** is a general purpose library for learning-based tools for alignment/registration, and more generally modelling with deformations.
4
+
5
+ > ⚠️ **Warning**: VoxelMorph pytorch is under active development. Interfaces may change.
6
+
7
+ > **For users who want to use the stable TensorFlow version**, pull or clone the [`dev-tensorflow`](https://github.com/voxelmorph/voxelmorph/tree/dev-tensorflow) branch.
8
+
9
+ ## Install
10
+
11
+ Install the published package from PyPI:
12
+
13
+ ```
14
+ pip install voxelmorph
15
+ ```
16
+
17
+ To work from a source checkout, clone this repository and install the requirements listed in `setup.py`.
18
+
19
+ ### Pre-commit hooks
20
+
21
+ This repo uses `pre-commit` to run `pycodestyle` before commits.
22
+
23
+ Install once after cloning:
24
+
25
+ ```bash
26
+ pip install pre-commit
27
+ pre-commit install
28
+ ```
29
+
30
+ You can also run the check manually:
31
+
32
+ ```bash
33
+ pre-commit run pycodestyle --all-files
34
+ ```
4
35
 
5
36
  # Tutorial
6
37
 
7
- Visit the [VoxelMorph tutorial](http://tutorial.voxelmorph.net/) to learn about VoxelMorph and Learning-based Registration. Here's an [additional small tutorial](https://colab.research.google.com/drive/1V0CutSIfmtgDJg1XIkEnGteJuw0u7qT-#scrollTo=h1KXYz-Nauwn) on warping annotations together with images, and another on [template (atlas) construction](https://colab.research.google.com/drive/1SkQbrWTQHpQFrG4J2WoBgGZC9yAzUas2?usp=sharing) with VoxelMorph.
38
+ We have several VoxelMorph tutorials:
39
+ - the main [VoxelMorph tutorial](http://tutorial.voxelmorph.net/) explains VoxelMorph and learning-based registration
40
+ - a [deformable SynthMorph demo](https://colab.research.google.com/drive/1zaDnAJGUokS0knqWttuTgrRJMb6zxukI?usp=sharing) showing how to train a registration model without data
41
+ - an [affine SynthMorph demo](https://colab.research.google.com/drive/1QClknfaZIYklBjmBy-nUn83h85bpo8r0?usp=sharing) on learning anatomy-aware and acquisition-agnostic affine registration
42
+ - a [CT-to-MRI SynthMorph demo](https://colab.research.google.com/drive/1aWbFiyQw5mtJbTglpniAOMimGo_l8BYP?usp=drive_link) clipping the Hounsfield scale for multi-modal registration
43
+ - a [SynthMorph shapes demo](https://colab.research.google.com/drive/14s2h0j_Aoncp587vmpjsQBe6PQTxyVP5) that walks through the steps of running a trained 3D shapes model
44
+ - a [tutorial on training VoxelMorph](https://colab.research.google.com/drive/1ZefmWXBupRNsnIbBbGquhVDsk-7R7L1S?usp=sharing) on [OASIS data](https://github.com/adalca/medical-datasets/blob/master/neurite-oasis.md), which we processed and released for free for HyperMorph
45
+ - an [additional small tutorial](https://colab.research.google.com/drive/1V0CutSIfmtgDJg1XIkEnGteJuw0u7qT-#scrollTo=h1KXYz-Nauwn) on warping annotations together with images
46
+ - another tutorial on [template (atlas) construction](https://colab.research.google.com/drive/1SkQbrWTQHpQFrG4J2WoBgGZC9yAzUas2?usp=sharing) with VoxelMorph
47
+ - visualize [warp](https://colab.research.google.com/drive/1F8f1imh5WfyBv-crllfeJBFY16-KHl9c?usp=sharing) as warped grid
48
+ - [inverting warps](https://colab.research.google.com/drive/1juAJRYhPPDNbO9yRtlc0VGhbIFSuhpJ2?usp=sharing) that are not diffeomorphisms
8
49
 
9
50
 
10
51
  # Instructions
11
52
 
12
- To use the VoxelMorph library, either clone this repository and install the requirements listed in `setup.py` or install directly with pip.
53
+ To use the VoxelMorph library from source, clone this repository and install the requirements listed in `setup.py`.
54
+
55
+ > **Note**: For source development, install from GitHub instead:
13
56
 
14
57
  ```
15
- pip install voxelmorph
58
+ pip install git+https://github.com/voxelmorph/voxelmorph.git
16
59
  ```
17
60
 
18
61
  ## Pre-trained models
@@ -69,28 +112,39 @@ For our data, we found `image_sigma=0.01` and `prior_lambda=25` to work best.
69
112
  In the original MICCAI code, the parameters were applied after the scaling of the velocity field. With the newest code, this has been "fixed", with different default parameters reflecting the change. We recommend running the updated code. However, if you'd like to run the very original MICCAI2018 mode, please use `xy` indexing and `use_miccai_int` network option, with MICCAI2018 parameters.
70
113
 
71
114
 
72
- ## Spatial Transforms and Integration
115
+ ## Spatial transforms and integration
73
116
 
74
117
  - The spatial transform code, found at `voxelmorph.layers.SpatialTransformer`, accepts N-dimensional affine and dense transforms, including linear and nearest neighbor interpolation options. Note that original development of VoxelMorph used `xy` indexing, whereas we are now emphasizing `ij` indexing.
75
118
 
76
119
  - For the MICCAI2018 version, we integrate the velocity field using `voxelmorph.layers.VecInt`. By default we integrate using scaling and squaring, which we found efficient.
77
120
 
78
121
 
79
- # VoxelMorph Papers
122
+ # VoxelMorph papers
80
123
 
81
- If you use voxelmorph or some part of the code, please cite (see [bibtex](citations.bib)):
124
+ If you use VoxelMorph or some part of the code, please cite (see [bibtex](citations.bib)):
82
125
 
83
126
  * HyperMorph, avoiding the need to tune registration hyperparameters:
84
127
 
85
- **HyperMorph: Amortized Hyperparameter Learning for Image Registration.**
86
- Andrew Hoopes, [Malte Hoffmann](https://nmr.mgh.harvard.edu/malte), Bruce Fischl, [John Guttag](https://people.csail.mit.edu/guttag/), [Adrian V. Dalca](http://adalca.mit.edu)
87
- IPMI: Information Processing in Medical Imaging. 2021. [eprint arxiv:2101.01035](https://arxiv.org/abs/2101.01035)
128
+ **Learning the Effect of Registration Hyperparameters with HyperMorph**
129
+ Andrew Hoopes, [Malte Hoffmann](https://malte.cz), Bruce Fischl, [John Guttag](https://people.csail.mit.edu/guttag/), [Adrian V. Dalca](http://adalca.mit.edu)
130
+ MELBA: Machine Learning for Biomedical Imaging. 2022. [eprint arXiv:2203.16680](https://arxiv.org/abs/2203.16680)
88
131
 
132
+ **HyperMorph: Amortized Hyperparameter Learning for Image Registration.**
133
+ Andrew Hoopes, [Malte Hoffmann](https://malte.cz), Bruce Fischl, [John Guttag](https://people.csail.mit.edu/guttag/), [Adrian V. Dalca](http://adalca.mit.edu)
134
+ IPMI: Information Processing in Medical Imaging. 2021. [eprint arXiv:2101.01035](https://arxiv.org/abs/2101.01035)
89
135
 
90
136
  * [SynthMorph](https://synthmorph.voxelmorph.net), avoiding the need to have data at training (!):
91
137
 
138
+ **Anatomy-aware and acquisition-agnostic joint registration with SynthMorph.**
139
+ [Malte Hoffmann](https://malte.cz), Andrew Hoopes, Douglas N. Greve, Bruce Fischl, [Adrian V. Dalca](http://adalca.mit.edu)
140
+ Imaging Neuroscience. 2024. [eprint arXiv:2301.11329](https://arxiv.org/abs/2301.11329)
141
+
142
+ **Anatomy-specific acquisition-agnostic affine registration learned from fictitious images.**
143
+ [Malte Hoffmann](https://malte.cz), Andrew Hoopes, Bruce Fischl, [Adrian V. Dalca](http://adalca.mit.edu)
144
+ SPIE Medical Imaging: Image Processing. 2023.
145
+
92
146
  **SynthMorph: learning contrast-invariant registration without acquired images.**
93
- [Malte Hoffmann](https://nmr.mgh.harvard.edu/malte), Benjamin Billot, [Juan Eugenio Iglesias](https://scholar.harvard.edu/iglesias), Bruce Fischl, [Adrian V. Dalca](http://adalca.mit.edu)
147
+ [Malte Hoffmann](https://malte.cz), Benjamin Billot, [Juan Eugenio Iglesias](https://scholar.harvard.edu/iglesias), Bruce Fischl, [Adrian V. Dalca](http://adalca.mit.edu)
94
148
  IEEE TMI: Transactions on Medical Imaging. 2022. [eprint arXiv:2004.10282](https://arxiv.org/abs/2004.10282)
95
149
 
96
150
  * For the atlas formation model:
@@ -121,19 +175,17 @@ IEEE TMI: Transactions on Medical Imaging. 2019.
121
175
  CVPR 2018. [eprint arXiv:1802.02604](https://arxiv.org/abs/1802.02604)
122
176
 
123
177
 
124
- # Notes:
178
+ # Notes
125
179
  - **keywords**: machine learning, convolutional neural networks, alignment, mapping, registration
126
- - The `master` branch is still in testing as we roll out a major refactoring of the library.
127
- - If you'd like to run code from VoxelMorph publications, please use the `legacy` branch.
128
180
  - **data in papers**:
129
181
  In our initial papers, we used publicly available data, but unfortunately we cannot redistribute it (due to the constraints of those datasets). We do a certain amount of pre-processing for the brain images we work with, to eliminate sources of variation and be able to compare algorithms on a level playing field. In particular, we perform FreeSurfer `recon-all` steps up to skull stripping and affine normalization to Talairach space, and crop the images via `((48, 48), (31, 33), (3, 29))`.
130
182
 
131
183
  We encourage users to download and process their own data. See [a list of medical imaging datasets here](https://github.com/adalca/medical-datasets). Note that you likely do not need to perform all of the preprocessing steps, and indeed VoxelMorph has been used in other work with other data.
132
184
 
133
185
 
134
- # Creation of Deformable Templates
186
+ # Creation of deformable templates
135
187
 
136
- To experiment with this method, please use `train_template.py` for unconditional templates and `train_cond_template.py` for conditional templates, which use the same conventions as voxelmorph (please note that these files are less polished than the rest of the voxelmorph library).
188
+ To experiment with this method, please use `train_template.py` for unconditional templates and `train_cond_template.py` for conditional templates, which use the same conventions as VoxelMorph (please note that these files are less polished than the rest of the VoxelMorph library).
137
189
 
138
190
  We've also provided an unconditional atlas in `data/generated_uncond_atlas.npz.npy`.
139
191
 
@@ -158,5 +210,8 @@ mri_robust_register --mov in.nii.gz --dst out.nii.gz --lta transform.lta --satit
158
210
  where we replace `--satit --iscale` with `--cost NMI` for registration across MRI contrasts.
159
211
 
160
212
 
161
- # Contact:
162
- For any problems or questions please [open an issue](https://github.com/voxelmorph/voxelmorph/issues/new?labels=voxelmorph) for code problems/questions or [start a discussion](https://github.com/voxelmorph/voxelmorph/discussions) for general registration/voxelmorph question/discussion.
213
+ # Data
214
+ While we cannot release most of the data used in the VoxelMorph papers as they prohibit redistribution, we thorough processed and [re-released OASIS1](https://github.com/adalca/medical-datasets/blob/master/neurite-oasis.md) while developing [HyperMorph](http://hypermorph.voxelmorph.net/). We now include a quick [VoxelMorph tutorial](https://colab.research.google.com/drive/1ZefmWXBupRNsnIbBbGquhVDsk-7R7L1S?usp=sharing) to train VoxelMorph on neurite-oasis data.
215
+
216
+ # Contact
217
+ For any code-related problems or questions please [open an issue](https://github.com/voxelmorph/voxelmorph/issues/new?labels=voxelmorph) or [start a discussion](https://github.com/voxelmorph/voxelmorph/discussions) of general registration/VoxelMorph topics.
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "voxelmorph"
7
+ version = "0.3"
8
+ description = "Image Registration with Convolutional Networks"
9
+ requires-python = ">=3.8"
10
+ readme = "README.md"
11
+ license = "Apache-2.0"
12
+ classifiers = [
13
+ "Intended Audience :: Science/Research",
14
+ "Programming Language :: Python :: 3",
15
+ "Operating System :: OS Independent"
16
+ ]
17
+ authors = [
18
+ { name = "Adrian V. Dalca" },
19
+ { name = "Malte Hoffmann" },
20
+ { name = "Andrew Hoopes" }
21
+ ]
22
+ dependencies = [
23
+ "torch",
24
+ "scikit-image",
25
+ "packaging",
26
+ "numpy",
27
+ "scipy",
28
+ "nibabel",
29
+ "h5py",
30
+ "neurite>=0.2",
31
+ ]
32
+ keywords = [
33
+ "python",
34
+ "pytorch",
35
+ "medical-imaging",
36
+ "registration",
37
+ "medical-image-computing",
38
+ ]
39
+
40
+ [project.urls]
41
+ GitHub = "https://github.com/voxelmorph/voxelmorph"
42
+ PyPI = "https://pypi.org/project/voxelmorph/"
@@ -3,22 +3,15 @@
3
3
  import re
4
4
  import pathlib
5
5
  import setuptools
6
- import packaging.version
7
-
8
-
9
- # base source directory
10
- base_dir = pathlib.Path(__file__).parent.resolve()
11
6
 
12
7
  # extract the current version
13
- init_file = base_dir.joinpath('voxelmorph/__init__.py')
8
+ init_file = pathlib.Path(__file__).parent.resolve().joinpath('voxelmorph/__init__.py')
14
9
  init_text = open(init_file, 'rt').read()
15
10
  pattern = r"^__version__ = ['\"]([^'\"]*)['\"]"
16
11
  match = re.search(pattern, init_text, re.M)
17
12
  if not match:
18
- raise RuntimeError(f'Unable to find __version__ in {init_file}.')
13
+ raise RuntimeError(f'Unable to find __version__ in {init_file}')
19
14
  version = match.group(1)
20
- if isinstance(packaging.version.parse(version), packaging.version.LegacyVersion):
21
- raise RuntimeError(f'Invalid version string {version}.')
22
15
 
23
16
  # run setup
24
17
  setuptools.setup(
@@ -29,7 +22,7 @@ setuptools.setup(
29
22
  url='https://github.com/voxelmorph/voxelmorph',
30
23
  keywords=['deformation', 'registration', 'imaging', 'cnn', 'mri'],
31
24
  packages=setuptools.find_packages(),
32
- python_requires='>=3.6',
25
+ python_requires='>=3.8',
33
26
  classifiers=[
34
27
  'Intended Audience :: Science/Research',
35
28
  'Programming Language :: Python :: 3',