19
19
)
20
20
21
21
22
- def gen_subcortical_alignment_wf ( repetition_time , name = 'subcortical_alignment_wf ' ):
22
+ def init_subcortical_mni_alignment_wf ( * , repetition_time , name = 'subcortical_mni_alignment_wf ' ):
23
23
"""
24
24
Align individual subcortical structures into MNI space.
25
25
26
26
This is a nipype workflow port of the DCAN infant pipeline.
27
- https://github.com/DCAN-Labs/dcan-infant-pipeline/blob/247e19/fMRISurface/scripts/SubcorticalAlign_ROIs.sh
27
+ https://github.com/DCAN-Labs/dcan-infant-pipeline/ \
28
+ blob/247e19/fMRISurface/scripts/SubcorticalAlign_ROIs.sh
28
29
29
30
30
31
Parameters
@@ -67,7 +68,7 @@ def gen_subcortical_alignment_wf(repetition_time, name='subcortical_alignment_wf
67
68
split_atlas_rois = pe .Node (fsl .Split (dimension = "t" ), name = "split_atlas_rois" )
68
69
atlas_labels = pe .Node (VolumeLabelExportTable (label_map = 1 ), name = "atlas_labels" )
69
70
parse_labels = pe .Node (
70
- niu .Function (function = parse_roi_labels , output_names = ["structures" , "label_id " ]),
71
+ niu .Function (function = parse_roi_labels , output_names = ["structures" , "label_ids " ]),
71
72
name = "parse_labels" ,
72
73
)
73
74
@@ -85,22 +86,22 @@ def gen_subcortical_alignment_wf(repetition_time, name='subcortical_alignment_wf
85
86
)
86
87
applyxfm_roi = pe .MapNode (
87
88
fsl .ApplyXFM (interp = "spline" ),
88
- iterfield = ["reference" ],
89
+ iterfield = ["reference" , "in_matrix_file" ],
89
90
name = 'applyxfm_roi' ,
90
91
)
91
92
bold_mask_roi = pe .MapNode (
92
93
fsl .ApplyMask (),
93
- iterfield = ["in_file" , "operand_file " ],
94
+ iterfield = ["in_file" , "operand_value " ],
94
95
name = 'bold_mask_roi' ,
95
96
)
96
97
mul_roi = pe .MapNode (
97
98
fsl .BinaryMaths (operation = "mul" ),
98
- iterfield = ["in_file" , "operand_file " ],
99
+ iterfield = ["in_file" , "operand_value " ],
99
100
name = 'mul_roi' ,
100
101
)
101
102
mul_atlas_roi = pe .MapNode (
102
103
fsl .BinaryMaths (operation = "mul" ),
103
- iterfield = ["in_file" , "operand_file " ],
104
+ iterfield = ["in_file" , "operand_value " ],
104
105
name = 'mul_atlas_roi' ,
105
106
)
106
107
vol_label = pe .MapNode (
@@ -116,7 +117,7 @@ def gen_subcortical_alignment_wf(repetition_time, name='subcortical_alignment_wf
116
117
create_dtseries = pe .MapNode (
117
118
CiftiCreateDenseTimeseries (),
118
119
iterfield = ["volume_data" , "volume_structure_labels" ],
119
- name = 'create_dtseries'
120
+ name = 'create_dtseries' ,
120
121
)
121
122
create_label = pe .MapNode (
122
123
CiftiCreateLabel (),
@@ -151,9 +152,9 @@ def gen_subcortical_alignment_wf(repetition_time, name='subcortical_alignment_wf
151
152
)
152
153
153
154
fmt_vols = pe .Node (niu .Function (function = format_volume_rois ), name = 'fmt_vols' )
154
- create_dtseries = pe .Node (
155
+ create_dtseries_tmpl = pe .Node (
155
156
CiftiCreateDenseFromTemplate (series = True , series_step = repetition_time , series_start = 0 ),
156
- name = 'create_dtseries ' ,
157
+ name = 'create_dtseries_tmpl ' ,
157
158
)
158
159
fmt_agg_rois = pe .Node (
159
160
niu .Function (
@@ -162,7 +163,7 @@ def gen_subcortical_alignment_wf(repetition_time, name='subcortical_alignment_wf
162
163
),
163
164
name = 'fmt_agg_rois' ,
164
165
)
165
- agg_rois = pe .MapNode (fsl .MultiImageMaths (), name = 'agg_rois' )
166
+ agg_rois = pe .Node (fsl .MultiImageMaths (), name = 'agg_rois' )
166
167
final_vol = pe .Node (
167
168
CiftiSeparate (direction = "COLUMN" , volume_all_file = 'volume_all.nii.gz' ),
168
169
name = "final_vol"
@@ -186,14 +187,16 @@ def gen_subcortical_alignment_wf(repetition_time, name='subcortical_alignment_wf
186
187
(atlas_labels , parse_labels , [("out_file" , "label_file" )]),
187
188
# for loop across ROIs
188
189
(split_rois , roi2atlas , [("out_files" , "in_file" )]),
190
+ (split_atlas_rois , roi2atlas , [("out_files" , "reference" )]),
189
191
(inputnode , applyxfm_roi , [("bold_file" , "in_file" )]),
190
192
(split_atlas_rois , applyxfm_roi , [("out_files" , "reference" )]),
193
+ (roi2atlas , applyxfm_roi , [("out_matrix_file" , "in_matrix_file" )]),
191
194
(applyxfm_roi , bold_mask_roi , [("out_file" , "in_file" )]),
192
195
(roi2atlas , bold_mask_roi , [("out_file" , "mask_file" )]),
193
196
(roi2atlas , mul_roi , [("out_file" , "in_file" )]),
194
- (parse_labels , mul_roi , [("label_ids" , "operand_file " )]),
197
+ (parse_labels , mul_roi , [("label_ids" , "operand_value " )]),
195
198
(split_atlas_rois , mul_atlas_roi , [("out_files" , "in_file" )]),
196
- (parse_labels , mul_atlas_roi , [("label_ids" , "operand_file " )]),
199
+ (parse_labels , mul_atlas_roi , [("label_ids" , "operand_value " )]),
197
200
(mul_roi , vol_label , [("out_file" , "in_file" )]),
198
201
(atlas_labels , vol_label , [("out_file" , "label_list_file" )]),
199
202
(mul_atlas_roi , vol_atlas_label , [("out_file" , "in_file" )]),
@@ -211,17 +214,18 @@ def gen_subcortical_alignment_wf(repetition_time, name='subcortical_alignment_wf
211
214
# end loop
212
215
(parse_labels , fmt_vols , [("structures" , "structs" )]),
213
216
(separate , fmt_vols , [("volume_all_file" , "rois" )]),
214
- (create_dense , create_dtseries , [("out_file" , "in_file" )]),
215
- (fmt_vols , create_dtseries , [("out" , "volume" )]),
217
+ (create_dense , create_dtseries_tmpl , [("out_file" , "in_file" )]),
218
+ (fmt_vols , create_dtseries_tmpl , [("out" , "volume" )]),
216
219
(mul_roi , fmt_agg_rois , [("out_file" , "rois" )]),
217
220
(fmt_agg_rois , agg_rois , [
218
221
("first_image" , "in_file" ),
219
222
("op_files" , "operand_files" ),
220
223
("op_string" , "op_string" )]),
221
- (create_dtseries , final_vol , [("out_file" , "in_file" )]),
222
- (final_vol , outputnode , [("out_file " , "subcortical_file" )]),
224
+ (create_dtseries_tmpl , final_vol , [("out_file" , "in_file" )]),
225
+ (final_vol , outputnode , [("volume_all_file " , "subcortical_file" )]),
223
226
])
224
227
# fmt: on
228
+ return workflow
225
229
226
230
227
231
def parse_roi_labels (label_file ):
@@ -236,7 +240,7 @@ def parse_roi_labels(label_file):
236
240
>>> structs
237
241
['CEREBELLUM_LEFT', 'THALAMUS_LEFT', 'CAUDATE_LEFT']
238
242
>>> ids
239
- ['8', '10', '11' ]
243
+ [8, 10, 11 ]
240
244
"""
241
245
242
246
with open (label_file ) as fp :
@@ -248,7 +252,7 @@ def parse_roi_labels(label_file):
248
252
if idx % 2 == 0 :
249
253
structs .append (line .strip ())
250
254
else :
251
- label_ids .append (line .split (' ' , 1 )[0 ])
255
+ label_ids .append (int ( line .split (' ' , 1 )[0 ]) )
252
256
return structs , label_ids
253
257
254
258
@@ -273,4 +277,4 @@ def format_agg_rois(rois):
273
277
op_string
274
278
275
279
"""
276
- return rois [0 ], rois [1 :], "-add %s " * (len (rois ) - 1 ).strip ()
280
+ return rois [0 ], rois [1 :], ( "-add %s " * (len (rois ) - 1 ) ).strip ()
0 commit comments