esmraldi.registration

Module for the registration of two images

Module Contents

Functions

precision(im1, im2)

Precision between two images

recall(im1, im2)

Recall between two images

quality_registration(imRef, imRegistered, threshold=-1, display=False)

Evaluates registration quality.

fmeasure(precision, recall)

Computes the F-Measure, or F1-score,

mutual_information(imRef, imRegistered, bins=20)

Mutual information for joint histogram

dt_mutual_information(imRef, imRegistered, bins=20)

Computes the mutual information on DT

best_fit(fixed, array_moving, number_of_bins, sampling_percentage, find_best_rotation=False, learning_rate=1.1, min_step=0.001, relaxation_factor=0.8)

Finds the best fit between variations of the same image

initialize_resampler(fixed, tx)

Utility function to setup the resampler

find_best_transformation(scale_and_rotation, initial_transform, fixed, moving, update_DT=True)

Function returning the similarity metric value

find_best_translation(translation_vector, initial_transform, fixed, moving)

Function returning the similarity metric value

register_component_images(fixed_array, moving_array, component_images_array, translation_range=1)

Function used for the registration of NMF component images.

register(fixed, moving, number_of_bins, sampling_percentage, find_best_rotation=False, use_DT=True, update_DT=False, normalize_DT=False, seed=1, learning_rate=1.1, min_step=0.001, relaxation_factor=0.8)

Registration between reference (fixed)

esmraldi.registration.precision(im1, im2)

Precision between two images defined as card(im1 cap im2)/card(im2)

Parameters
im1: np.ndarray

first binary image

im2: np.ndarray

second binary image

Returns
float

precision value

esmraldi.registration.recall(im1, im2)

Recall between two images defined as card(im1 cap im2)/card(im1)

Parameters
im1: np.ndarray

first binary image

im2: np.ndarray

second binary image

Returns
float

recall value

esmraldi.registration.quality_registration(imRef, imRegistered, threshold=- 1, display=False)

Evaluates registration quality.

Binarizes images, then computes recall and precision.

Parameters
imRef: np.ndarray

reference (fixed) image

imRegistered: np.ndarray

deformable (moving) image - after registration

threshold: int

threshold to get binary images. A value of -1 means using Otsu thresholding scheme.

Returns
tuple

precision and recall values

esmraldi.registration.fmeasure(precision, recall)

Computes the F-Measure, or F1-score, that is the harmonic mean of the precision and recall.

Parameters
precision: float

precision value

recall: float

recall value

Returns
float

fmeasure

esmraldi.registration.mutual_information(imRef, imRegistered, bins=20)

Mutual information for joint histogram based on entropy computation

Parameters
imRef: np.ndarray

reference (fixed) image

imRegistered: np.ndarray

deformable (moving)image

bins: int

number of bins for joint histogram

Returns
float

mutual information

esmraldi.registration.dt_mutual_information(imRef, imRegistered, bins=20)

Computes the mutual information on DT

Parameters
imRef: sitk.Image

reference image

imRegistered: sitk.Image

target image

bins: int

number of bins for mutual information

Returns
float

mutual information between DT of images

esmraldi.registration.best_fit(fixed, array_moving, number_of_bins, sampling_percentage, find_best_rotation=False, learning_rate=1.1, min_step=0.001, relaxation_factor=0.8)

Finds the best fit between variations of the same image according to mutual information measure.

Different variations of the image (e.g. symmetry) are stored in the first dimension of the array.

Parameters
fixed: np.ndarray

reference (fixed) image

array_moving: np.ndarray

3D deformable (moving) image

number_of_bins: int

number of bins for sampling

sampling_percentage: float

proportion of points to consider in sampling

find_best_rotation: bool

whether to find the best rotation

learning_rate: float

learning rate for gradient descent optimization

min_step: float

min step for optimizer

relaxation_factor: float

relaxation factor for optimizer

Returns
sitk.ImageRegistrationMethod

registration object

esmraldi.registration.initialize_resampler(fixed, tx)

Utility function to setup the resampler i.e. the object which can apply a transform onto an image.

Initialized with nearest neighbor interpolation.

Parameters
fixed: sitk.Image

reference image

tx: sitk.Transform

the transform

Returns
sitk.ResampleImageFilter

the resampler

esmraldi.registration.find_best_transformation(scale_and_rotation, initial_transform, fixed, moving, update_DT=True)

Function returning the similarity metric value between the reference image and the deformed target image.

The current transformation parameters (scale and rotation) are applied to the target image before estimating the metric, i.e. either regular mean squared error, or mean squared error on the distance transformed images.

Parameters
scale_and_rotation: list

current scale and rotation parameters

initial_transform: sitk.Transform

initial transform

fixed: sitk.Image

reference image

moving: sitk.Image

target image

update_DT: bool

whether to re-compute the DT at each step (DT-MSE)

Returns
float

similarity metric value

esmraldi.registration.find_best_translation(translation_vector, initial_transform, fixed, moving)

Function returning the similarity metric value between the reference image and the deformed target image. This function is used in the context of NMF component image registration.

The current transformation parameters (only translation) are applied to the target image before estimating the metric, i.e. mean squared error.

Parameters
translation_vector: list

translation vector in nD

initial_transform: sitk.Transform

the initial transform

fixed: sitk.Image

reference image

moving: sitk.Image

moving image

Returns
float

similarity metric value

esmraldi.registration.register_component_images(fixed_array, moving_array, component_images_array, translation_range=1)

Function used for the registration of NMF component images.

Translation of component images to match the reference.

Parameters
fixed_array: np.ndarray

reference image

moving_array: np.ndarray

target image

component_images_array: np.ndarray

NMF component images: shape (w, h, number_of_components)

translation_range: int

translation search between [-t, t], default 1

Returns
tuple(np.ndarray, np.ndarray)

The translated NMF component images, the translation map

esmraldi.registration.register(fixed, moving, number_of_bins, sampling_percentage, find_best_rotation=False, use_DT=True, update_DT=False, normalize_DT=False, seed=1, learning_rate=1.1, min_step=0.001, relaxation_factor=0.8)

Registration between reference (fixed) and deformable (moving) images.

The transform is initialized with moments

Metric: mutual information

Optimization: gradient descent

Interpolation: nearest neighbor

Parameters
fixed: np.ndarray

reference (fixed) image

moving: np.ndarray

deformable (moving) image

number_of_bins: int

number of bins for sampling

sampling_percentage: float

proportion of points to consider in sampling

find_best_rotation: bool

whether to use exhaustive search to find the best scaling and rotation parameters

use_DT: bool

whether to use the distance transformations of images during exhaustive optimization (if find_best_rotation==True)

update_DT: bool

whether to update the distance transformations during exhaustive optimization (if find_best_rotation==True)

normalize_DT: bool

whether to normalize the distance transformations during exhaustive optimization ((if find_best_rotation==True)

seed: int

seed for metric sampling

learning_rate: float

learning rate for gradient descent optimizer

min_step: float

minimum step: stop criterion for the optimizer

relaxation_factor: float

relaxation factor for the parameters of the transform between each step of the optimizer

Returns
sitk.ImageRegistrationMethod

registration object