Skip to content

Commit 30bcf28

Browse files
authored
Merge pull request #41 from ghisvail/fix/failing-tests
FIX: Integration tests for FNIRT and SUSAN
2 parents cb64566 + 0752bca commit 30bcf28

File tree

2 files changed

+27
-50
lines changed

2 files changed

+27
-50
lines changed

pydra/tasks/fsl/preprocess/fnirt.py

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@
4848
),
4949
(
5050
"fieldcoeff_file",
51-
ty.Any,
51+
str,
5252
{
5353
"help_string": "name of output file with field coefficients or true",
5454
"argstr": "--cout={fieldcoeff_file}",
55+
"output_file_template": "{in_file}_fieldwarp",
5556
},
5657
),
5758
(
@@ -65,31 +66,34 @@
6566
),
6667
(
6768
"field_file",
68-
ty.Any,
69+
str,
6970
{
7071
"help_string": "name of output file with field or true",
7172
"argstr": "--fout={field_file}",
73+
"output_file_template": "{in_file}_field",
7274
},
7375
),
7476
(
7577
"jacobian_file",
76-
ty.Any,
78+
str,
7779
{
7880
"help_string": "name of file for writing out the Jacobian of the field (for diagnostic or VBM purposes)",
7981
"argstr": "--jout={jacobian_file}",
82+
"output_file_template": "{in_file}_field_jacobian",
8083
},
8184
),
8285
(
8386
"modulatedref_file",
84-
ty.Any,
87+
str,
8588
{
8689
"help_string": "name of file for writing out intensity modulated --ref (for diagnostic purposes)",
8790
"argstr": "--refout={modulatedref_file}",
91+
"output_file_template": "{in_file}_modulated",
8892
},
8993
),
9094
(
9195
"out_intensitymap_file",
92-
ty.Any,
96+
str,
9397
{
9498
"help_string": "name of files for writing information pertaining to intensity mapping",
9599
"argstr": "--intout={out_intensitymap_file}",
@@ -353,50 +357,7 @@
353357
]
354358
FNIRT_input_spec = specs.SpecInfo(name="Input", fields=input_fields, bases=(specs.ShellSpec,))
355359

356-
output_fields = [
357-
(
358-
"fieldcoeff_file",
359-
specs.File,
360-
{
361-
"help_string": "file with field coefficients",
362-
"requires": ["in_file"],
363-
"output_file_template": "{in_file}_fieldwarp",
364-
},
365-
),
366-
(
367-
"field_file",
368-
specs.File,
369-
{
370-
"help_string": "file with warp field",
371-
"requires": ["in_file"],
372-
"output_file_template": "{in_file}_field",
373-
},
374-
),
375-
(
376-
"jacobian_file",
377-
specs.File,
378-
{
379-
"help_string": "file containing Jacobian of the field",
380-
"requires": ["in_file"],
381-
"output_file_template": "{in_file}_field_jacobian",
382-
},
383-
),
384-
(
385-
"modulatedref_file",
386-
specs.File,
387-
{
388-
"help_string": "file containing intensity modulated --ref",
389-
"requires": ["in_file"],
390-
"output_file_template": "{in_file}_modulated",
391-
},
392-
),
393-
]
394-
FNIRT_output_spec = specs.SpecInfo(
395-
name="Output", fields=output_fields, bases=(specs.ShellOutSpec,)
396-
)
397-
398360

399361
class FNIRT(ShellCommandTask):
400362
input_spec = FNIRT_input_spec
401-
output_spec = FNIRT_output_spec
402363
executable = "fnirt"

pydra/tasks/fsl/preprocess/susan.py

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

5+
6+
def format_usans(field: ty.Sequence[ty.Tuple[str, float]]) -> 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+
return " ".join([f"{len(field)}"] + [f"{usan} {bt}" for usan, bt in field])
19+
20+
521
input_fields = [
622
(
723
"in_file",
@@ -55,11 +71,11 @@
5571
),
5672
(
5773
"usans",
58-
list,
74+
ty.Sequence[ty.Tuple[str, float]],
5975
[],
6076
{
6177
"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": "",
78+
"formatter": format_usans,
6379
"position": 6,
6480
},
6581
),

0 commit comments

Comments
 (0)