Skip to content
Snippets Groups Projects
Commit a6f30843 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Merge branch 'evan-patch' into 'master'

ENH: add function to load settings from arbitrary fsf

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