NIPY logo

Site Navigation

NIPY Community

Table Of Contents

Previous topic

modalities.fmri.design

This Page

modalities.fmri.fmri

Module: modalities.fmri.fmri

Inheritance diagram for nipy.modalities.fmri.fmri:

FmriImageList

class nipy.modalities.fmri.fmri.FmriImageList(images=None, volume_start_times=None, slice_times=None)

Bases: nipy.core.image.image_list.ImageList

Class to implement image list interface for FMRI time series

Allows metadata such as volume and slice times

Methods

from_image
next
__init__(images=None, volume_start_times=None, slice_times=None)

A lightweight implementation of an fMRI image as in ImageList

Parameters :

images: a sliceable object whose items are meant to be images, :

this is checked by asserting that each has a coordmap attribute

volume_start_times: start time of each frame. It can be specified :

either as an ndarray with len(images) elements or as a single float, the TR. Defaults to arange(len(images)).astype(np.float)

slice_times: ndarray specifying offset for each slice of each frame :

See also

nipy.core.image_list.ImageList

Examples

>>> from numpy import asarray
>>> from nipy.testing import funcfile
>>> from nipy.io.api import load_image
>>> # fmrilist and ilist represent the same data
>>> funcim = load_image(funcfile)
>>> fmrilist = FmriImageList.from_image(funcim)
>>> ilist = FmriImageList(funcim)
>>> print asarray(ilist).shape
(17, 21, 3, 20)
>>> print asarray(ilist[4]).shape
(21, 3, 20)
classmethod from_image(klass, fourdimage, volume_start_times=None, slice_times=None, axis='t')

Create an FmriImageList from a 4D Image by extracting 3d images along the ‘t’ axis.

Parameters :

fourdimage: a 4D Image :

volume_start_times: start time of each frame. It can be specified :

either as an ndarray with len(images) elements or as a single float, the TR. Defaults to the diagonal entry of slowest moving dimension of Affine transform

slice_times: ndarray specifying offset for each slice of each frame :

next()
nipy.modalities.fmri.fmri.fmri_generator(data, iterable=None)

This function takes an iterable object and returns a generator that looks like:

[numpy.asarray(data)[:,item] for item in iterator]

This can be used to get time series out of a 4d fMRI image, if and only if time varies across axis 0.

Parameters :

data : array-like

object such that arr = np.asarray(data) returns an array of at least 2 dimensions.

iterable : None or sequence

sequence of objects that can be used to index array arr returned from data. If None, default is range(data.shape[1]), in which case the generator will return elements [arr[:,0], arr[:,1] ... ]

Notes

If data is an FmriImageList instance, there is more overhead involved in calling numpy.asarray(data) than if data is an Image instance or an array.