NIPY logo

Site Navigation

NIPY Community

Table Of Contents

Previous topic

core.image.image_spaces

This Page

core.image.roi

Module: core.image.roi

Inheritance diagram for nipy.core.image.roi:

Template region of interest (ROI) module

Classes

ContinuousROI

class nipy.core.image.roi.ContinuousROI(coordinate_system, bfn, args=None, ndim=3)

Bases: nipy.core.image.roi.ROI

Create an ROI with a binary function in a given coordinate system.

Methods

todiscrete(voxels) Return a DiscreteROI instance at the voxels in the ROI.
__init__(coordinate_system, bfn, args=None, ndim=3)

Initialize continuous ROI instance

Parameters :

coordinate_system : CoordinateSystem instance

TODO

bfn : callable

binary function accepting real-value points as input, and any args in args, returning 1 at points inside the ROI and 0 for points outside the ROI.

args : sequence

arguments to be passed to bfn other then real-valued points

ndim : int

number of dimensions.

todiscrete(voxels)

Return a DiscreteROI instance at the voxels in the ROI.

Parameters :

voxels : array shape (N, 3)

voxel points in real space

Returns :

droi : DiscreteROI instance

discrete ROI where roi defined by voxels inside self

CoordinateMapROI

class nipy.core.image.roi.CoordinateMapROI(coordinate_system, voxels, coordmap)

Bases: nipy.core.image.roi.DiscreteROI

Methods

feature(fn, **extra) Return a feature of an image within the ROI.
mask(img) Return image with ones within ROI, zeros elsewhere
next() Return next point in ROI
pool(image) Pool data from an image over the ROI
__init__(coordinate_system, voxels, coordmap)

Initialize coordinate map ROI instance

Parameters :

coordinate_system : TODO

TODO

voxels : TODO

TODO

coordmap : TODO

TODO

feature(fn, **extra)

Return a feature of an image within the ROI.

Take the mean of voxel (point) features in ROI.

Parameters :

fn : callable

accepts point and kwargs **extra, returns value for that point (see pool method)

**extra : kwargs

keyword arguments to pass to fn

Returns :

val : object

result of np.mean when applied to the values output from fn

mask(img)

Return image with ones within ROI, zeros elsewhere

Returns :``numpy.ndarray`
next()

Return next point in ROI

pool(image)

Pool data from an image over the ROI

Return image value for each voxel in ROI

Parameters :

image : image.Image

or something with a get_data method

Returns :

vals : list

values in image at voxel points given by self.voxels

Raises :

ValueError: if coordinate maps of image and ROI do not match :

DiscreteROI

class nipy.core.image.roi.DiscreteROI(coordinate_system, voxels)

Bases: nipy.core.image.roi.ROI

ROI defined from discrete points

Methods

feature(fn, **extra) Return a feature of an image within the ROI.
next() Return next point in ROI
pool(fn, **extra) Pool data from an image over the ROI – return fn evaluated at
__init__(coordinate_system, voxels)

Initialize discrete ROI

Parameters :

coordinate_system : TODO

TODO

voxels : sequence

feature(fn, **extra)

Return a feature of an image within the ROI.

Take the mean of voxel (point) features in ROI.

Parameters :

fn : callable

accepts point and kwargs **extra, returns value for that point (see pool method)

**extra : kwargs

keyword arguments to pass to fn

Returns :

val : object

result of np.mean when applied to the values output from fn

next()

Return next point in ROI

pool(fn, **extra)

Pool data from an image over the ROI – return fn evaluated at each voxel.

Parameters :

fn : callable

function to apply to each voxel

**extras : kwargs

keyword arguments to pass to fn

Returns :

proc_pts : list

result of fn applied to each point within ROI

ROI

class nipy.core.image.roi.ROI(coordinate_system)

Bases: object

This is the basic ROI class, which we model as basically a function defined on Euclidean space, i.e. R^3. For practical purposes, this function is evaluated on the range of a Mapping instance.

__init__(coordinate_system)

Initialize ROI instance

Parameters :coordinate_system : CoordinateSystem instance

Functions

nipy.core.image.roi.roi_ellipse_fn(center, form, a=1.0)

Ellipse determined by regions where a quadratic form is <= a. The quadratic form is given by the inverse of the ‘form’ argument, so a sphere of radius 10 can be specified as {‘form’:10**2 * identity(3), ‘a’:1} or {‘form’:identity(3), ‘a’:100}.

Form must be positive definite.

Parameters :

form : TODO

TODO

a : float

TODO

Returns :

ellipse_fn : function

binary function of point, returning True if point is within ellipse, False otherwise

nipy.core.image.roi.roi_from_array_sampling_coordmap(data, coordmap)

Return a CoordinateMapROI from an array (data) on a coordmap. interpolation. Obvious ways to extend this.

Parameters :

data : array

Non-zero values in data define points in ROI

coordmap : CoordinateMap instance

coordinate map defining relationship of ijk(etc) indices in data and point space

Returns :

cm_roi : CoordinateMapROI

nipy.core.image.roi.roi_sphere_fn(center, radius)

Binary function for sphere with center and radius

Parameters center : sequence

real coordinates point for sphere center
radius : float
sphere radius
Returns :

sph_fn : function

binary function accepting points as input, return True if point is within sphere, False otherwise