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