@@ -166,11 +166,64 @@ def select_target(subject_id, space):
166
166
)
167
167
sampler .inputs .hemi = ["lh" , "rh" ]
168
168
169
+ update_metadata = pe .MapNode (
170
+ GiftiSetAnatomicalStructure (),
171
+ iterfield = ["in_file" ],
172
+ name = "update_metadata" ,
173
+ mem_gb = DEFAULT_MEMORY_MIN_GB ,
174
+ )
175
+
176
+ joinnode = pe .JoinNode (
177
+ niu .IdentityInterface (fields = ["surfaces" , "target" ]),
178
+ joinsource = "itersource" ,
179
+ name = "joinnode" ,
180
+ )
181
+
182
+ outputnode = pe .Node (
183
+ niu .IdentityInterface (fields = ["surfaces" , "target" , "goodvoxels_ribbon" ]),
184
+ name = "outputnode" ,
185
+ )
186
+
187
+ # fmt: off
188
+ workflow .connect ([
189
+ (inputnode , get_fsnative , [
190
+ ("subject_id" , "subject_id" ),
191
+ ("subjects_dir" , "subjects_dir" )
192
+ ]),
193
+ (inputnode , targets , [("subject_id" , "subject_id" )]),
194
+ (inputnode , itk2lta , [
195
+ ("source_file" , "src_file" ),
196
+ ("t1w2fsnative_xfm" , "in_file" ),
197
+ ]),
198
+ (get_fsnative , itk2lta , [("T1" , "dst_file" )]),
199
+ (inputnode , sampler , [
200
+ ("subjects_dir" , "subjects_dir" ),
201
+ ("subject_id" , "subject_id" ),
202
+ ]),
203
+ (itersource , targets , [("target" , "space" )]),
204
+ (itersource , rename_src , [("target" , "subject" )]),
205
+ (rename_src , sampler , [("out_file" , "source_file" )]),
206
+ (itk2lta , sampler , [("out" , "reg_file" )]),
207
+ (targets , sampler , [("out" , "target_subject" )]),
208
+ (update_metadata , joinnode , [("out_file" , "surfaces" )]),
209
+ (itersource , joinnode , [("target" , "target" )]),
210
+ (joinnode , outputnode , [
211
+ ("surfaces" , "surfaces" ),
212
+ ("target" , "target" ),
213
+ ]),
214
+ ])
215
+ # fmt: on
216
+
217
+ # At this point, rename_src.in_file and update_metadata.in_file need connecting
218
+ #
219
+ # These depend on two optional steps: goodvoxel projection and medial wall nan replacment
220
+ #
221
+ # inputnode -> optional(goodvoxels_bold_mask_wf) -> rename_src
222
+ # sampler -> optional(metric_dilate) -> optional(medial_nans) -> update_metadata
223
+ #
224
+
169
225
metric_dilate = pe .MapNode (
170
- MetricDilate (
171
- distance = 10 ,
172
- nearest = True ,
173
- ),
226
+ MetricDilate (distance = 10 , nearest = True ),
174
227
iterfield = ["in_file" , "surf_file" ],
175
228
name = "metric_dilate" ,
176
229
mem_gb = mem_gb * 3 ,
@@ -193,107 +246,41 @@ def select_target(subject_id, space):
193
246
MedialNaNs (), iterfield = ["in_file" ], name = "medial_nans" , mem_gb = DEFAULT_MEMORY_MIN_GB
194
247
)
195
248
196
- # Rename the source file to the output space to simplify naming later
197
- prepend_hemi = pe .MapNode (
198
- niu .Rename (format_string = "%(hemi)s.target.func.gii" ),
199
- iterfield = ["in_file" , "hemi" ],
200
- name = "prepend_hemi" ,
201
- mem_gb = DEFAULT_MEMORY_MIN_GB ,
202
- run_without_submitting = True ,
203
- )
204
- prepend_hemi .inputs .hemi = ["lh" , "rh" ]
205
-
206
- update_metadata = pe .MapNode (
207
- GiftiSetAnatomicalStructure (),
208
- iterfield = ["in_file" ],
209
- name = "update_metadata" ,
210
- mem_gb = DEFAULT_MEMORY_MIN_GB ,
211
- run_without_submitting = True ,
212
- )
213
-
214
- outputnode = pe .JoinNode (
215
- niu .IdentityInterface (fields = ["surfaces" , "target" , "goodvoxels_ribbon" ]),
216
- joinsource = "itersource" ,
217
- name = "outputnode" ,
218
- run_without_submitting = True ,
219
- )
220
-
221
249
if project_goodvoxels :
222
250
goodvoxels_bold_mask_wf = init_goodvoxels_bold_mask_wf (mem_gb )
223
251
224
252
# fmt: off
225
253
workflow .connect ([
226
- (inputnode , goodvoxels_bold_mask_wf , [("source_file" , "inputnode.bold_file" ),
227
- ("anat_ribbon" , "inputnode.anat_ribbon" )]),
254
+ (inputnode , goodvoxels_bold_mask_wf , [
255
+ ("source_file" , "inputnode.bold_file" ),
256
+ ("anat_ribbon" , "inputnode.anat_ribbon" ),
257
+ ]),
228
258
(goodvoxels_bold_mask_wf , rename_src , [("outputnode.masked_bold" , "in_file" )]),
229
- (goodvoxels_bold_mask_wf , outputnode , [("outputnode.goodvoxels_ribbon" ,
230
- "goodvoxels_ribbon" )]),
259
+ (goodvoxels_bold_mask_wf , outputnode , [
260
+ ("outputnode.goodvoxels_ribbon" , "goodvoxels_ribbon" ),
261
+ ]),
262
+ (sampler , metric_dilate , [("out_file" , "in_file" )]),
231
263
])
232
264
# fmt: on
233
265
else :
266
+ workflow .connect (inputnode , "source_file" , rename_src , "in_file" )
267
+
268
+ if medial_surface_nan :
234
269
# fmt: off
235
270
workflow .connect ([
236
- (inputnode , rename_src , [("source_file" , "in_file" )]),
271
+ (inputnode , medial_nans , [("subjects_dir" , "subjects_dir" )]),
272
+ (medial_nans , update_metadata , [("out_file" , "in_file" )]),
237
273
])
238
274
# fmt: on
239
275
240
- # fmt: off
241
- workflow .connect (
242
- [
243
- (
244
- inputnode ,
245
- get_fsnative ,
246
- [("subject_id" , "subject_id" ), ("subjects_dir" , "subjects_dir" )],
247
- ),
248
- (inputnode , targets , [("subject_id" , "subject_id" )]),
249
- (inputnode , itk2lta , [("source_file" , "src_file" ), ("t1w2fsnative_xfm" , "in_file" )]),
250
- (get_fsnative , itk2lta , [("brain" , "dst_file" )]), # InfantFS: Use brain instead of T1
251
- (inputnode , sampler , [("subjects_dir" , "subjects_dir" ), ("subject_id" , "subject_id" )]),
252
- (itersource , targets , [("target" , "space" )]),
253
- (itersource , rename_src , [("target" , "subject" )]),
254
- (rename_src , sampler , [("out_file" , "source_file" )]),
255
- (itk2lta , sampler , [("out" , "reg_file" )]),
256
- (targets , sampler , [("out" , "target_subject" )]),
257
- (update_metadata , outputnode , [("out_file" , "surfaces" )]),
258
- (itersource , outputnode , [("target" , "target" )]),
259
- ]
260
- )
261
- # fmt: on
262
-
263
- if medial_surface_nan :
264
- if project_goodvoxels :
265
- # fmt: off
266
- workflow .connect ([
267
- (inputnode , medial_nans , [("subjects_dir" , "subjects_dir" )]),
268
- (sampler , metric_dilate , [("out_file" , "in_file" )]),
269
- (metric_dilate , medial_nans , [("out_file" , "in_file" )]),
270
- (medial_nans , update_metadata , [("out_file" , "in_file" )]),
271
- ])
272
- # fmt: on
273
- else :
274
- # fmt: off
275
- workflow .connect ([
276
- (inputnode , medial_nans , [("subjects_dir" , "subjects_dir" )]),
277
- (sampler , medial_nans , [("out_file" , "in_file" )]),
278
- (medial_nans , update_metadata , [("out_file" , "in_file" )]),
279
- ])
280
- # fmt: on
281
-
276
+ if medial_surface_nan and project_goodvoxels :
277
+ workflow .connect (metric_dilate , "out_file" , medial_nans , "in_file" )
278
+ elif medial_surface_nan :
279
+ workflow .connect (sampler , "out_file" , medial_nans , "in_file" )
280
+ elif project_goodvoxels :
281
+ workflow .connect (metric_dilate , "out_file" , update_metadata , "in_file" )
282
282
else :
283
- if project_goodvoxels :
284
- # fmt: off
285
- workflow .connect ([
286
- (sampler , metric_dilate , [("out_file" , "in_file" )]),
287
- (metric_dilate , update_metadata , [("out_file" , "in_file" )]),
288
- ])
289
- # fmt: on
290
- else :
291
- # fmt: off
292
- workflow .connect ([
293
- (sampler , update_metadata , [("out_file" , "in_file" )]),
294
- ])
295
- # fmt: on
296
-
283
+ workflow .connect (sampler , "out_file" , update_metadata , "in_file" )
297
284
return workflow
298
285
299
286
0 commit comments