Skip to content

Commit

Permalink
[ENH] Use list of ints for manacc instead of comma-separated string (#…
Browse files Browse the repository at this point in the history
…598)

* Switch manacc to list from string.

* Update test.

* Fix that test.
  • Loading branch information
tsalo authored Sep 18, 2020
1 parent 150b5c0 commit 3374356
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion tedana/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ def test_integration_five_echo(skip_integration):
# Test re-running, but use the CLI
out_dir2 = '/tmp/data/five-echo/TED.five-echo-manual'
acc_comps = df.loc[df['classification'] == 'accepted'].index.values
acc_comps = [str(c) for c in acc_comps]
mixing = os.path.join(out_dir, 'ica_mixing.tsv')
t2smap = os.path.join(out_dir, 't2sv.nii.gz')
args = (['-d'] + datalist + ['-e'] + [str(te) for te in echo_times] +
['--out-dir', out_dir2, '--debug', '--verbose',
'--manacc', ','.join(acc_comps.astype(str)),
'--manacc', *acc_comps,
'--ctab', comptable, '--mix', mixing, '--t2smap', t2smap])
tedana_cli._main(args)

Expand Down
20 changes: 11 additions & 9 deletions tedana/workflows/tedana.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ def _get_parser():
default=None)
rerungrp.add_argument('--manacc',
dest='manacc',
help=('Comma separated list of manually '
'accepted components'),
metavar='INT',
type=int,
nargs='+',
help='List of manually accepted components.',
default=None)

return parser
Expand Down Expand Up @@ -286,10 +288,10 @@ def tedana_workflow(data, tes, out_dir='.', mask=None,
File containing component table from which to extract pre-computed
classifications, to be used with 'mixm' when re-running the workflow.
Default is None.
manacc : :obj:`list`, :obj:`str`, or None, optional
List of manually accepted components. Can be a list of the components,
a comma-separated string with component numbers, or None. Default is
None.
manacc : :obj:`list` of :obj:`int` or None, optional
List of manually accepted components. Can be a list of the components
numbers or None.
Default is None.
Other Parameters
----------------
Expand Down Expand Up @@ -420,15 +422,15 @@ def tedana_workflow(data, tes, out_dir='.', mask=None,
elif ctab is not None:
raise IOError('Argument "ctab" must be an existing file.')

if isinstance(manacc, str):
manacc = [int(comp) for comp in manacc.split(',')]

if ctab and not mixm:
LGR.warning('Argument "ctab" requires argument "mixm".')
ctab = None
elif manacc is not None and not mixm:
LGR.warning('Argument "manacc" requires argument "mixm".')
manacc = None
elif manacc is not None:
# coerce to list of integers
manacc = [int(m) for m in manacc]

if t2smap is not None and op.isfile(t2smap):
t2smap = op.abspath(t2smap)
Expand Down

0 comments on commit 3374356

Please sign in to comment.