Package mvpa :: Package datasets :: Module nifti :: Class NiftiDataset
[hide private]
[frames] | no frames]

Class NiftiDataset

source code


Dataset loading its samples from a NIfTI image or file.

Samples can be loaded from a NiftiImage instance or directly from a NIfTI
file. This class stores all relevant information from the NIfTI file header
and provides information about the metrics and neighborhood information of
all voxels.

Most importantly it allows to map data back into the original data space
and format via :meth:`~mvpa.datasets.nifti.NiftiDataset.map2Nifti`.

This class allows for convenient pre-selection of features by providing a
mask to the constructor. Only non-zero elements from this mask will be
considered as features.

NIfTI files are accessed via PyNIfTI. See
http://niftilib.sourceforge.net/pynifti/ for more information about
pynifti.

Instance Methods [hide private]
 
__init__(self, samples=None, mask=None, dsattr=None, enforce_dim=4, scale_data=True, **kwargs)
If samples and mapper arguments are not None the mapper is used to forward-map the samples array and the result is passed to the Dataset constructor.
source code
 
map2Nifti(self, data=None)
Maps a data vector into the dataspace and wraps it with a NiftiImage. The header data of this object is used to initialize the new NiftiImage (scl_slope and scl_inter are reset to 1.0 and 0.0 accordingly).
source code
 
getDt(self)
Return the temporal distance of two samples/volumes.
source code

Inherited from mapped.MappedDataset: mapForward, mapReverse, mapSelfReverse, selectFeatures

Class Variables [hide private]
  niftihdr = property(fget= lambda self: self._dsattr ['niftihdr...
  dt = property(fget= getDt, doc= 'Time difference between two s...
  samplingrate = property(fget= lambda self: 1.0/ self.dt, doc= ...

Inherited from mapped.MappedDataset: O, __doc__, mapper, samples_original

Method Details [hide private]

__init__(self, samples=None, mask=None, dsattr=None, enforce_dim=4, scale_data=True, **kwargs)
(Constructor)

source code 
If samples and mapper arguments are not None the mapper is used to forward-map the samples array and the result is passed to the Dataset constructor.
Parameters:
  • samples, str, |, NiftiImage - Filename of a NIfTI image or a NiftiImage instance.
  • mask, str, |, NiftiImage, |, ndarray - Filename of a NIfTI image or a NiftiImage instance or an ndarray of appropriate shape.
  • enforce_dim (int or None) - If not None, it is the dimensionality of the data to be enforced, commonly 4D for the data, and 3D for the mask in case of fMRI.
  • scale_data (bool) - NIfTI header specifies scl_slope and scl_inter for scaling and offsetting the data. By default those will get applied to the data (change in behavior post 0.4.6).
Overrides: mapped.MappedDataset.__init__

map2Nifti(self, data=None)

source code 
Maps a data vector into the dataspace and wraps it with a NiftiImage. The header data of this object is used to initialize the new NiftiImage (scl_slope and scl_inter are reset to 1.0 and 0.0 accordingly).
Parameters:
  • data (ndarray or Dataset) - The data to be wrapped into NiftiImage. If None (default), it would wrap samples of the current dataset. If it is a Dataset instance -- takes its samples for mapping

getDt(self)

source code 

Return the temporal distance of two samples/volumes.

This method tries to be clever and always returns dt in seconds, by using unit information from the NIfTI header. If such information is not present the assumed unit will also be seconds.


Class Variable Details [hide private]

niftihdr

Value:
property(fget= lambda self: self._dsattr ['niftihdr'], doc= 'Access to\
 the NIfTI header dictionary.')

dt

Value:
property(fget= getDt, doc= 'Time difference between two samples (in se\
conds). ' 'AKA TR in fMRI world.')

samplingrate

Value:
property(fget= lambda self: 1.0/ self.dt, doc= 'Sampling rate (based o\
n .dt).')