All Projects → Hsankesara → VoxelMorph-PyTorch

Hsankesara / VoxelMorph-PyTorch

Licence: MIT license
An unofficial PyTorch implementation of VoxelMorph- An unsupervised 3D deformable image registration method

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to VoxelMorph-PyTorch

istn
Image-and-Spatial Transformer Networks
Stars: ✭ 86 (+26.47%)
Mutual labels:  image-registration, spatial-transformer-networks
DeepAtlas
Joint Semi-supervised Learning of Image Registration and Segmentation
Stars: ✭ 38 (-44.12%)
Mutual labels:  image-registration
MTF
Modular Tracking Framework
Stars: ✭ 99 (+45.59%)
Mutual labels:  image-registration
RNiftyReg
An R interface to the NiftyReg medical image registration library
Stars: ✭ 32 (-52.94%)
Mutual labels:  image-registration
st gridnet
A Python implementation of the model described in our publication "A convolutional neural network for common-coordinate registration of high-resolution histology images" developed principally for applications to registration of spatial transcriptomics image data.
Stars: ✭ 18 (-73.53%)
Mutual labels:  image-registration
claire
Constrained Large Deformation Diffeomorphic Image Registration (CLAIRE)
Stars: ✭ 30 (-55.88%)
Mutual labels:  image-registration
BIRL
BIRL: Benchmark on Image Registration methods with Landmark validations
Stars: ✭ 66 (-2.94%)
Mutual labels:  image-registration
quicksilver
Predictive Image Registration
Stars: ✭ 117 (+72.06%)
Mutual labels:  image-registration
nemar
[CVPR2020] Unsupervised Multi-Modal Image Registration via Geometry Preserving Image-to-Image Translation
Stars: ✭ 120 (+76.47%)
Mutual labels:  image-registration
ViT-V-Net for 3D Image Registration Pytorch
Vision Transformer for 3D medical image registration (Pytorch).
Stars: ✭ 169 (+148.53%)
Mutual labels:  image-registration
nightlight
Nightlight: Astronomic Image Processing
Stars: ✭ 25 (-63.24%)
Mutual labels:  image-registration
ITKTubeTK
TubeTK is an open-source toolkit for the segmentation, registration, and analysis of tubes and surfaces in images, developed by Kitware, Inc.
Stars: ✭ 29 (-57.35%)
Mutual labels:  image-registration
TransMorph Transformer for Medical Image Registration
TransMorph: Transformer for Unsupervised Medical Image Registration (PyTorch)
Stars: ✭ 130 (+91.18%)
Mutual labels:  image-registration
glimpse clouds
Pytorch implementation of the paper "Glimpse Clouds: Human Activity Recognition from Unstructured Feature Points", F. Baradel, C. Wolf, J. Mille , G.W. Taylor, CVPR 2018
Stars: ✭ 30 (-55.88%)
Mutual labels:  cvpr2018
MIRACL
Multi-modal Image Registration And Connectivity anaLysis
Stars: ✭ 23 (-66.18%)
Mutual labels:  image-registration
Joint-Motion-Estimation-and-Segmentation
[MICCAI'18] Joint Learning of Motion Estimation and Segmentation for Cardiac MR Image Sequences
Stars: ✭ 45 (-33.82%)
Mutual labels:  image-registration
FaceAttr
CVPR2018 Face Super-resolution with supplementary Attributes
Stars: ✭ 18 (-73.53%)
Mutual labels:  cvpr2018
FAIR.m
Flexible Algorithms for Image Registration
Stars: ✭ 103 (+51.47%)
Mutual labels:  image-registration
text-detection-fots.pytorch
FOTS text detection branch reimplementation, hmean: 83.3%
Stars: ✭ 80 (+17.65%)
Mutual labels:  cvpr2018
IDN-pytorch
paper implement : Fast and Accurate Single Image Super-Resolution via Information Distillation Network
Stars: ✭ 40 (-41.18%)
Mutual labels:  cvpr2018

VoxelMorph-PyTorch

An unofficial PyTorch implementation of VoxelMorph- An unsupervised 3D deformable image registration method.

Image registration

Image registration is the process of aligning two images. For that purpose, one image is taken as a fixed image and the other one is moving image. The goal is to apply a transformation to moving image such that the transformed image(known as the registered image) has the same orientation as the fixed image. The application of the process is vast. The major application of this problem is in medical imaging where two different types of images(like MRI and CT scan) of the same object need to be aligned properly for better understanding.

There are two types of algorithms in image registration. First is Rigid Image Registration(RIR) and the second is Deformation Image Registration (DIR). The process in which all transformations are affine that is the pixel to pixel relationship remains the same as before is known as RIR. This is a linear method and frequently used in the past. It is useful when the moving image has no deformity. The major drawback of this method is that it cannot be used when the moving image incurred some deformation. This happens quite often in medical images when there is a disease like a tumor which can grow or shrink with time. Deformation image registration(DIR) process is used in such cases.

DIR methods are employed when RIR cannot perform the desired task. They can be used to analysis and comparison of medical structures between the scans. Such analysis is used to assess and understand the evolution of brain anatomy over time for individuals with the disease. Deformable registration strategies often involve two steps: an initial affine transformation for global alignment, followed by a much slower deformable transformation with more degrees of freedom. We concentrate on the latter step, in which we compute a dense, nonlinear correspondence for all pixels.

Since the problem is highly ill-posed and has vast applications hence it became a perfect problem for deep learning algorithms to solve. Many different architectures has been proposed but recently VoxelMorph has been proposed which surpassed the prior state of the art. Since, VoxelMorph only has Tensorflow implementation hence I've developed an unoficial PyTorch implementation along with an easy to use API.

How to use

class Dataset(data.Dataset):
    """
    Dataset class for converting the data into batches.
    The data.Dataset class is a pyTorch class which help
    in speeding up  this process with effective parallelization
    """
    'Characterizes a dataset for PyTorch'

    def __init__(self, list_IDs):
        'Initialization'
        self.list_IDs = list_IDs

    def __len__(self):
        'Denotes the total number of samples'
        return len(self.list_IDs)

    def __getitem__(self, index):
        'Generates one sample of data'
        # Select sample
        ID = self.list_IDs[index]

        # Load data and get label
        fixed_image = torch.Tensor(
            resize(io.imread('./fire-fundus-image-registration-dataset/' + ID + '_1.jpg'), (256, 256, 3)))
        moving_image = torch.Tensor(
            resize(io.imread('./fire-fundus-image-registration-dataset/' + ID + '_2.jpg'), (256, 256, 3)))
        return fixed_image, moving_image

    ## Main code
    vm = VoxelMorph(
        (3, 256, 256), is_2d=True)  # Object of the higher level class
    DATA_PATH = './fire-fundus-image-registration-dataset/'
    params = {'batch_size': 1,
              'shuffle': True,
              'num_workers': 6,
              'worker_init_fn': np.random.seed(42)
              }

    max_epochs = 2
    filename = list(set([x.split('_')[0]
                         for x in os.listdir('./fire-fundus-image-registration-dataset/')]))
    partition = {}
    partition['train'], partition['validation'] = train_test_split(
        filename, test_size=0.33, random_state=42)

    # Generators
    training_set = Dataset(partition['train'])
    training_generator = data.DataLoader(training_set, **params)

    validation_set = Dataset(partition['validation'])
    validation_generator = data.DataLoader(validation_set, **params)

    # Loop over epochs
    for epoch in range(max_epochs):
        start_time = time.time()
        train_loss = 0
        train_dice_score = 0
        val_loss = 0
        val_dice_score = 0
        for batch_fixed, batch_moving in training_generator:
            loss, dice = vm.train_model(batch_moving, batch_fixed)
            train_dice_score += dice.data
            train_loss += loss.data
        print('[', "{0:.2f}".format((time.time() - start_time) / 60), 'mins]', 'After', epoch + 1, 'epochs, the Average training loss is ', train_loss *
              params['batch_size'] / len(training_set), 'and average DICE score is', train_dice_score.data * params['batch_size'] / len(training_set))
        # Testing time
        start_time = time.time()
        for batch_fixed, batch_moving in validation_generator:
            # Transfer to GPU
            loss, dice = vm.get_test_loss(batch_moving, batch_fixed)
            val_dice_score += dice.data
            val_loss += loss.data
        print('[', "{0:.2f}".format((time.time() - start_time) / 60), 'mins]', 'After', epoch + 1, 'epochs, the Average validations loss is ', val_loss *
              params['batch_size'] / len(validation_set), 'and average DICE score is', val_dice_score.data * params['batch_size'] / len(validation_set))

Resources

  1. Know more about image registration
  2. Approaches to Registering Images
  3. QuickSilver: A fast deformable image registration technique
  4. VoxelMorph
  5. Spatial Transformer Networks

Author

Heet Sankesara

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].