fsl.data.featanalysis
This module provides a few utility functions for loading/querying the
contents of a FEAT analysis directory. They are primarily for use by the
FEATImage class, but are available for other uses if needed. The
following functions are provided:
Returns |
|
Returns |
|
Returns |
|
Returns |
|
If the given path is contained within a FEAT directory, the path to that FEAT directory is returned. |
|
If the given path is contained within a hierarchy of FEAT or MELODIC directories, the path to the highest-level (i.e. the shallowest in the file system) directory is returned. |
|
Returns |
|
Loads the design matrix from a FEAT directory. |
|
Loads the contrasts from a FEAT directory. |
|
Loads F-tests from a FEAT directory. |
|
Loads the analysis settings from a text file (.fsf) used to configure FEAT. |
|
Loads the analysis settings from a FEAT directory. |
|
Given a FEAT settings dictionary, returns a dictionary of |
|
If cluster thresholding was used in the FEAT analysis, this function will load and return the cluster results for the specified (0-indexed) contrast or f-test. |
|
Load a FEAT design file, e.g. |
The following functions return the names of various files of interest:
Returns the name of the file in the FEAT directory which contains the model input data (typically called |
|
Returns the name of the file in the FEAT results which contains the model fit residuals (typically called |
|
Returns the name of the file in the FEAT results which contains the melodic components (if melodic ICA was performed as part of the FEAT analysis). |
|
Returns the path of the PE file for the specified EV. |
|
Returns the path of the COPE file for the specified contrast. |
|
Returns the path of the Z-statistic file for the specified contrast. |
|
Returns the path of the Z-statistic file for the specified F-test. |
|
Returns the path of the cluster mask file for the specified contrast. |
|
Returns the path of the cluster mask file for the specified f-test. |
- fsl.data.featanalysis.isFEATImage(path)[source]
Returns
Trueif the given path looks like it is the input data to a FEAT analysis,Falseotherwise.
- fsl.data.featanalysis.isFEATDir(path)[source]
Returns
Trueif the given path looks like a FEAT directory, or looks like the input data for a FEAT analysis,Falseotherwise. A FEAT directory:Must be named
*.feat.Must contain a file called
filtered_func_data.nii.gz.Must contain a file called
design.fsf.Must contain a file called
design.mat.Must contain a file called
design.con.
- Parameters:
path – A file / directory path.
- fsl.data.featanalysis.hasStats(featdir)[source]
Returns
Trueif it looks like statistics have been calculated for the given FEAT analysis,Falseotherwise.
- fsl.data.featanalysis.hasMelodicDir(featdir)[source]
Returns
Trueif the data for the given FEAT directory has had MELODIC run on it,Falseotherwise.
- fsl.data.featanalysis.getAnalysisDir(path)[source]
If the given path is contained within a FEAT directory, the path to that FEAT directory is returned. Otherwise,
Noneis returned.
- fsl.data.featanalysis.getTopLevelAnalysisDir(path)[source]
If the given path is contained within a hierarchy of FEAT or MELODIC directories, the path to the highest-level (i.e. the shallowest in the file system) directory is returned. Otherwise,
Noneis returned.
- fsl.data.featanalysis.getReportFile(featdir)[source]
Returns the path to the FEAT report index file, or
Noneif there is no report.
- fsl.data.featanalysis.loadContrasts(featdir)[source]
Loads the contrasts from a FEAT directory. Returns a tuple containing:
A list of names, one for each contrast.
A list of contrast vectors (each of which is a list itself).
- Parameters:
featdir – A FEAT directory.
- fsl.data.featanalysis.loadFTests(featdir)[source]
Loads F-tests from a FEAT directory. Returns a list of f-test vectors (each of which is a list itself), where each vector contains a 1 or a 0 denoting the contrasts included in the F-test.
- Parameters:
featdir – A FEAT directory.
- fsl.data.featanalysis.loadFsf(designfsf)[source]
Loads the analysis settings from a text file (.fsf) used to configure FEAT.
Returns a dict containing the settings specified in the file
- Parameters:
designfsf – A .fsf file.
- fsl.data.featanalysis.loadSettings(featdir)[source]
Loads the analysis settings from a FEAT directory.
Returns a dict containing the settings specified in the
design.fsffile within the directory- Parameters:
featdir – A FEAT directory.
- fsl.data.featanalysis.loadDesign(featdir, settings)[source]
Loads the design matrix from a FEAT directory.
- Parameters:
featdir – A FEAT directory.
settings – Dictionary containing FEAT settings (see
loadSettings()).
- Returns:
a
FEATFSFDesigninstance which represents the design matrix.
- fsl.data.featanalysis.getThresholds(settings)[source]
Given a FEAT settings dictionary, returns a dictionary of
{stat : threshold}mappings, containing the thresholds used in the FEAT statistical analysis.The following keys will be present. Threshold values will be
Noneif the respective statistical thresholding was not carried out:p: P-value thresholdingz: Z-statistic thresholding
- Parameters:
settings – A FEAT settings dictionary (see
loadSettings()).
- fsl.data.featanalysis.isFirstLevelAnalysis(settings)[source]
Returns
Trueif the FEAT analysis described bysettingsis a first level analysis,Falseotherwise.- Parameters:
settings – A FEAT settings dictionary (see
loadSettings()).
- fsl.data.featanalysis.loadClusterResults(featdir, settings, contrast, ftest=False)[source]
If cluster thresholding was used in the FEAT analysis, this function will load and return the cluster results for the specified (0-indexed) contrast or f-test.
If there are no cluster results for the given contrast/f-test,
Noneis returned.An error will be raised if the cluster file cannot be parsed.
- Parameters:
featdir – A FEAT directory.
settings – A FEAT settings dictionary.
contrast – 0-indexed contrast or f-test number.
ftest – If
False(default), return cluster results for the contrast numberedcontrast. Otherwise, return cluster results for the f-test numberedcontrast.
- Returns:
A list of
Clusterinstances, each of which contains information about one cluster. AClusterobject has the following attributes:indexCluster index.
nvoxelsNumber of voxels in cluster.
pCluster p value.
logp\(-log_{10}\) of the cluster P value.
zmaxMaximum Z value in cluster.
zmaxxX voxel coordinate of maximum Z value.
zmaxyY voxel coordinate of maximum Z value.
zmaxzZ voxel coordinate of maximum Z value.
zcogxX voxel coordinate of cluster centre of gravity.
zcogyY voxel coordinate of cluster centre of gravity.
zcogzZ voxel coordinate of cluster centre of gravity.
copemaxMaximum COPE value in cluster (not present for f-tests).
copemaxxX voxel coordinate of maximum COPE value (not present for f-tests).
copemaxyY voxel coordinate of maximum COPE value. (not present for f-tests).
copemaxzZ voxel coordinate of maximum COPE value. (not present for f-tests).
copemeanMean COPE of all voxels in the cluster. (not present for f-tests).
- fsl.data.featanalysis.loadFEATDesignFile(filename)[source]
Load a FEAT design file, e.g.
design.mat,design.con,design.fts.These files contain key-value pairs, and are formatted according to an undocumented structure where each key is of the form “/KeyName”, and is followed immediately by a whitespace character, and then the value.
- Parameters:
filename – File to load
- Returns:
A dictionary of key-value pairs. The values are all left as strings.
- fsl.data.featanalysis.getDataFile(featdir)[source]
Returns the name of the file in the FEAT directory which contains the model input data (typically called
filtered_func_data.nii.gz).Raises a
PathErrorif the file does not exist.- Parameters:
featdir – A FEAT directory.
- fsl.data.featanalysis.getMelodicFile(featdir)[source]
Returns the name of the file in the FEAT results which contains the melodic components (if melodic ICA was performed as part of the FEAT analysis). This file can be loaded as a
MelodicImage.Raises a
PathErrorif the file does not exist.
- fsl.data.featanalysis.getResidualFile(featdir)[source]
Returns the name of the file in the FEAT results which contains the model fit residuals (typically called
res4d.nii.gz).Raises a
PathErrorif the file does not exist.- Parameters:
featdir – A FEAT directory.
- fsl.data.featanalysis.getPEFile(featdir, ev)[source]
Returns the path of the PE file for the specified EV.
Raises a
PathErrorif the file does not exist.- Parameters:
featdir – A FEAT directory.
ev – The EV number (0-indexed).
- fsl.data.featanalysis.getCOPEFile(featdir, contrast)[source]
Returns the path of the COPE file for the specified contrast.
Raises a
PathErrorif the file does not exist.- Parameters:
featdir – A FEAT directory.
contrast – The contrast number (0-indexed).
- fsl.data.featanalysis.getZStatFile(featdir, contrast)[source]
Returns the path of the Z-statistic file for the specified contrast.
Raises a
PathErrorif the file does not exist.- Parameters:
featdir – A FEAT directory.
contrast – The contrast number (0-indexed).
- fsl.data.featanalysis.getZFStatFile(featdir, ftest)[source]
Returns the path of the Z-statistic file for the specified F-test.
Raises a
PathErrorif the file does not exist.- Parameters:
featdir – A FEAT directory.
ftest – The F-test number (0-indexed).