10
10
'ds001600' ,
11
11
'testdata' ,
12
12
])
13
- def test_workflow (bids_layouts , tmpdir , output_path , dataset , workdir ):
13
+ def test_phdiff (bids_layouts , tmpdir , output_path , dataset , workdir ):
14
14
"""Test creation of the workflow."""
15
15
tmpdir .chdir ()
16
16
17
+ extra_entities = {}
18
+ if dataset == 'ds001600' :
19
+ extra_entities ['acquisition' ] = 'v4'
20
+
17
21
data = bids_layouts [dataset ]
18
22
wf = Workflow (name = 'phdiff_%s' % dataset )
19
23
phdiff_wf = init_phdiff_wf (omp_nthreads = 2 )
20
24
phdiff_wf .inputs .inputnode .magnitude = data .get (
21
25
suffix = ['magnitude1' , 'magnitude2' ],
22
- acq = 'v4' ,
26
+ return_type = 'file' ,
27
+ extension = ['.nii' , '.nii.gz' ],
28
+ ** extra_entities )
29
+
30
+ phdiff_files = data .get (
31
+ suffix = 'phasediff' ,
32
+ extension = ['.nii' , '.nii.gz' ],
33
+ ** extra_entities )
34
+
35
+ phdiff_wf .inputs .inputnode .phasediff = [
36
+ (ph .path , ph .get_metadata ()) for ph in phdiff_files ]
37
+
38
+ if output_path :
39
+ from ...interfaces .reportlets import FieldmapReportlet
40
+ rep = pe .Node (FieldmapReportlet (reference_label = 'Magnitude' ), 'simple_report' )
41
+ rep .interface ._always_run = True
42
+
43
+ dsink = pe .Node (DerivativesDataSink (
44
+ base_directory = str (output_path ), keep_dtype = True ), name = 'dsink' )
45
+ dsink .interface .out_path_base = 'sdcflows'
46
+ dsink .inputs .source_file = phdiff_files [0 ].path
47
+
48
+ dsink_fmap = pe .Node (DerivativesDataSink (
49
+ base_directory = str (output_path ), keep_dtype = True ), name = 'dsink_fmap' )
50
+ dsink_fmap .interface .out_path_base = 'sdcflows'
51
+ dsink_fmap .inputs .source_file = phdiff_files [0 ].path
52
+
53
+ wf .connect ([
54
+ (phdiff_wf , rep , [
55
+ ('outputnode.fmap' , 'fieldmap' ),
56
+ ('outputnode.fmap_ref' , 'reference' ),
57
+ ('outputnode.fmap_mask' , 'mask' )]),
58
+ (rep , dsink , [('out_report' , 'in_file' )]),
59
+ (phdiff_wf , dsink_fmap , [('outputnode.fmap' , 'in_file' )]),
60
+ ])
61
+ else :
62
+ wf .add_nodes ([phdiff_wf ])
63
+
64
+ if workdir :
65
+ wf .base_dir = str (workdir )
66
+
67
+ wf .run ()
68
+
69
+
70
+ def test_phases (bids_layouts , tmpdir , output_path , workdir ):
71
+ """Test creation of the workflow."""
72
+ tmpdir .chdir ()
73
+
74
+ data = bids_layouts ['ds001600' ]
75
+ wf = Workflow (name = 'phases_ds001600' )
76
+ phdiff_wf = init_phdiff_wf (omp_nthreads = 2 )
77
+ phdiff_wf .inputs .inputnode .magnitude = data .get (
78
+ suffix = ['magnitude1' , 'magnitude2' ],
79
+ acquisition = 'v2' ,
23
80
return_type = 'file' ,
24
81
extension = ['.nii' , '.nii.gz' ])
25
82
26
- phdiff_files = data .get (suffix = 'phasediff ' , acq = 'v4 ' ,
83
+ phdiff_files = data .get (suffix = [ 'phase1 ' , 'phase2' ], acquisition = 'v2 ' ,
27
84
extension = ['.nii' , '.nii.gz' ])
28
85
29
86
phdiff_wf .inputs .inputnode .phasediff = [
@@ -39,12 +96,18 @@ def test_workflow(bids_layouts, tmpdir, output_path, dataset, workdir):
39
96
dsink .interface .out_path_base = 'sdcflows'
40
97
dsink .inputs .source_file = phdiff_files [0 ].path
41
98
99
+ dsink_fmap = pe .Node (DerivativesDataSink (
100
+ base_directory = str (output_path ), keep_dtype = True ), name = 'dsink_fmap' )
101
+ dsink_fmap .interface .out_path_base = 'sdcflows'
102
+ dsink_fmap .inputs .source_file = phdiff_files [0 ].path
103
+
42
104
wf .connect ([
43
105
(phdiff_wf , rep , [
44
106
('outputnode.fmap' , 'fieldmap' ),
45
107
('outputnode.fmap_ref' , 'reference' ),
46
108
('outputnode.fmap_mask' , 'mask' )]),
47
109
(rep , dsink , [('out_report' , 'in_file' )]),
110
+ (phdiff_wf , dsink_fmap , [('outputnode.fmap' , 'in_file' )]),
48
111
])
49
112
else :
50
113
wf .add_nodes ([phdiff_wf ])
0 commit comments