fsl.utils.image.roi

This module provides the roi() function, which can be used to extract a region-of-interest from, or expand the field-of-view of, an Image.

fsl.utils.image.roi._normaliseBounds(shape, bounds)[source]

Adjust the given bounds so that it is compatible with the given shape.

Bounds must be specified for at least three dimensions - if the shape has more than three dimensions, additional bounds are added.

A ValueError is raised if the provided bounds are invalid.

Parameters:

bounds – Sequence of (lo, hi) bounds - see roi().

Returns:

An adjusted sequence of bounds.

fsl.utils.image.roi.roi(image, bounds)[source]

Extract an ROI from the given image according to the given bounds.

This function can also be used to pad, or expand the field-of-view, of an image, by passing in negative low bound values, or high bound values which are larger than the image shape. The padded region will contain zeroes.

Parameters:
  • imageImage object

  • bounds – Must be a sequence of tuples, containing the low/high bounds for each voxel dimension, where the low bound is inclusive, and the high bound is exclusive. For 4D images, the bounds for the fourth dimension are optional.

Returns:

A new Image object containing the region specified by the bounds.