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

Merge branch 'bf/featdesign' into 'main'

BF: Adjust `loadFEATDesignFile` to handle missing values

See merge request fsl/fslpy!469
parents a0e98476 0fe45912
No related branches found
No related tags found
No related merge requests found
This document contains the ``fslpy`` release history in reverse chronological This document contains the ``fslpy`` release history in reverse chronological
order. order.
XXX (Under development)
-----------------------
Fixed
^^^^^
* Adjusted the :func:`.featdesign.loadFEATDesignFile` function to handle missing
values (!469).
3.22.0 (Monday 17th February 2025) 3.22.0 (Monday 17th February 2025)
---------------------------------- ----------------------------------
......
...@@ -544,7 +544,12 @@ def loadFEATDesignFile(filename): ...@@ -544,7 +544,12 @@ def loadFEATDesignFile(filename):
if line == '': if line == '':
continue continue
name, value = line.split(maxsplit=1) tokens = line.split(maxsplit=1)
if len(tokens) == 1:
name, value = tokens[0], ''
else:
name, value = tokens
fields[name] = value fields[name] = value
return fields return fields
......
...@@ -103,8 +103,9 @@ with the following commands: ...@@ -103,8 +103,9 @@ with the following commands:
""" """
import os.path as op import os.path as op
import numpy as np import textwrap as tw
import numpy as np
import pytest import pytest
...@@ -400,6 +401,45 @@ def test_loadDesignMat(): ...@@ -400,6 +401,45 @@ def test_loadDesignMat():
featdesign.loadDesignMat(badfile) featdesign.loadDesignMat(badfile)
# fsl/fslpy!469
def test_loadFEATDesignFile():
with tempdir():
with open('design1.con', 'wt') as f:
f.write(tw.dedent("""
/ContrastName1 mycontrast
/NumWaves 2
/NumContrasts 1
/Matrix
10 20
""").strip())
with open('design2.con', 'wt') as f:
f.write(tw.dedent("""
/ContrastName1
/NumWaves 2
/NumContrasts 1
/Matrix
10 20
""").strip())
des1 = featanalysis.loadFEATDesignFile('design1.con')
exp1 = {'ContrastName1': 'mycontrast',
'NumWaves': '2',
'NumContrasts': '1',
'Matrix': '10 20'}
des2 = featanalysis.loadFEATDesignFile('design2.con')
exp2 = {'ContrastName1': '',
'NumWaves': '2',
'NumContrasts': '1',
'Matrix': '10 20'}
assert des1 == exp1
assert des2 == exp2
def test_VoxelwiseEVs(): def test_VoxelwiseEVs():
with tempdir(): with tempdir():
img = tests.make_random_image('image.nii.gz', (10, 10, 10, 10)) img = tests.make_random_image('image.nii.gz', (10, 10, 10, 10))
......
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