Skip to content
Snippets Groups Projects
Commit 3203612b authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Renamed featresults.py to featanalysis.py. FSF settings are stored in an

ordered dict.
parent 79cf2dc7
No related branches found
No related tags found
No related merge requests found
:orphan:
fsl.data.featresults module
===========================
fsl.data.featanalysis module
============================
.. automodule:: fsl.data.featresults
.. automodule:: fsl.data.featanalysis
:members:
:undoc-members:
:show-inheritance:
#!/usr/bin/env python
#
# featresults.py - Utility functions for loading/querying the contents of
# featanalysis.py - Utility functions for loading/querying the contents of
# a FEAT analysis directory.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
......@@ -42,6 +42,7 @@ The following functions return the names of various files of interest:
"""
import collections
import logging
import os.path as op
import numpy as np
......@@ -238,7 +239,7 @@ def loadSettings(featdir):
:arg featdir: A FEAT directory.
"""
settings = {}
settings = collections.OrderedDict()
designfsf = op.join(featdir, 'design.fsf')
log.debug('Loading FEAT settings from {}'.format(designfsf))
......@@ -254,7 +255,7 @@ def loadSettings(featdir):
tkns = line.split(None, 2)
key = tkns[1].strip()
val = tkns[2].strip().strip("'").strip('"')
val = tkns[2].strip(' \'"')
if key.startswith('fmri(') and key.endswith(')'):
key = key[5:-1]
......
......@@ -14,14 +14,14 @@ import os.path as op
import numpy as np
from . import image as fslimage
from . import featresults
from . import featanalysis
class FEATImage(fslimage.Image):
"""An ``Image`` from a FEAT analysis.
The :class:`FEATImage` class makes use of the functions defined in the
:mod:`.featresults` module.
:mod:`.featanalysis` module.
An example of using the ``FEATImage`` class::
......@@ -66,16 +66,16 @@ class FEATImage(fslimage.Image):
if op.isdir(path):
path = op.join(path, 'filtered_func_data')
if not featresults.isFEATImage(path):
if not featanalysis.isFEATImage(path):
raise ValueError('{} does not appear to be data '
'from a FEAT analysis'.format(path))
featDir = op.dirname(path)
settings = featresults.loadSettings( featDir)
settings = featanalysis.loadSettings( featDir)
if featresults.hasStats(featDir):
design = featresults.loadDesign( featDir)
names, cons = featresults.loadContrasts(featDir)
if featanalysis.hasStats(featDir):
design = featanalysis.loadDesign( featDir)
names, cons = featanalysis.loadContrasts(featDir)
else:
design = np.zeros((0, 0))
names, cons = [], []
......@@ -88,7 +88,7 @@ class FEATImage(fslimage.Image):
self.__contrastNames = names
self.__contrasts = cons
self.__settings = settings
self.__evNames = featresults.getEVNames(settings)
self.__evNames = featanalysis.getEVNames(settings)
self.__residuals = None
self.__pes = [None] * self.numEVs()
......@@ -117,7 +117,7 @@ class FEATImage(fslimage.Image):
which this FEAT analysis is a part, or ``None`` if this analysis
is not part of another analysis.
"""
return featresults.getTopLevelAnalysisDir(self.__featDir)
return featanalysis.getTopLevelAnalysisDir(self.__featDir)
def hasStats(self):
......@@ -166,7 +166,7 @@ class FEATImage(fslimage.Image):
def contrasts(self):
"""Returns a list containing the analysis contrast vectors.
See :func:`.featresults.loadContrasts`
See :func:`.featanalysis.loadContrasts`
"""
return [list(c) for c in self.__contrasts]
......@@ -175,26 +175,26 @@ class FEATImage(fslimage.Image):
def thresholds(self):
"""Returns the statistical thresholds used in the analysis.
See :func:`.featresults.getThresholds`
See :func:`.featanalysis.getThresholds`
"""
return featresults.getThresholds(self.__settings)
return featanalysis.getThresholds(self.__settings)
def clusterResults(self, contrast):
"""Returns the clusters found in the analysis.
See :func:.featresults.loadClusterResults`
See :func:.featanalysis.loadClusterResults`
"""
return featresults.loadClusterResults(self.__featDir,
self.__settings,
contrast)
return featanalysis.loadClusterResults(self.__featDir,
self.__settings,
contrast)
def getPE(self, ev):
"""Returns the PE image for the given EV (0-indexed). """
if self.__pes[ev] is None:
pefile = featresults.getPEFile(self.__featDir, ev)
pefile = featanalysis.getPEFile(self.__featDir, ev)
self.__pes[ev] = fslimage.Image(
pefile,
name='{}: PE{} ({})'.format(
......@@ -209,7 +209,7 @@ class FEATImage(fslimage.Image):
"""Returns the residuals of the full model fit. """
if self.__residuals is None:
resfile = featresults.getResidualFile(self.__featDir)
resfile = featanalysis.getResidualFile(self.__featDir)
self.__residuals = fslimage.Image(
resfile,
name='{}: residuals'.format(self.__analysisName))
......@@ -221,7 +221,7 @@ class FEATImage(fslimage.Image):
"""Returns the COPE image for the given contrast (0-indexed). """
if self.__copes[con] is None:
copefile = featresults.getPEFile(self.__featDir, con)
copefile = featanalysis.getPEFile(self.__featDir, con)
self.__copes[con] = fslimage.Image(
copefile,
name='{}: COPE{} ({})'.format(
......@@ -237,7 +237,7 @@ class FEATImage(fslimage.Image):
"""
if self.__zstats[con] is None:
zfile = featresults.getZStatFile(self.__featDir, con)
zfile = featanalysis.getZStatFile(self.__featDir, con)
self.__zstats[con] = fslimage.Image(
zfile,
......@@ -254,7 +254,7 @@ class FEATImage(fslimage.Image):
"""
if self.__clustMasks[con] is None:
mfile = featresults.getClusterMaskFile(self.__featDir, con)
mfile = featanalysis.getClusterMaskFile(self.__featDir, con)
self.__clustMasks[con] = fslimage.Image(
mfile,
......
......@@ -39,9 +39,9 @@ import numpy as np
import props
import fsl.utils.path as fslpath
import fsl.data.image as fslimage
import fsl.data.featresults as featresults
import fsl.utils.path as fslpath
import fsl.data.image as fslimage
import fsl.data.featanalysis as featanalysis
log = logging.getLogger(__name__)
......@@ -112,9 +112,9 @@ def getTopLevelAnalysisDir(path):
directories, the path to the highest-level (i.e. the shallowest in the
file system) directory is returned. Otherwise, ``None`` is returned.
See :func:`.featresults.getTopLevelAnalysisDir`.
See :func:`.featanalysis.getTopLevelAnalysisDir`.
"""
return featresults.getTopLevelAnalysisDir(path)
return featanalysis.getTopLevelAnalysisDir(path)
def getDataFile(meldir):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment