Menu

Helper Module for Deep Learning.

Unsupervised Learning with CNNs for Image Registration

class pynet.models.voxelmorphnet.ConvBlock(dim, in_channels, out_channels, stride=1)[source]

Represents a single convolution block in the Unet which is a convolution based on the size of the input channel and output channels and then preforms a Leaky Relu with parameter 0.2.

__init__(dim, in_channels, out_channels, stride=1)[source]

Initialize the conv block.

Parameters

dim: int

the number of dimensions of the input.

in_channels: int

the number of input channels.

out_channels: int

the number of output channels.

stride: int, default 1

the stride of the convolution.

forward(x)[source]
class pynet.models.voxelmorphnet.FlowRegularizer(k1=0.01)[source]

Total Variation Loss (Smooth Term).

For a dense flow field, we regularize it with the following loss that discourages discontinuity.

k1 * FlowLoss

FlowLoss: a gradient loss on the flow field. Recommend for k1 are 1.0 for ncc, or 0.01 for mse.

__init__(k1=0.01)[source]

Initialize self. See help(type(self)) for accurate signature.

debug(name, tensor)[source]

Print debug message.

Parameters

name: str

the tensor name in the displayed message.

tensor: Tensor

a pytorch tensor.

class pynet.models.voxelmorphnet.SpatialTransformer(size, mode='bilinear')[source]

Represesents a spatial transformation block that uses the output from the UNet to preform a grid_sample.

__init__(size, mode='bilinear')[source]

Initilaize the block.

Parameters

size: uplet

the size of input of the spatial transformer block.

mode: str, default ‘bilinear’

method of interpolation for the grid sampler.

forward(moving, flow)[source]
class pynet.models.voxelmorphnet.UNetCore(dim, enc_nf, dec_nf, full_size=True)[source]

Class representing the U-Net implementation that takes in a fixed image and a moving image and outputs a flow-field.

__init__(dim, enc_nf, dec_nf, full_size=True)[source]

Initiliza the UNet model.

Parameters

enc_nf: list of int, default [16, 32, 32, 32]

the number of features maps for encoding stages.

dec_nf: int, default [32, 32, 32, 32, 32, 16, 16]

the number of features maps for decoding stages.

full_size: bool, default False

full amount of decoding layers.

forward(x)[source]

Forward method.

Parameters

x: Tensor

concatenated moving and fixed images.

class pynet.models.voxelmorphnet.VoxelMorphNet(vol_size, enc_nf=[16, 32, 32, 32], dec_nf=[32, 32, 32, 32, 32, 16, 16], full_size=True)[source]

VoxelMorphNet.

An unsupervised learning-based inference algorithm that uses insights from classical registration methods and makes use of recent developments inconvolutional neural networks (CNNs).

VoxelMorph assumes that input images are pre-affined by an external tool.

2018 CVPR implementation of voxelmorph.

TODO: expand this model by including anatomical surface alignment, which enables training the network given (optional) anatomical segmentations -> described in the paper.

Reference: https://arxiv.org/abs/1903.03545. Code: https://github.com/voxelmorph/voxelmorph.

__init__(vol_size, enc_nf=[16, 32, 32, 32], dec_nf=[32, 32, 32, 32, 32, 16, 16], full_size=True)[source]

Init class.

Parameters

vol_size: uplet

volume size of the atlas.

enc_nf: list of int, default [16, 32, 32, 32]

the number of features maps for encoding stages.

dec_nf: int, default [32, 32, 32, 32, 32, 16, 16]

the number of features maps for decoding stages.

full_size: bool, default False

full amount of decoding layers.

forward(x)[source]

Forward method.

Parameters

x: Tensor

concatenated moving and fixed images.

Follow us

© 2019, pynet developers .
Inspired by AZMIND template.