Skip to content

Commit 8c139bf

Browse files
committed
FIX: SUSAN: Add formatter for usans argument
1 parent 2ffa915 commit 8c139bf

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

pydra/tasks/fsl/preprocess/susan.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22
from pydra import ShellCommandTask
33
import typing as ty
44

5+
6+
def format_usans(field: ty.Sequence[ty.Tuple[str, float]] = None) -> str:
7+
"""Format usans argument to its appropriate argstr.
8+
9+
Examples
10+
--------
11+
>>> format_usans([])
12+
'0'
13+
>>> format_usans([('/path/to/file', 2.5)])
14+
'1 /path/to/file 2.5'
15+
>>> format_usans([('/path/to/file1', 10.5), ('/path/to/file2', 22.1)])
16+
'2 /path/to/file1 10.5 /path/to/file2 22.1'
17+
"""
18+
try:
19+
n_usans = len(field)
20+
except TypeError:
21+
n_usans = 0
22+
23+
if n_usans > 0:
24+
usan_bt = " ".join([f"{usan} {bt}" for usan, bt in field])
25+
return f"{n_usans} {usan_bt}"
26+
else:
27+
return f"{n_usans}"
28+
29+
530
input_fields = [
631
(
732
"in_file",
@@ -54,12 +79,12 @@
5479
},
5580
),
5681
(
57-
"n_usans",
58-
int,
59-
0,
82+
"usans",
83+
ty.Sequence[ty.Tuple[str, float]],
84+
[],
6085
{
6186
"help_string": "determines whether the smoothing area (USAN) is to be found from secondary images (0, 1 or 2). A negative value for any brightness threshold will auto-set the threshold at 10% of the robust range",
62-
"argstr": "{n_usans}",
87+
"formatter": format_usans,
6388
"position": 6,
6489
},
6590
),

0 commit comments

Comments
 (0)