fsl.data.featimage

This module provides the FEATImage class, a subclass of Image designed to encapsulate data from a FEAT analysis. This module also provides the modelFit() function.

class fsl.data.featimage.FEATImage(*args, **kwargs)[source]

Bases: Image

An Image which contains the input data from a FEAT analysis.

The FEATImage class makes use of the functions defined in the featanalysis module.

An example of using the FEATImage class:

import fsl.data.featimage as featimage

# You can pass in the name of the
# .feat directory, or the filtered_func_data
# file contained within that directory.
img = featimage.FEATImage('myanalysis.feat/filtered_func_data.nii.gz')

# Query information about the FEAT analysis
print(img.numEVs())
print(img.contrastNames())
print(img.numPoints())

# Get the model fit residuals
res4d = img.getResiduals()

# Get the full model fit for voxel
# [23, 30, 42] (in this example, we
# have 4 EVs - the first argument
# is a contrast vector).
img.fit([1, 1, 1, 1], [23, 30, 42], fullModel=True)
__init__(path, **kwargs)[source]

Create a FEATImage instance.

Parameters:
  • path – A FEAT analysis directory, or the input data image file contained within such a directory.

  • kwargs – Passed to the Image constructor.

__del__()[source]

Clears references to any loaded images.

getFEATDir()[source]

Returns the FEAT directory this image is contained in.

getAnalysisName()[source]

Returns the FEAT analysis name, which is the FEAT directory name, minus the .feat / .gfeat suffix.

isFirstLevelAnalysis()[source]

Returns True if the FEAT analysis described by settings is a first level analysis, False otherwise.

getTopLevelAnalysisDir()[source]

Returns the path to the higher level analysis directory of which this FEAT analysis is a part, or None if this analysis is not part of another analysis.

getReportFile()[source]

Returns the path to the FEAT report - see featanalysis.getReportFile().

hasStats()[source]

Returns True if the analysis for this FEATImage contains a statistical analysis.

getDesign(voxel=None)[source]

Returns the analysis design matrix as a numpy array with shape \(numPoints\times numEVs\). See FEATFSFDesign.getDesign().

numPoints()[source]

Returns the number of points (e.g. time points, number of subjects, etc) in the analysis.

numEVs()[source]

Returns the number of explanatory variables (EVs) in the analysis.

evNames()[source]

Returns a list containing the name of each EV in the analysis.

numContrasts()[source]

Returns the number of contrasts in the analysis.

numFTests()[source]

Returns the number of f-tests in the analysis.

contrastNames()[source]

Returns a list containing the name of each contrast in the analysis.

contrasts()[source]

Returns a list containing the analysis contrast vectors.

See featanalysis.loadContrasts()

ftests()[source]

Returns a list containing the analysis f-test vectors.

See featanalysis.loadFTests()

thresholds()[source]

Returns the statistical thresholds used in the analysis.

See featanalysis.getThresholds()

clusterResults(contrast, ftest=False)[source]

Returns the clusters found in the analysis for the specified contrast or f-test.

See :func:.featanalysis.loadClusterResults`

getPE(ev)[source]

Returns the PE image for the given EV (0-indexed).

getResiduals()[source]

Returns the residuals of the full model fit.

getCOPE(con)[source]

Returns the COPE image for the given contrast (0-indexed).

getZStats(con)[source]

Returns the Z statistic image for the given contrast (0-indexed).

getZFStats(ftest)[source]

Returns the Z statistic image for the given f-test (0-indexed).

getClusterMask(con)[source]

Returns the cluster mask image for the given contrast (0-indexed).

getFClusterMask(ftest)[source]

Returns the cluster mask image for the given f-test (0-indexed).

fit(contrast, xyz)[source]

Calculates the model fit for the given contrast vector at the given voxel. See the modelFit() function.

Parameters:
  • contrast – The contrast vector (pass all 1s for a full model fit).

  • xyz – Coordinates of the voxel to calculate the model fit for.

partialFit(contrast, xyz)[source]

Calculates and returns the partial model fit for the specified contrast vector at the specified voxel.

See fit() for details on the arguments.

__annotations__ = {}
__module__ = 'fsl.data.featimage'
fsl.data.featimage.modelFit(data, design, contrast, pes, firstLevel=True)[source]

Calculates the model fit to the given data for the given contrast vector.

Parameters:
  • data – The input data

  • design – The design matrix

  • contrast – The contrast vector (pass all 1s for a full model fit)

  • pes – Parameter estimates for each EV in the design matrix

  • firstLevel – If True (the default), the mean of the input data is added to the result.

Returns:

The best fit of the model to the data.