NIPY logo

Site Navigation

NIPY Community

Github repo

Table Of Contents

This Page

algorithms.registration.histogram_registration

Module: algorithms.registration.histogram_registration

Inheritance diagram for nipy.algorithms.registration.histogram_registration:

Intensity-based image registration

Class

HistogramRegistration

class nipy.algorithms.registration.histogram_registration.HistogramRegistration(from_img, to_img, from_bins=256, to_bins=None, from_mask=None, to_mask=None, similarity='crl1', interp='pv', **kwargs)

Bases: object

A class to reprensent a generic intensity-based image registration algorithm.

Methods

eval
explore
optimize
set_fov
subsample
__init__(from_img, to_img, from_bins=256, to_bins=None, from_mask=None, to_mask=None, similarity='crl1', interp='pv', **kwargs)
Creates a new histogram registration object.
Parameters :

from_img : nipy-like image

From image

to_img : nipy-like image

To image

from_bins : integer

Number of histogram bins to represent the from image

to_bins : integer

Number of histogram bins to represent the to image

from_mask : array-like

Mask to apply to the from image

to_mask : array-like

Mask to apply to the to image

similarity : str or callable

Cost-function for assessing image similarity. If a string, one of ‘cc’: correlation coefficient, ‘cr’: correlation ratio, ‘crl1’: L1-norm based correlation ratio, ‘mi’: mutual information, ‘nmi’: normalized mutual information, ‘slr’: supervised log-likelihood ratio. If a callable, it should take a two-dimensional array representing the image joint histogram as an input and return a float.

interp : str

Interpolation method. One of ‘pv’: Partial volume, ‘tri’: Trilinear, ‘rand’: Random interpolation. See joint_histogram.c

eval(T)

Evaluate similarity function given a world-to-world transform.

Parameters :

T : Transform

Transform object implementing apply method

explore(T0, *args)

Evaluate the similarity at the transformations specified by sequences of parameter values.

For instance:

explore(T0, (0, [-1,0,1]), (4, [-2.,2]))

interp
optimize(T, optimizer='powell', **kwargs)

Optimize transform T with respect to similarity measure.

The input object T will change as a result of the optimization.

Parameters :

T : object or str

An object representing a transformation that should implement apply method and param attribute or property. If a string, one of ‘rigid’, ‘similarity’, or ‘affine’. The corresponding transformation class is then initialized by default.

optimizer : str

Name of optimization function (one of ‘powell’, ‘steepest’, ‘cg’, ‘bfgs’, ‘simplex’)

**kwargs : dict

keyword arguments to pass to optimizer

set_fov(spacing=None, corner=(0, 0, 0), size=None, npoints=None)

Defines a subset of the from image to restrict joint histogram computation.

Parameters :

spacing : sequence (3,) of positive integers

Subsampling of image in voxels, where None (default) results in the subsampling to be automatically adjusted to roughly match a cubic grid with npoints voxels

corner : sequence (3,) of positive integers

Bounding box origin in voxel coordinates

size : sequence (3,) of positive integers

Desired bounding box size

npoints : positive integer

Desired number of voxels in the bounding box. If a spacing argument is provided, then npoints is ignored.

similarity
subsample(spacing=None, npoints=None)

Functions

nipy.algorithms.registration.histogram_registration.clamp(x, bins=256, mask=None)

Clamp array values that fall within a given mask in the range [0..bins-1] and reset masked values to -1.

Parameters :

x : ndarray

The input array

bins : number

Desired number of bins

mask : ndarray, tuple or slice

Anything such that x[mask] is an array.

Returns :

y : ndarray

Clamped array, masked items are assigned -1

bins : number

Adjusted number of bins

nipy.algorithms.registration.histogram_registration.ideal_spacing(data, npoints)

Tune spacing factors so that the number of voxels in the output block matches a given number.

Parameters :

data : ndarray or sequence

Data image to subsample

npoints : number

Target number of voxels (negative values will be ignored)

Returns :

spacing: ndarray :

Spacing factors

nipy.algorithms.registration.histogram_registration.smallest_bounding_box(msk)

Extract the smallest bounding box from a mask