Skip to content
Snippets Groups Projects
Commit 673a206d authored by Evan Edmond's avatar Evan Edmond
Browse files

ENH: add function to load settings from arbitrary fsf

parent 8c7adadc
No related branches found
No related tags found
No related merge requests found
...@@ -215,19 +215,16 @@ def loadContrasts(featdir): ...@@ -215,19 +215,16 @@ def loadContrasts(featdir):
return names, contrasts return names, contrasts
def loadFsf(designfsf):
"""Loads the analysis settings from a text file (.fsf) used to configure FEAT.
def loadSettings(featdir): Returns a dict containing the settings specified in the file
"""Loads the analysis settings from a FEAT directory.
Returns a dict containing the settings specified in the ``design.fsf``
file within the directory
:arg featdir: A FEAT directory. :arg designfsf: A .fsf file.
""" """
settings = collections.OrderedDict() settings = collections.OrderedDict()
designfsf = op.join(featdir, 'design.fsf')
log.debug('Loading FEAT settings from {}'.format(designfsf)) log.debug('Loading FEAT settings from {}'.format(designfsf))
with open(designfsf, 'rt') as f: with open(designfsf, 'rt') as f:
...@@ -250,6 +247,19 @@ def loadSettings(featdir): ...@@ -250,6 +247,19 @@ def loadSettings(featdir):
return settings return settings
def loadSettings(featdir):
"""Loads the analysis settings from a FEAT directory.
Returns a dict containing the settings specified in the ``design.fsf``
file within the directory
:arg featdir: A FEAT directory.
"""
designfsf = op.join(featdir, 'design.fsf')
return loadFsf(designfsf)
def loadDesign(featdir, settings): def loadDesign(featdir, settings):
"""Loads the design matrix from a FEAT directory. """Loads the design matrix from a FEAT directory.
......
...@@ -240,9 +240,10 @@ def test_loadSettings(): ...@@ -240,9 +240,10 @@ def test_loadSettings():
with tests.testdir() as testdir: with tests.testdir() as testdir:
featdir = op.join(testdir, 'analysis.feat') featdir = op.join(testdir, 'analysis.feat')
tests.make_dummy_file(op.join(featdir, 'design.fsf'), contents) designfsf = op.join(featdir, 'design.fsf')
result = featanalysis.loadSettings(featdir) tests.make_dummy_file(designfsf, contents)
assert result == expected assert featanalysis.loadSettings(featdir) == expected
assert featanalysis.loadFsf(designfsf) == expected
def test_loadDesign(): def test_loadDesign():
......
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