NIPY logo

Site Navigation

NIPY Community

Table Of Contents

Next topic

algorithms.statistics.classification

This Page

algorithms.resample

Module: algorithms.resample

Some simple examples and utility functions for resampling.

Functions

nipy.algorithms.resample.resample(image, target, mapping, shape, order=3)

Resample image to target CoordinateMap

Use a “world-to-world” mapping mapping and spline interpolation of a order.

Here, “world-to-world” refers to the fact that mapping should be a callable that takes a physical coordinate in “target” and gives a physical coordinate in “image”.

Parameters :

image : Image instance

image that is to be resampled

target : CoordinateMap

coordinate map for output image

mapping : callable or tuple or array

transformation from target.function_range to image.coordmap.function_range, i.e. ‘world-to-world mapping’. Can be specified in three ways: a callable, a tuple (A, b) representing the mapping y=dot(A,x)+b or a representation of this mapping as an affine array, in homogeneous coordinates.

shape : sequence of int

shape of output array, in target.function_domain

order : int, optional

what order of interpolation to use in scipy.ndimage

Returns :

output : Image instance

with interpolated data and output.coordmap == target

nipy.algorithms.resample.resample_img2img(source, target, order=3)

Resample source image to space of target image

This wraps the resample function to resample one image onto another. The output of the function will give an image with shape of the target and data from the source

Parameters :

source : Image

Image instance that is to be resampled

target : Image

Image instance to which source is resampled The output image will have the same shape as the target, and the same coordmap

order : int, optional

What order of interpolation to use in scipy.ndimage

Returns :

output : Image

Image with interpolated data and output.coordmap == target.coordmap

Examples

>>> from nipy.testing import funcfile, anatfile
>>> from nipy.io.api import load_image
>>> aimg_source = load_image(anatfile)
>>> aimg_target = aimg_source
>>> # in this case, we resample aimg to itself
>>> resimg = resample_img2img(aimg_source, aimg_target)