55
55
from .fit .registration import init_register_template_wf
56
56
from .outputs import (
57
57
init_anat_reports_wf ,
58
+ init_ds_anat_volumes_wf ,
59
+ init_ds_grayord_metrics_wf ,
58
60
init_ds_surface_metrics_wf ,
59
61
init_ds_surfaces_wf ,
60
62
init_ds_template_wf ,
64
66
init_ds_template_registration_wf ,
65
67
init_ds_fs_registration_wf ,
66
68
init_anat_second_derivatives_wf ,
69
+ init_template_iterator_wf ,
67
70
)
68
71
from .surfaces import (
69
72
init_anat_ribbon_wf ,
70
73
init_fsLR_reg_wf ,
71
74
init_gifti_morphometrics_wf ,
75
+ init_hcp_morphometrics_wf ,
72
76
init_gifti_surfaces_wf ,
77
+ init_morph_grayords_wf ,
73
78
init_msm_sulc_wf ,
74
79
init_surface_derivatives_wf ,
75
80
init_surface_recon_wf ,
76
81
init_refinement_wf ,
82
+ init_resample_midthickness_wf ,
77
83
)
78
84
79
85
LOGGER = logging .getLogger ("nipype.workflow" )
@@ -113,6 +119,8 @@ def init_anat_preproc_wf(
113
119
114
120
from niworkflows.utils.spaces import SpatialReferences, Reference
115
121
from smriprep.workflows.anatomical import init_anat_preproc_wf
122
+ spaces = SpatialReferences(spaces=['MNI152NLin2009cAsym', 'fsaverage5'])
123
+ spaces.checkpoint()
116
124
wf = init_anat_preproc_wf(
117
125
bids_root='.',
118
126
output_dir='.',
@@ -124,7 +132,7 @@ def init_anat_preproc_wf(
124
132
t2w=[],
125
133
skull_strip_mode='force',
126
134
skull_strip_template=Reference('OASIS30ANTs'),
127
- spaces=SpatialReferences( spaces=['MNI152NLin2009cAsym', 'fsaverage5']) ,
135
+ spaces=spaces,
128
136
precomputed={},
129
137
omp_nthreads=1,
130
138
)
@@ -261,14 +269,13 @@ def init_anat_preproc_wf(
261
269
omp_nthreads = omp_nthreads ,
262
270
skull_strip_fixed_seed = skull_strip_fixed_seed ,
263
271
)
264
- anat_second_derivatives_wf = init_anat_second_derivatives_wf (
272
+ template_iterator_wf = init_template_iterator_wf (spaces = spaces )
273
+ ds_std_volumes_wf = init_ds_anat_volumes_wf (
265
274
bids_root = bids_root ,
266
- freesurfer = freesurfer ,
267
275
output_dir = output_dir ,
268
- spaces = spaces ,
269
- cifti_output = cifti_output ,
276
+ name = "ds_std_volumes_wf" ,
270
277
)
271
- # fmt:off
278
+
272
279
workflow .connect ([
273
280
(inputnode , anat_fit_wf , [
274
281
("t1w" , "inputnode.t1w" ),
@@ -293,19 +300,32 @@ def init_anat_preproc_wf(
293
300
(f"outputnode.sphere_reg_{ 'msm' if msm_sulc else 'fsLR' } " , "sphere_reg_fsLR" ),
294
301
("outputnode.anat_ribbon" , "anat_ribbon" ),
295
302
]),
296
- (anat_fit_wf , anat_second_derivatives_wf , [
297
- ('outputnode.template' , 'inputnode.template' ),
303
+ (anat_fit_wf , template_iterator_wf , [
304
+ ("outputnode.template" , "inputnode.template" ),
305
+ ("outputnode.anat2std_xfm" , "inputnode.anat2std_xfm" ),
306
+ ]),
307
+ (anat_fit_wf , ds_std_volumes_wf , [
298
308
('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
299
309
("outputnode.t1w_preproc" , "inputnode.t1w_preproc" ),
300
310
("outputnode.t1w_mask" , "inputnode.t1w_mask" ),
301
311
("outputnode.t1w_dseg" , "inputnode.t1w_dseg" ),
302
312
("outputnode.t1w_tpms" , "inputnode.t1w_tpms" ),
303
- ('outputnode.anat2std_xfm' , 'inputnode.anat2std_xfm' ),
304
313
]),
305
- ])
306
- # fmt:on
307
- if freesurfer :
314
+ (template_iterator_wf , ds_std_volumes_wf , [
315
+ ("outputnode.std_t1w" , "inputnode.ref_file" ),
316
+ ("outputnode.anat2std_xfm" , "inputnode.anat2std_xfm" ),
317
+ ("outputnode.space" , "inputnode.space" ),
318
+ ("outputnode.cohort" , "inputnode.cohort" ),
319
+ ("outputnode.resolution" , "inputnode.resolution" ),
320
+ ]),
321
+ ]) # fmt:skip
308
322
323
+ if freesurfer :
324
+ anat_second_derivatives_wf = init_anat_second_derivatives_wf (
325
+ bids_root = bids_root ,
326
+ output_dir = output_dir ,
327
+ cifti_output = cifti_output ,
328
+ )
309
329
surface_derivatives_wf = init_surface_derivatives_wf (
310
330
cifti_output = cifti_output ,
311
331
)
@@ -316,7 +336,6 @@ def init_anat_preproc_wf(
316
336
bids_root = bids_root , output_dir = output_dir , metrics = ["curv" ], name = "ds_curv_wf"
317
337
)
318
338
319
- # fmt:off
320
339
workflow .connect ([
321
340
(anat_fit_wf , surface_derivatives_wf , [
322
341
('outputnode.t1w_preproc' , 'inputnode.reference' ),
@@ -336,18 +355,78 @@ def init_anat_preproc_wf(
336
355
(surface_derivatives_wf , ds_curv_wf , [
337
356
('outputnode.curv' , 'inputnode.curv' ),
338
357
]),
358
+ (anat_fit_wf , anat_second_derivatives_wf , [
359
+ ('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
360
+ ]),
339
361
(surface_derivatives_wf , anat_second_derivatives_wf , [
340
362
('outputnode.out_aseg' , 'inputnode.t1w_fs_aseg' ),
341
363
('outputnode.out_aparc' , 'inputnode.t1w_fs_aparc' ),
342
- ('outputnode.cifti_morph' , 'inputnode.cifti_morph' ),
343
- ('outputnode.cifti_metadata' , 'inputnode.cifti_metadata' ),
344
364
]),
345
365
(surface_derivatives_wf , outputnode , [
346
366
('outputnode.out_aseg' , 't1w_aseg' ),
347
367
('outputnode.out_aparc' , 't1w_aparc' ),
348
368
]),
349
- ])
350
- # fmt:on
369
+ ]) # fmt:skip
370
+
371
+ if cifti_output :
372
+ hcp_morphometrics_wf = init_hcp_morphometrics_wf (omp_nthreads = omp_nthreads )
373
+ resample_midthickness_wf = init_resample_midthickness_wf (grayord_density = cifti_output )
374
+ morph_grayords_wf = init_morph_grayords_wf (
375
+ grayord_density = cifti_output , omp_nthreads = omp_nthreads
376
+ )
377
+
378
+ ds_grayord_metrics_wf = init_ds_grayord_metrics_wf (
379
+ bids_root = bids_root ,
380
+ output_dir = output_dir ,
381
+ metrics = ['curv' , 'thickness' , 'sulc' ],
382
+ cifti_output = cifti_output ,
383
+ )
384
+
385
+ workflow .connect ([
386
+ (anat_fit_wf , hcp_morphometrics_wf , [
387
+ ('outputnode.subject_id' , 'inputnode.subject_id' ),
388
+ ('outputnode.sulc' , 'inputnode.sulc' ),
389
+ ('outputnode.thickness' , 'inputnode.thickness' ),
390
+ ('outputnode.midthickness' , 'inputnode.midthickness' ),
391
+ ]),
392
+ (surface_derivatives_wf , hcp_morphometrics_wf , [
393
+ ('outputnode.curv' , 'inputnode.curv' ),
394
+ ]),
395
+ (anat_fit_wf , resample_midthickness_wf , [
396
+ ('outputnode.midthickness' , 'inputnode.midthickness' ),
397
+ (
398
+ f"outputnode.sphere_reg_{ 'msm' if msm_sulc else 'fsLR' } " ,
399
+ "inputnode.sphere_reg_fsLR" ,
400
+ ),
401
+ ]),
402
+ (anat_fit_wf , morph_grayords_wf , [
403
+ ('outputnode.midthickness' , 'inputnode.midthickness' ),
404
+ (
405
+ f"outputnode.sphere_reg_{ 'msm' if msm_sulc else 'fsLR' } " ,
406
+ "inputnode.sphere_reg_fsLR" ,
407
+ ),
408
+ ]),
409
+ (hcp_morphometrics_wf , morph_grayords_wf , [
410
+ ('outputnode.curv' , 'inputnode.curv' ),
411
+ ('outputnode.sulc' , 'inputnode.sulc' ),
412
+ ('outputnode.thickness' , 'inputnode.thickness' ),
413
+ ('outputnode.roi' , 'inputnode.roi' ),
414
+ ]),
415
+ (resample_midthickness_wf , morph_grayords_wf , [
416
+ ('outputnode.midthickness_fsLR' , 'inputnode.midthickness_fsLR' ),
417
+ ]),
418
+ (anat_fit_wf , ds_grayord_metrics_wf , [
419
+ ('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
420
+ ]),
421
+ (morph_grayords_wf , ds_grayord_metrics_wf , [
422
+ ('outputnode.curv_fsLR' , 'inputnode.curv' ),
423
+ ('outputnode.curv_metadata' , 'inputnode.curv_metadata' ),
424
+ ('outputnode.thickness_fsLR' , 'inputnode.thickness' ),
425
+ ('outputnode.thickness_metadata' , 'inputnode.thickness_metadata' ),
426
+ ('outputnode.sulc_fsLR' , 'inputnode.sulc' ),
427
+ ('outputnode.sulc_metadata' , 'inputnode.sulc_metadata' ),
428
+ ]),
429
+ ]) # fmt:skip
351
430
352
431
return workflow
353
432
@@ -1264,7 +1343,7 @@ def init_anat_fit_wf(
1264
1343
# fmt:on
1265
1344
elif msm_sulc :
1266
1345
LOGGER .info ("ANAT Stage 10: Found pre-computed MSM-Sulc registration sphere" )
1267
- fsLR_buffer .inputs .sphere_reg_msm = sorted (precomputed ["sphere_reg_msm" ])
1346
+ msm_buffer .inputs .sphere_reg_msm = sorted (precomputed ["sphere_reg_msm" ])
1268
1347
else :
1269
1348
LOGGER .info ("ANAT Stage 10: MSM-Sulc disabled" )
1270
1349
0 commit comments