fsl.data.featdesign
This module provides the FEATFSFDesign class, which encapsulates
a FEAT design matrix.
The FEATFSFDesign class is intended to be used to access the design
matrix for a FEAT analysis. The main reason for using the FEATFSFDesign
class, instead of just using the design matrix loaded directly from the
[analysis].feat/design.mat file, is because FEAT supports voxelwise EVs,
where the contents of the design matrix will differ for each voxel in the
analysis. For all voxelwise EVs (confound or otherwise), the design matrix (in
design.mat) contains a dummy column which contains the mean across all
voxels. The FEATFSFDesign.getDesign() method will return an
appropriate design matrix for a specific voxel.
Note
Interaction EVs are not currently supported.
Explanatory variables in a FEAT design
A FEAT design matrix may contain the following types of explanatory variables:
Normal EVs. This is simply a column in the design matrix, defined by the user.
Temporal derivative of normal EVs. A column in the design matrix containing the derivative of a normal EV. The presence of a temporal derivative EV for a given normal EV can be determined by the
deriv_ynflag in thedesign.fsffile.Basis function EV. One or more columns derived from a normal EV. A normal EV with the
convolvevalue set to4,5, or6will be followed by a set of basis function EVs (the number of additional EVs can be determined by thebasisfnumflag).Voxelwise EVs. An EV with different values for each voxel. An EV with the
shapevalue set to9is a voxelwise EV. The voxel data will be stored in a file in the FEAT directory calleddesignVoxelwiseEVN.nii.gz(whereNis the EV number, relative to the order in which the EVs were set up by the user).
A FEAT design matrix will contain EVs of the above types, followed by the following types of confound EVs:
Voxelwise confound EVs. These are confound EVs with different values for each voxel. If the design matrix contains confound EVs, two additional files will be present in the FEAT directory,
vef.datandven.dat. Thevef.datfile contains a list of comma separated file names, which are paths to the confound images (these should be in the FEAT directory, and calledInputConfoundEVN.nii.gz).ven.datis a list of comma separated integers, specifying the column number (starting from 1) of each voxelwise confound EV in the final design matrix.Motion parameter EVs. The user can choose to add 6 or 24 motion parameters as regressors to the design matrix. If the
motionevsvalue indesign.fsfis set to1, then 6 motion EVs are added; ifmotionevsis2, then 24 motion EVs are added.Confound EVs. These are any other EVs added by the user.
Module contents
In addition to the FEATFSFDesign class, this module contains a few
other functions and classes that may be useful to advanced users.
The loadDesignMat() function loads the design.mat file from a
FEAT directory, and returns it as a numpy array.
The following functions, defined in this module, will analyse a FEAT analysis
to determine the contents of its design matrix (these functions are called by
the FEATFSFDesign.__init__() method, but may be called directly):
Derives the EVs for the given first level FEAT analysis. |
|
Derives the EVs for the given higher level FEAT analysis. |
These functions return a list containing one instance of the following classes for each column in the design matrix:
Class representing a normal EV in a FEAT design matrix, i.e. one which has been explicitly provided by the user. |
|
Class representing a temporal derivative EV, derived from a normal EV. |
|
Class representing a basis function EV, derived from a normal EV. |
|
Class representing an EV with different values for each voxel in the analysis. |
|
Class representing a confound EV. |
|
Class representing a motion parameter EV. |
|
Class representing a voxelwise confound EV. |
- exception fsl.data.featdesign.FSFError[source]
Bases:
ExceptionException raised by various things in this module, primarily when the contents of the FEAT directory are not valid.
- __module__ = 'fsl.data.featdesign'
- __weakref__
list of weak references to the object (if defined)
- class fsl.data.featdesign.FEATFSFDesign(featDir, settings=None, loadVoxelwiseEVs=True)[source]
Bases:
objectThe
FEATFSFDesignclass encapsulates the design matrix from a FEAT analysis. This class is intended to be used for FEAT analyses generated with FSL 5.0.9 and newer.- __init__(featDir, settings=None, loadVoxelwiseEVs=True)[source]
Create a
FEATFSFDesign.- Parameters:
featDir – Path to the FEAT directory.
settings – A dictionary containing the FEAT analysis settings from its
design.fsf. If not provided, is loaded viafeatanalysis.loadSettings().loadVoxelwiseEVs – If
True(the default), image files for all voxelwise EVs are loaded. Otherwise they are not loaded, and all calls to meth:getDesign will contain the mean data for any voxelwise EV columns.
- getEVs()[source]
Returns a list containing the
EVinstances that represent each column of thisFEATFSFDesign.
- getDesign(voxel=None)[source]
Returns the design matrix for the specified voxel.
- Parameters:
voxel – A tuple containing the
(x, y, z)voxel coordinates of interest. IfNone(the default), or if thisFEATFSFDesignwas created withloadVoxelwiseEVs=False, the design matrix is returned, with any voxelwise EV columns containing the mean voxelwise EV data.
- __dict__ = mappingproxy({'__module__': 'fsl.data.featdesign', '__doc__': 'The ``FEATFSFDesign`` class encapsulates the design matrix from a FEAT\n analysis. This class is intended to be used for FEAT analyses generated\n with FSL 5.0.9 and newer.\n ', '__init__': <function FEATFSFDesign.__init__>, 'getEVs': <function FEATFSFDesign.getEVs>, 'getDesign': <function FEATFSFDesign.getDesign>, '__dict__': <attribute '__dict__' of 'FEATFSFDesign' objects>, '__weakref__': <attribute '__weakref__' of 'FEATFSFDesign' objects>, '__annotations__': {}})
- __module__ = 'fsl.data.featdesign'
- __weakref__
list of weak references to the object (if defined)
- class fsl.data.featdesign.VoxelwiseEVMixin(filename)[source]
Bases:
objectMixin class for voxelwise EVs.
VoxelwiseEVMixininstances contain the following attributes:filenamePath to the image file containing the data for this EV
imageReference to the
ImageobjectSome FSL tools (e.g. PNM) generate compressed voxelwise EVs, where there is only one voxel per slice. For example, if the input data has shape
(x, y, z, t), and slices are acquired along the Z plane, voxelwise EV files generated by PNM will have shape(1, 1, z, t).Therefore, using the
getData()method is preferable to accessing theimage()directly, asgetDatawill check for compressed images, and adjust the voxel coordinates accordingly.- __init__(filename)[source]
Create a
VoxelwiseEVMixin.- Parameters:
filename – Path to the file containing the data for this
VoxelwiseEV.
- property filename
Returns the path to the image file containing the data for this EV.
- getData(x, y, z)[source]
Returns the data at the specified voxel, taking into account compressed voxelwise EVs.
- __dict__ = mappingproxy({'__module__': 'fsl.data.featdesign', '__doc__': 'Mixin class for voxelwise EVs.\n\n ``VoxelwiseEVMixin`` instances contain the following attributes:\n\n ============ ======================================================\n ``filename`` Path to the image file containing the data for this EV\n ``image`` Reference to the :class:`.Image` object\n ============ ======================================================\n\n Some FSL tools (e.g. `PNM\n <https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/PNM>`_) generate *compressed*\n voxelwise EVs, where there is only one voxel per slice. For example,\n if the input data has shape ``(x, y, z, t)``, and slices are acquired\n along the Z plane, voxelwise EV files generated by PNM will have shape\n ``(1, 1, z, t)``.\n\n Therefore, using the :meth:`getData` method is preferable to accessing\n the :meth:`image` directly, as ``getData`` will check for compressed\n images, and adjust the voxel coordinates accordingly.\n ', '__init__': <function VoxelwiseEVMixin.__init__>, '__del__': <function VoxelwiseEVMixin.__del__>, 'filename': <property object>, 'image': <property object>, 'getData': <function VoxelwiseEVMixin.getData>, '__dict__': <attribute '__dict__' of 'VoxelwiseEVMixin' objects>, '__weakref__': <attribute '__weakref__' of 'VoxelwiseEVMixin' objects>, '__annotations__': {}})
- __module__ = 'fsl.data.featdesign'
- __weakref__
list of weak references to the object (if defined)
- class fsl.data.featdesign.EV(index, title)[source]
Bases:
objectClass representing an explanatory variable in a FEAT design matrix.
EVinstances contain the following attributes:indexIndex of this
EV(starting from 0) in the design matrix.titleName of this
EV.- __init__(index, title)[source]
Create an
EV.- Parameters:
index – Index (starting from 0) of this
EVin the design matrix.title – Name of this
EV.
- __dict__ = mappingproxy({'__module__': 'fsl.data.featdesign', '__doc__': 'Class representing an explanatory variable in a FEAT design matrix.\n\n ``EV`` instances contain the following attributes:\n\n ========= ============================================================\n ``index`` Index of this ``EV`` (starting from 0) in the design matrix.\n ``title`` Name of this ``EV``.\n ========= ============================================================\n ', '__init__': <function EV.__init__>, '__dict__': <attribute '__dict__' of 'EV' objects>, '__weakref__': <attribute '__weakref__' of 'EV' objects>, '__annotations__': {}})
- __module__ = 'fsl.data.featdesign'
- __weakref__
list of weak references to the object (if defined)
- class fsl.data.featdesign.NormalEV(realIdx, origIdx, title)[source]
Bases:
EVClass representing a normal EV in a FEAT design matrix, i.e. one which has been explicitly provided by the user.
NormalEVinstances contain the following attributes (in addition to theEVattributes):origIndexIndex (starting from 0) of this
NormalEV, as it was when the user set up the design matrix (i.e. not taking into account temporal derivative or basis function EVs).- __init__(realIdx, origIdx, title)[source]
Create a
NormalEV.- Parameters:
realIdx – Index (starting from 0) of this
NormalEVin the design matrix.origIdx – Original index (starting from 0) of this
NormalEV.title – Name of this
NormalEV.
- __annotations__ = {}
- __module__ = 'fsl.data.featdesign'
- class fsl.data.featdesign.TemporalDerivativeEV(realIdx, origIdx, title)[source]
Bases:
NormalEVClass representing a temporal derivative EV, derived from a normal EV.
- __annotations__ = {}
- __module__ = 'fsl.data.featdesign'
- class fsl.data.featdesign.BasisFunctionEV(realIdx, origIdx, title)[source]
Bases:
NormalEVClass representing a basis function EV, derived from a normal EV.
- __annotations__ = {}
- __module__ = 'fsl.data.featdesign'
- class fsl.data.featdesign.VoxelwiseEV(realIdx, origIdx, title, filename)[source]
Bases:
NormalEV,VoxelwiseEVMixinClass representing an EV with different values for each voxel in the analysis.
VoxelwiseEVinstances contain the following attributes (in addition to theNormalEVattributes):filenamePath to the image file containing the data for this EV
imageReference to the
ImageobjectNote
The file for voxelwise EVs in a higher level analysis are not copied into the FEAT directory, so if the user has removed them, or moved the .gfeat directory, the file path here will not be valid. Therefore, a
VoxelwiseEVwill test to see if the file exists, and will set thefilenameandimageattributes toNoneit it does not exist.- __init__(realIdx, origIdx, title, filename)[source]
Create a
VoxelwiseEV.- Parameters:
realIdx – Index (starting from 0) of this
VoxelwiseEVin the design matrix.origIdx – Original index (starting from 0) of this
VoxelwiseEV.title – Name of this
VoxelwiseEV.filename – Path to the file containing the data for this
VoxelwiseEV.
- __annotations__ = {}
- __module__ = 'fsl.data.featdesign'
- class fsl.data.featdesign.ConfoundEV(index, confIndex, title)[source]
Bases:
EVClass representing a confound EV.
ConfoundEVinstances contain the following attributes (in addition to theEVattributes):confIndexIndex of this
ConfoundEV(starting from 0) in relation to all other confound EVs.- __init__(index, confIndex, title)[source]
Create a
ConfoundEV.- Parameters:
index – Index (starting from 0) of this
ConfoundEVin the design matrix.confIndex – Index (starting from 0) of this
ConfoundEVin relation to all other confound EVs.title – Name of this
ConfoundEV.
- __annotations__ = {}
- __module__ = 'fsl.data.featdesign'
- class fsl.data.featdesign.MotionParameterEV(index, motionIndex, title)[source]
Bases:
EVClass representing a motion parameter EV.
MotionParameterEVinstances contain the following attributes (in addition to theEVattributes):motionIndexIndex of this
MotionParameterEV(starting from 0) in relation to all other motion parameter EVs.- __init__(index, motionIndex, title)[source]
Create a
MotionParameterEV.- Parameters:
index – Index (starting from 0) of this
MotionParameterEVin the design matrix.confIndex – Index (starting from 0) of this
MotionParameterEVin relation to all other motion parameter EVs.title – Name of this
MotionParameterEV.
- __annotations__ = {}
- __module__ = 'fsl.data.featdesign'
- class fsl.data.featdesign.VoxelwiseConfoundEV(index, voxIndex, title, filename)[source]
Bases:
EV,VoxelwiseEVMixinClass representing a voxelwise confound EV.
VoxelwiseConfoundEVinstances contain the following attributes (in addition to theEVattributes):voxIndexIndex of this
VoxelwiseConfoundEV(starting from 0) in relation to all other voxelwise confound EVs.filenamePath to the image file containing the data for this EV
imageReference to the
Imageobject- __init__(index, voxIndex, title, filename)[source]
Create a
Voxelwise ConfoundEV.- Parameters:
index – Index (starting from 0) of this
VoxelwiseConfoundEVin the design matrix.confIndex – Index (starting from 0) of this
VoxelwiseConfoundEVin relation to all other voxelwise confound EVs.title – Name of this
VoxelwiseConfoundEV.filename – Path to the file containing the data for this
VoxelwiseConfoundEV.
- __annotations__ = {}
- __module__ = 'fsl.data.featdesign'
- fsl.data.featdesign.getFirstLevelEVs(featDir, settings, designMat)[source]
Derives the EVs for the given first level FEAT analysis.
- Parameters:
featDir – Path to the FEAT analysis.
settings – A dictionary containing the FEAT analysis settings from its
design.fsffile (seefeatanalysis.loadSettings()).designMat – The FEAT design matrix (a numpy array - see
loadDesignMat()).
- Returns:
A list of
EVinstances, one for each column in the design matrix.
- fsl.data.featdesign.getHigherLevelEVs(featDir, settings, designMat)[source]
Derives the EVs for the given higher level FEAT analysis.
- Parameters:
featDir – Path to the FEAT analysis.
settings – A dictionary containing the FEAT analysis settings from its
design.fsffile (seefeatanalysis.loadSettings()).designMat – The FEAT design matrix (a numpy array - see
loadDesignMat()).
- Returns:
A list of
EVinstances, one for each column in the design matrix.