Skip to content

Commit 64fe757

Browse files
author
oliver-contier
committed
changed if clause structure to account for case when single file name is given
1 parent 5f15479 commit 64fe757

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

nipype/workflows/fmri/fsl/preprocess.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,25 @@ def getthreshop(thresh):
1818
return ['-thr %.10f -Tmin -bin' % (0.1 * val[1]) for val in thresh]
1919

2020

21-
2221
def pickrun(files, whichrun):
2322
"""pick file from list of files"""
2423

2524
filemap = {'first': 0, 'last': -1, 'middle': len(files) // 2}
2625

27-
if isinstance(whichrun, str):
28-
if whichrun not in filemap.keys():
29-
raise(KeyError, 'Sorry, whichrun must be either integer index'
30-
'or string in form of "first", "last" or "middle')
31-
else:
32-
return files[filemap[whichrun]]
33-
3426
if isinstance(files, list):
35-
return files[whichrun]
27+
28+
# whichrun is given as integer
29+
if isinstance(whichrun, int):
30+
return files[whichrun]
31+
# whichrun is given as string
32+
elif isinstance(whichrun, str):
33+
if whichrun not in filemap.keys():
34+
raise(KeyError, 'Sorry, whichrun must be either integer index'
35+
'or string in form of "first", "last" or "middle')
36+
else:
37+
return files[filemap[whichrun]]
3638
else:
39+
# in case single file name is given
3740
return files
3841

3942

0 commit comments

Comments
 (0)