6
6
7
7
def init_pepolar_wf (subject_id , dwi_meta , epi_fmaps ):
8
8
9
- dwi_file_pe = dwi_meta [" PhaseEncodingDirection" ]
9
+ dwi_file_pe = dwi_meta [' PhaseEncodingDirection' ]
10
10
11
11
file2dir = dict ()
12
12
@@ -23,22 +23,22 @@ def init_pepolar_wf(subject_id, dwi_meta, epi_fmaps):
23
23
24
24
if not usable_fieldmaps_opposite_pe :
25
25
raise Exception (
26
- " None of the discovered fieldmaps for "
27
- " participant {} has the right phase "
28
- " encoding direction" .format (subject_id )
26
+ ' None of the discovered fieldmaps for '
27
+ ' participant {} has the right phase '
28
+ ' encoding direction' .format (subject_id )
29
29
)
30
30
31
- wf = pe .Workflow (name = " pepolar_wf" )
31
+ wf = pe .Workflow (name = ' pepolar_wf' )
32
32
33
33
inputnode = pe .Node (
34
- niu .IdentityInterface (fields = [" b0_stripped" ]), name = " inputnode"
34
+ niu .IdentityInterface (fields = [' b0_stripped' ]), name = ' inputnode'
35
35
)
36
36
37
37
outputnode = pe .Node (
38
38
niu .IdentityInterface (
39
- fields = [" out_topup" , " out_movpar" , " out_fmap" , " out_enc_file" ]
39
+ fields = [' out_topup' , ' out_movpar' , ' out_fmap' , ' out_enc_file' ]
40
40
),
41
- name = " outputnode" ,
41
+ name = ' outputnode' ,
42
42
)
43
43
44
44
topup_wf = init_topup_wf ()
@@ -47,7 +47,7 @@ def init_pepolar_wf(subject_id, dwi_meta, epi_fmaps):
47
47
48
48
if not usable_fieldmaps_matching_pe :
49
49
wf .connect (
50
- [(inputnode , topup_wf , [(" b0_stripped" , " inputnode.epi_file" )])]
50
+ [(inputnode , topup_wf , [(' b0_stripped' , ' inputnode.epi_file' )])]
51
51
)
52
52
else :
53
53
topup_wf .inputs .inputnode .epi_file = usable_fieldmaps_matching_pe [0 ]
@@ -57,12 +57,12 @@ def init_pepolar_wf(subject_id, dwi_meta, epi_fmaps):
57
57
topup_wf .inputs .inputnode .altepi_file ,
58
58
]
59
59
dir_map = {
60
- "i" : "x" ,
61
- "i-" : "x-" ,
62
- "j" : "y" ,
63
- "j-" : "y-" ,
64
- "k" : "z" ,
65
- "k-" : "z-" ,
60
+ 'i' : 'x' ,
61
+ 'i-' : 'x-' ,
62
+ 'j' : 'y' ,
63
+ 'j-' : 'y-' ,
64
+ 'k' : 'z' ,
65
+ 'k-' : 'z-' ,
66
66
}
67
67
topup_wf .inputs .inputnode .encoding_directions = [
68
68
dir_map [file2dir [file ]] for file in epi_list
@@ -74,10 +74,10 @@ def init_pepolar_wf(subject_id, dwi_meta, epi_fmaps):
74
74
topup_wf ,
75
75
outputnode ,
76
76
[
77
- (" outputnode.out_fmap" , " out_fmap" ),
78
- (" outputnode.out_movpar" , " out_movpar" ),
79
- (" outputnode.out_base" , " out_topup" ),
80
- (" outputnode.out_enc_file" , " out_enc_file" ),
77
+ (' outputnode.out_fmap' , ' out_fmap' ),
78
+ (' outputnode.out_movpar' , ' out_movpar' ),
79
+ (' outputnode.out_base' , ' out_topup' ),
80
+ (' outputnode.out_enc_file' , ' out_enc_file' ),
81
81
],
82
82
)
83
83
]
@@ -87,43 +87,43 @@ def init_pepolar_wf(subject_id, dwi_meta, epi_fmaps):
87
87
88
88
89
89
def init_synb0_wf (subject_id , dwi_meta , synb0 ):
90
- dwi_file_pe = dwi_meta [" PhaseEncodingDirection" ]
90
+ dwi_file_pe = dwi_meta [' PhaseEncodingDirection' ]
91
91
92
92
file2dir = dict ()
93
93
94
94
usable_fieldmaps_matching_pe = []
95
95
usable_fieldmaps_opposite_pe = []
96
96
97
- wf = pe .Workflow (name = " synb0_wf" )
97
+ wf = pe .Workflow (name = ' synb0_wf' )
98
98
99
99
inputnode = pe .Node (
100
- niu .IdentityInterface (fields = [" b0_stripped" ]), name = " inputnode"
100
+ niu .IdentityInterface (fields = [' b0_stripped' ]), name = ' inputnode'
101
101
)
102
102
103
103
outputnode = pe .Node (
104
104
niu .IdentityInterface (
105
- fields = [" out_topup" , " out_movpar" , " out_fmap" , " out_enc_file" ]
105
+ fields = [' out_topup' , ' out_movpar' , ' out_fmap' , ' out_enc_file' ]
106
106
),
107
- name = " outputnode" ,
107
+ name = ' outputnode' ,
108
108
)
109
109
110
110
topup_wf = init_topup_wf (use_acqp = True )
111
111
topup_wf .inputs .inputnode .altepi_file = synb0
112
112
wf .add_nodes ([inputnode ])
113
113
wf .connect (
114
- [(inputnode , topup_wf , [(" b0_stripped" , " inputnode.epi_file" )])]
114
+ [(inputnode , topup_wf , [(' b0_stripped' , ' inputnode.epi_file' )])]
115
115
)
116
- topup_wf .inputs .inputnode .acqp = " /scratch/smansour/synb0_acqp.txt"
116
+ topup_wf .inputs .inputnode .acqp = ' /scratch/smansour/synb0_acqp.txt'
117
117
118
118
wf .connect (
119
119
[
120
120
(
121
121
topup_wf ,
122
122
outputnode ,
123
123
[
124
- (" outputnode.out_fmap" , " out_fmap" ),
125
- (" outputnode.out_movpar" , " out_movpar" ),
126
- (" outputnode.out_base" , " out_topup" ),
124
+ (' outputnode.out_fmap' , ' out_fmap' ),
125
+ (' outputnode.out_movpar' , ' out_movpar' ),
126
+ (' outputnode.out_base' , ' out_topup' ),
127
127
],
128
128
)
129
129
]
@@ -135,77 +135,77 @@ def init_synb0_wf(subject_id, dwi_meta, synb0):
135
135
def init_topup_wf (use_acqp = False ):
136
136
from ...interfaces import mrtrix3
137
137
138
- wf = pe .Workflow (name = " topup_wf" )
138
+ wf = pe .Workflow (name = ' topup_wf' )
139
139
140
140
inputnode = pe .Node (
141
141
niu .IdentityInterface (
142
142
fields = [
143
- " epi_file" ,
144
- " altepi_file" ,
145
- " encoding_directions" ,
146
- " topup_name" ,
147
- " acqp" ,
143
+ ' epi_file' ,
144
+ ' altepi_file' ,
145
+ ' encoding_directions' ,
146
+ ' topup_name' ,
147
+ ' acqp' ,
148
148
]
149
149
),
150
- name = " inputnode" ,
150
+ name = ' inputnode' ,
151
151
)
152
- inputnode .inputs .topup_name = " topup_base"
152
+ inputnode .inputs .topup_name = ' topup_base'
153
153
154
- epi_flirt = pe .Node (fsl .FLIRT (), name = " epi_flirt" )
154
+ epi_flirt = pe .Node (fsl .FLIRT (), name = ' epi_flirt' )
155
155
156
156
outputnode = pe .Node (
157
157
niu .IdentityInterface (
158
- fields = [" out_fmap" , " out_movpar" , " out_base" , " out_enc_file" ]
158
+ fields = [' out_fmap' , ' out_movpar' , ' out_base' , ' out_enc_file' ]
159
159
),
160
- name = " outputnode" ,
160
+ name = ' outputnode' ,
161
161
)
162
162
163
- list_merge = pe .Node (niu .Merge (numinputs = 2 ), name = " list_merge" )
163
+ list_merge = pe .Node (niu .Merge (numinputs = 2 ), name = ' list_merge' )
164
164
165
- merge = pe .Node (fsl .Merge (dimension = "t" ), name = " mergeAPPA" )
165
+ merge = pe .Node (fsl .Merge (dimension = 't' ), name = ' mergeAPPA' )
166
166
167
167
# Resize (make optional)
168
- resize = pe .Node (mrtrix3 .MRResize (voxel_size = [1 ]), name = " epi_resize" )
168
+ resize = pe .Node (mrtrix3 .MRResize (voxel_size = [1 ]), name = ' epi_resize' )
169
169
170
- topup = pe .Node (fsl .TOPUP (), name = " topup" )
170
+ topup = pe .Node (fsl .TOPUP (), name = ' topup' )
171
171
172
- get_base_movpar = lambda x : x .split (" _movpar.txt" )[0 ]
172
+ get_base_movpar = lambda x : x .split (' _movpar.txt' )[0 ]
173
173
174
174
if use_acqp :
175
- wf .connect ([(inputnode , topup , [(" acqp" , " encoding_file" )])])
175
+ wf .connect ([(inputnode , topup , [(' acqp' , ' encoding_file' )])])
176
176
else :
177
177
topup .inputs .readout_times = [0.05 , 0.05 ]
178
178
wf .connect (
179
179
[
180
180
(
181
181
inputnode ,
182
182
topup ,
183
- [(" encoding_directions" , " encoding_direction" )],
183
+ [(' encoding_directions' , ' encoding_direction' )],
184
184
)
185
185
]
186
186
)
187
187
188
188
wf .connect (
189
189
[
190
- (inputnode , list_merge , [(" epi_file" , " in1" )]),
190
+ (inputnode , list_merge , [(' epi_file' , ' in1' )]),
191
191
(
192
192
inputnode ,
193
193
epi_flirt ,
194
- [(" altepi_file" , " in_file" ), (" epi_file" , " reference" )],
194
+ [(' altepi_file' , ' in_file' ), (' epi_file' , ' reference' )],
195
195
),
196
- (epi_flirt , list_merge , [(" out_file" , " in2" )]),
197
- (list_merge , merge , [(" out" , " in_files" )]),
198
- # (merge, resize, [(" merged_file", " in_file" )]),
199
- # (resize, topup, [(" out_file", " in_file" )]),
200
- (merge , topup , [(" merged_file" , " in_file" )]),
196
+ (epi_flirt , list_merge , [(' out_file' , ' in2' )]),
197
+ (list_merge , merge , [(' out' , ' in_files' )]),
198
+ # (merge, resize, [(' merged_file', ' in_file' )]),
199
+ # (resize, topup, [(' out_file', ' in_file' )]),
200
+ (merge , topup , [(' merged_file' , ' in_file' )]),
201
201
(
202
202
topup ,
203
203
outputnode ,
204
204
[
205
- (" out_field" , " out_fmap" ),
206
- (" out_movpar" , " out_movpar" ),
207
- (" out_enc_file" , " out_enc_file" ),
208
- ((" out_movpar" , get_base_movpar ), " out_base" ),
205
+ (' out_field' , ' out_fmap' ),
206
+ (' out_movpar' , ' out_movpar' ),
207
+ (' out_enc_file' , ' out_enc_file' ),
208
+ ((' out_movpar' , get_base_movpar ), ' out_base' ),
209
209
],
210
210
),
211
211
]
0 commit comments