百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
V

voxelmorph

> 编程语言
开源

无监督学习用于图像注册

2.7K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

无监督学习用于图像注册

VoxelMorph: learning-based image registration

VoxelMorph is a general purpose library for learning-based tools for alignment/registration, and more generally modelling with deformations.

⚠️ Warning: VoxelMorph pytorch is under active development. Interfaces may change.

For users who want to use the stable TensorFlow version, pull or clone the dev-tensorflow branch.

Install

Install the published package from PyPI:

pip install voxelmorph

To work from a source checkout, clone this repository and install the requirements listed in setup.py.

Pre-commit hooks

This repo uses pre-commit to run pycodestyle before commits.

Install once after cloning:

pip install pre-commit
pre-commit install

You can also run the check manually:

pre-commit run pycodestyle --all-files

Tutorial

We have several VoxelMorph tutorials:

  • the main VoxelMorph tutorial explains VoxelMorph and learning-based registration
  • a deformable SynthMorph demo showing how to train a registration model without data
  • an affine SynthMorph demo on learning anatomy-aware and acquisition-agnostic affine registration
  • a CT-to-MRI SynthMorph demo clipping the Hounsfield scale for multi-modal registration
  • a SynthMorph shapes demo that walks through the steps of running a trained 3D shapes model
  • a tutorial on training VoxelMorph on OASIS data, which we processed and released for free for HyperMorph
  • an additional small tutorial on warping annotations together with images
  • another tutorial on template (atlas) construction with VoxelMorph
  • visualize warp as warped grid
  • inverting warps that are not diffeomorphisms

Instructions

To use the VoxelMorph library from source, clone this repository and install the requirements listed in setup.py.

Note: For source development, install from GitHub instead:

pip install git+https://github.com/voxelmorph/voxelmorph.git

Pre-trained models

See list of pre-trained models available here.

Training

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.

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.

./scripts/tf/train.py --img-list /images/list.txt --model-dir /models/output --gpu 0

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.

Registration

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:

./scripts/tf/register.py --moving moving.nii.gz --fixed atlas.nii.gz --moved warped.nii.gz --model model.h5 --gpu 0

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.

Testing (measuring Dice scores)

To test the quality of a model by computing dice overlap between an atlas segmentation and warped test scan segmentations, run:

./scripts/tf/test.py --model model.h5 --atlas atlas.npz --scans scan01.npz scan02.npz scan03.npz --labels labels.npz

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.

Parameter choices

CVPR version

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.

MICCAI version

For our data, we found image_sigma=0.01 and prior_lambda=25 to work best.

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.

Spatial transforms and integration

  • 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.

  • 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.

VoxelMorph papers

If you use VoxelMorph or some part of the code, please cite (see bibtex):

  • HyperMorph, avoiding the need to tune registration hyperparameters:

    Learning the Effect of Registration Hyperparameters with HyperMorph
    Andrew Hoopes, Malte Hoffmann, Bruce Fischl, John Guttag, Adrian V. Dalca
    MELBA: Machine Learning for Biomedical Imaging. 2022. eprint arXiv:2203.16680

    HyperMorph: Amortized Hyperparameter Learning for Image Registration.
    Andrew Hoopes, Malte Hoffmann, Bruce Fischl, John Guttag, Adrian V. Dalca
    IPMI: Information Processing in Medical Imaging. 2021. eprint arXiv:2101.01035

  • SynthMorph, avoiding the need to have data at training (!):

    Anatomy-aware and acquisition-agnostic joint registration with SynthMorph.
    Malte Hoffmann, Andrew Hoopes, Douglas N. Greve, Bruce Fischl, Adrian V. Dalca
    Imaging Neuroscience. 2024. eprint arXiv:2301.11329

    Anatomy-specific acquisition-agnostic affine registration learned from fictitious images.
    Malte Hoffmann, Andrew Hoopes, Bruce Fischl, Adrian V. Dalca
    SPIE Medical Imaging: Image Processing. 2023.

    SynthMorph: learning contrast-invariant registration without acquired images.
    Malte Hoffmann, Benjamin Billot, Juan Eugenio Iglesias, Bruce Fischl, Adrian V. Dalca
    IEEE TMI: Transactions on Medical Imaging. 2022. eprint arXiv:2004.10282

  • For the atlas formation model:

    Learning Conditional Deformable Templates with Convolutional Networks
    Adrian V. Dalca, Marianne Rakic, John Guttag, Mert R. Sabuncu
    NeurIPS 2019. eprint arXiv:1908.02738

  • For the diffeomorphic or probabilistic model:

    Unsupervised Learning of Probabilistic Diffeomorphic Registration for Images and Surfaces
    Adrian V. Dalca, Guha Balakrishnan, John Guttag, Mert R. Sabuncu
    MedIA: Medial Image Analysis. 2019. eprint arXiv:1903.03545

    Unsupervised Learning for Fast Probabilistic Diffeomorphic Registration
    Adrian V. Dalca, Guha Balakrishnan, John Guttag, Mert R. Sabuncu
    MICCAI 2018. eprint arXiv:1805.04605

  • For the original CNN model, MSE, CC, or segmentation-based losses:

    VoxelMorph: A Learning Framework for Deformable Medical Image Registration
    Guha Balakrishnan, Amy Zhao, Mert R. Sabuncu, John Guttag, Adrian V. Dalca
    IEEE TMI: Transactions on Medical Imaging. 2019. eprint arXiv:1809.05231

    An Unsupervised Learning Model for Deformable Medical Image Registration
    Guha Balakrishnan, Amy Zhao, Mert R. Sabuncu, John Guttag, Adrian V. Dalca
    CVPR 2018. eprint arXiv:1802.02604

Notes

  • keywords: machine learning, convolutional neural networks, alignment, mapping, registration
  • data in papers: 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)).

We encourage users to download and process their own data. See a list of medical imaging datasets here. Note that you likely do not need to perform all of the preprocessing steps, an

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythondeep-learningdiffeomorphismimage-alignmentimage-registration

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言