@@ -152,7 +152,18 @@ def init_single_subject_wf(subject_id: str):
152
152
from niworkflows .utils .misc import fix_multi_T1w_source_name
153
153
from niworkflows .utils .spaces import Reference
154
154
from smriprep .workflows .anatomical import init_anat_fit_wf
155
- from smriprep .workflows .outputs import init_template_iterator_wf
155
+ from smriprep .workflows .outputs import (
156
+ init_ds_anat_volumes_wf ,
157
+ init_ds_grayord_metrics_wf ,
158
+ init_ds_surface_metrics_wf ,
159
+ init_template_iterator_wf ,
160
+ )
161
+ from smriprep .workflows .surfaces import (
162
+ init_gifti_morphometrics_wf ,
163
+ init_hcp_morphometrics_wf ,
164
+ init_morph_grayords_wf ,
165
+ init_resample_midthickness_wf ,
166
+ )
156
167
157
168
from fmriprep .workflows .bold .base import init_bold_wf
158
169
@@ -302,10 +313,14 @@ def init_single_subject_wf(subject_id: str):
302
313
run_without_submitting = True ,
303
314
)
304
315
316
+ bids_root = str (config .execution .bids_dir )
317
+ fmriprep_dir = str (config .execution .fmriprep_dir )
318
+ omp_nthreads = config .nipype .omp_nthreads
319
+
305
320
# Build the workflow
306
321
anat_fit_wf = init_anat_fit_wf (
307
- bids_root = str ( config . execution . bids_dir ) ,
308
- output_dir = str ( config . execution . fmriprep_dir ) ,
322
+ bids_root = bids_root ,
323
+ output_dir = fmriprep_dir ,
309
324
freesurfer = config .workflow .run_reconall ,
310
325
hires = config .workflow .hires ,
311
326
longitudinal = config .workflow .longitudinal ,
@@ -316,7 +331,7 @@ def init_single_subject_wf(subject_id: str):
316
331
skull_strip_template = Reference .from_string (config .workflow .skull_strip_template )[0 ],
317
332
spaces = spaces ,
318
333
precomputed = anatomical_cache ,
319
- omp_nthreads = config . nipype . omp_nthreads ,
334
+ omp_nthreads = omp_nthreads ,
320
335
sloppy = config .execution .sloppy ,
321
336
skull_strip_fixed_seed = config .workflow .skull_strip_fixed_seed ,
322
337
)
@@ -347,11 +362,30 @@ def init_single_subject_wf(subject_id: str):
347
362
if config .workflow .level == "full" :
348
363
if spaces .cached .get_spaces (nonstandard = False , dim = (3 ,)):
349
364
template_iterator_wf = init_template_iterator_wf (spaces = spaces )
365
+ ds_std_volumes_wf = init_ds_anat_volumes_wf (
366
+ bids_root = bids_root ,
367
+ output_dir = fmriprep_dir ,
368
+ name = "ds_std_volumes_wf" ,
369
+ )
350
370
workflow .connect ([
351
371
(anat_fit_wf , template_iterator_wf , [
352
372
('outputnode.template' , 'inputnode.template' ),
353
373
('outputnode.anat2std_xfm' , 'inputnode.anat2std_xfm' ),
354
374
]),
375
+ (anat_fit_wf , ds_std_volumes_wf , [
376
+ ('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
377
+ ("outputnode.t1w_preproc" , "inputnode.t1w_preproc" ),
378
+ ("outputnode.t1w_mask" , "inputnode.t1w_mask" ),
379
+ ("outputnode.t1w_dseg" , "inputnode.t1w_dseg" ),
380
+ ("outputnode.t1w_tpms" , "inputnode.t1w_tpms" ),
381
+ ]),
382
+ (template_iterator_wf , ds_std_volumes_wf , [
383
+ ("outputnode.std_t1w" , "inputnode.ref_file" ),
384
+ ("outputnode.anat2std_xfm" , "inputnode.anat2std_xfm" ),
385
+ ("outputnode.space" , "inputnode.space" ),
386
+ ("outputnode.cohort" , "inputnode.cohort" ),
387
+ ("outputnode.resolution" , "inputnode.resolution" ),
388
+ ]),
355
389
]) # fmt:skip
356
390
357
391
if 'MNI152NLin2009cAsym' in spaces .get_spaces ():
@@ -395,6 +429,73 @@ def init_single_subject_wf(subject_id: str):
395
429
]),
396
430
]) # fmt:skip
397
431
432
+ # Create CIFTI morphometrics
433
+ curv_wf = init_gifti_morphometrics_wf (morphometrics = ['curv' ], name = 'curv_wf' )
434
+ hcp_morphometrics_wf = init_hcp_morphometrics_wf (omp_nthreads = omp_nthreads )
435
+ morph_grayords_wf = init_morph_grayords_wf (
436
+ grayord_density = config .workflow .cifti_output ,
437
+ omp_nthreads = omp_nthreads ,
438
+ )
439
+ resample_midthickness_wf = init_resample_midthickness_wf (
440
+ grayord_density = config .workflow .cifti_output ,
441
+ )
442
+ ds_grayord_metrics_wf = init_ds_grayord_metrics_wf (
443
+ bids_root = bids_root ,
444
+ output_dir = fmriprep_dir ,
445
+ metrics = ["curv" , "thickness" , "sulc" ],
446
+ cifti_output = config .workflow .cifti_output ,
447
+ )
448
+
449
+ workflow .connect ([
450
+ (anat_fit_wf , curv_wf , [
451
+ ("outputnode.subject_id" , "inputnode.subject_id" ),
452
+ ("outputnode.subjects_dir" , "inputnode.subjects_dir" ),
453
+ ]),
454
+ (anat_fit_wf , hcp_morphometrics_wf , [
455
+ ("outputnode.subject_id" , "inputnode.subject_id" ),
456
+ ("outputnode.thickness" , "inputnode.thickness" ),
457
+ ("outputnode.sulc" , "inputnode.sulc" ),
458
+ ("outputnode.midthickness" , "inputnode.midthickness" ),
459
+ ]),
460
+ (curv_wf , hcp_morphometrics_wf , [
461
+ ("outputnode.curv" , "inputnode.curv" ),
462
+ ]),
463
+ (anat_fit_wf , resample_midthickness_wf , [
464
+ ('outputnode.midthickness' , 'inputnode.midthickness' ),
465
+ (
466
+ f"outputnode.sphere_reg_{ 'msm' if msm_sulc else 'fsLR' } " ,
467
+ "inputnode.sphere_reg_fsLR" ,
468
+ ),
469
+ ]),
470
+ (anat_fit_wf , morph_grayords_wf , [
471
+ ("outputnode.midthickness" , "inputnode.midthickness" ),
472
+ (
473
+ f'outputnode.sphere_reg_{ "msm" if msm_sulc else "fsLR" } ' ,
474
+ 'inputnode.sphere_reg_fsLR' ,
475
+ ),
476
+ ]),
477
+ (hcp_morphometrics_wf , morph_grayords_wf , [
478
+ ("outputnode.curv" , "inputnode.curv" ),
479
+ ("outputnode.thickness" , "inputnode.thickness" ),
480
+ ("outputnode.sulc" , "inputnode.sulc" ),
481
+ ("outputnode.roi" , "inputnode.roi" ),
482
+ ]),
483
+ (resample_midthickness_wf , morph_grayords_wf , [
484
+ ('outputnode.midthickness_fsLR' , 'inputnode.midthickness_fsLR' ),
485
+ ]),
486
+ (anat_fit_wf , ds_grayord_metrics_wf , [
487
+ ('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
488
+ ]),
489
+ (morph_grayords_wf , ds_grayord_metrics_wf , [
490
+ ("outputnode.curv_fsLR" , "inputnode.curv" ),
491
+ ("outputnode.curv_metadata" , "inputnode.curv_metadata" ),
492
+ ("outputnode.thickness_fsLR" , "inputnode.thickness" ),
493
+ ("outputnode.thickness_metadata" , "inputnode.thickness_metadata" ),
494
+ ("outputnode.sulc_fsLR" , "inputnode.sulc" ),
495
+ ("outputnode.sulc_metadata" , "inputnode.sulc_metadata" ),
496
+ ]),
497
+ ]) # fmt:skip
498
+
398
499
if config .workflow .anat_only :
399
500
return clean_datasinks (workflow )
400
501
@@ -421,8 +522,8 @@ def init_single_subject_wf(subject_id: str):
421
522
fmap_wf = init_fmap_preproc_wf (
422
523
debug = "fieldmaps" in config .execution .debug ,
423
524
estimators = fmap_estimators ,
424
- omp_nthreads = config . nipype . omp_nthreads ,
425
- output_dir = str ( config . execution . fmriprep_dir ) ,
525
+ omp_nthreads = omp_nthreads ,
526
+ output_dir = fmriprep_dir ,
426
527
subject = subject_id ,
427
528
)
428
529
fmap_wf .__desc__ = f"""
@@ -481,7 +582,7 @@ def init_single_subject_wf(subject_id: str):
481
582
s .metadata for s in estimator .sources if s .suffix in ("bold" , "sbref" )
482
583
]
483
584
syn_preprocessing_wf = init_syn_preprocessing_wf (
484
- omp_nthreads = config . nipype . omp_nthreads ,
585
+ omp_nthreads = omp_nthreads ,
485
586
debug = config .execution .sloppy ,
486
587
auto_bold_nss = True ,
487
588
t1w_inversion = False ,
@@ -561,7 +662,6 @@ def init_single_subject_wf(subject_id: str):
561
662
('outputnode.white' , 'inputnode.white' ),
562
663
('outputnode.pial' , 'inputnode.pial' ),
563
664
('outputnode.midthickness' , 'inputnode.midthickness' ),
564
- ('outputnode.thickness' , 'inputnode.thickness' ),
565
665
('outputnode.anat_ribbon' , 'inputnode.anat_ribbon' ),
566
666
(
567
667
f'outputnode.sphere_reg_{ "msm" if msm_sulc else "fsLR" } ' ,
@@ -609,6 +709,12 @@ def init_single_subject_wf(subject_id: str):
609
709
workflow .connect ([
610
710
(select_MNI6_xfm , bold_wf , [("anat2std_xfm" , "inputnode.anat2mni6_xfm" )]),
611
711
(select_MNI6_tpl , bold_wf , [("brain_mask" , "inputnode.mni6_mask" )]),
712
+ (hcp_morphometrics_wf , bold_wf , [
713
+ ("outputnode.roi" , "inputnode.cortex_mask" ),
714
+ ]),
715
+ (resample_midthickness_wf , bold_wf , [
716
+ ('outputnode.midthickness_fsLR' , 'inputnode.midthickness_fsLR' ),
717
+ ]),
612
718
]) # fmt:skip
613
719
614
720
return clean_datasinks (workflow )
0 commit comments