@@ -152,7 +152,17 @@ 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
+ )
156
166
157
167
from fmriprep .workflows .bold .base import init_bold_wf
158
168
@@ -302,10 +312,14 @@ def init_single_subject_wf(subject_id: str):
302
312
run_without_submitting = True ,
303
313
)
304
314
315
+ bids_root = str (config .execution .bids_dir )
316
+ fmriprep_dir = str (config .execution .fmriprep_dir )
317
+ omp_nthreads = config .nipype .omp_nthreads
318
+
305
319
# Build the workflow
306
320
anat_fit_wf = init_anat_fit_wf (
307
- bids_root = str ( config . execution . bids_dir ) ,
308
- output_dir = str ( config . execution . fmriprep_dir ) ,
321
+ bids_root = bids_root ,
322
+ output_dir = fmriprep_dir ,
309
323
freesurfer = config .workflow .run_reconall ,
310
324
hires = config .workflow .hires ,
311
325
longitudinal = config .workflow .longitudinal ,
@@ -316,7 +330,7 @@ def init_single_subject_wf(subject_id: str):
316
330
skull_strip_template = Reference .from_string (config .workflow .skull_strip_template )[0 ],
317
331
spaces = spaces ,
318
332
precomputed = anatomical_cache ,
319
- omp_nthreads = config . nipype . omp_nthreads ,
333
+ omp_nthreads = omp_nthreads ,
320
334
sloppy = config .execution .sloppy ,
321
335
skull_strip_fixed_seed = config .workflow .skull_strip_fixed_seed ,
322
336
)
@@ -347,11 +361,30 @@ def init_single_subject_wf(subject_id: str):
347
361
if config .workflow .level == "full" :
348
362
if spaces .cached .get_spaces (nonstandard = False , dim = (3 ,)):
349
363
template_iterator_wf = init_template_iterator_wf (spaces = spaces )
364
+ ds_std_volumes_wf = init_ds_anat_volumes_wf (
365
+ bids_root = bids_root ,
366
+ output_dir = fmriprep_dir ,
367
+ name = "ds_std_volumes_wf" ,
368
+ )
350
369
workflow .connect ([
351
370
(anat_fit_wf , template_iterator_wf , [
352
371
('outputnode.template' , 'inputnode.template' ),
353
372
('outputnode.anat2std_xfm' , 'inputnode.anat2std_xfm' ),
354
373
]),
374
+ (anat_fit_wf , ds_std_volumes_wf , [
375
+ ('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
376
+ ("outputnode.t1w_preproc" , "inputnode.t1w_preproc" ),
377
+ ("outputnode.t1w_mask" , "inputnode.t1w_mask" ),
378
+ ("outputnode.t1w_dseg" , "inputnode.t1w_dseg" ),
379
+ ("outputnode.t1w_tpms" , "inputnode.t1w_tpms" ),
380
+ ]),
381
+ (template_iterator_wf , ds_std_volumes_wf , [
382
+ ("outputnode.std_t1w" , "inputnode.ref_file" ),
383
+ ("outputnode.anat2std_xfm" , "inputnode.anat2std_xfm" ),
384
+ ("outputnode.space" , "inputnode.space" ),
385
+ ("outputnode.cohort" , "inputnode.cohort" ),
386
+ ("outputnode.resolution" , "inputnode.resolution" ),
387
+ ]),
355
388
]) # fmt:skip
356
389
357
390
if 'MNI152NLin2009cAsym' in spaces .get_spaces ():
@@ -395,6 +428,60 @@ def init_single_subject_wf(subject_id: str):
395
428
]),
396
429
]) # fmt:skip
397
430
431
+ # Create CIFTI morphometrics
432
+ curv_wf = init_gifti_morphometrics_wf (morphometrics = ['curv' ], name = 'curv_wf' )
433
+ hcp_morphometrics_wf = init_hcp_morphometrics_wf (omp_nthreads = omp_nthreads )
434
+ morph_grayords_wf = init_morph_grayords_wf (
435
+ grayord_density = config .workflow .cifti_output ,
436
+ omp_nthreads = omp_nthreads ,
437
+ )
438
+ ds_grayord_metrics_wf = init_ds_grayord_metrics_wf (
439
+ bids_root = bids_root ,
440
+ output_dir = fmriprep_dir ,
441
+ metrics = ["curv" , "thickness" , "sulc" ],
442
+ cifti_output = config .workflow .cifti_output ,
443
+ )
444
+
445
+ workflow .connect ([
446
+ (anat_fit_wf , curv_wf , [
447
+ ("outputnode.subject_id" , "inputnode.subject_id" ),
448
+ ("outputnode.subjects_dir" , "inputnode.subjects_dir" ),
449
+ ]),
450
+ (anat_fit_wf , hcp_morphometrics_wf , [
451
+ ("outputnode.subject_id" , "inputnode.subject_id" ),
452
+ ("outputnode.thickness" , "inputnode.thickness" ),
453
+ ("outputnode.sulc" , "inputnode.sulc" ),
454
+ ("outputnode.midthickness" , "inputnode.midthickness" ),
455
+ ]),
456
+ (curv_wf , hcp_morphometrics_wf , [
457
+ ("outputnode.curv" , "inputnode.curv" ),
458
+ ]),
459
+ (anat_fit_wf , morph_grayords_wf , [
460
+ ("outputnode.midthickness" , "inputnode.midthickness" ),
461
+ (
462
+ f'outputnode.sphere_reg_{ "msm" if msm_sulc else "fsLR" } ' ,
463
+ 'inputnode.sphere_reg_fsLR' ,
464
+ ),
465
+ ]),
466
+ (hcp_morphometrics_wf , morph_grayords_wf , [
467
+ ("outputnode.curv" , "inputnode.curv" ),
468
+ ("outputnode.thickness" , "inputnode.thickness" ),
469
+ ("outputnode.sulc" , "inputnode.sulc" ),
470
+ ("outputnode.roi" , "inputnode.roi" ),
471
+ ]),
472
+ (anat_fit_wf , ds_grayord_metrics_wf , [
473
+ ('outputnode.t1w_valid_list' , 'inputnode.source_files' ),
474
+ ]),
475
+ (morph_grayords_wf , ds_grayord_metrics_wf , [
476
+ ("outputnode.curv_fsLR" , "inputnode.curv" ),
477
+ ("outputnode.curv_metadata" , "inputnode.curv_metadata" ),
478
+ ("outputnode.thickness_fsLR" , "inputnode.thickness" ),
479
+ ("outputnode.thickness_metadata" , "inputnode.thickness_metadata" ),
480
+ ("outputnode.sulc_fsLR" , "inputnode.sulc" ),
481
+ ("outputnode.sulc_metadata" , "inputnode.sulc_metadata" ),
482
+ ]),
483
+ ]) # fmt:skip
484
+
398
485
if config .workflow .anat_only :
399
486
return clean_datasinks (workflow )
400
487
@@ -421,8 +508,8 @@ def init_single_subject_wf(subject_id: str):
421
508
fmap_wf = init_fmap_preproc_wf (
422
509
debug = "fieldmaps" in config .execution .debug ,
423
510
estimators = fmap_estimators ,
424
- omp_nthreads = config . nipype . omp_nthreads ,
425
- output_dir = str ( config . execution . fmriprep_dir ) ,
511
+ omp_nthreads = omp_nthreads ,
512
+ output_dir = fmriprep_dir ,
426
513
subject = subject_id ,
427
514
)
428
515
fmap_wf .__desc__ = f"""
@@ -481,7 +568,7 @@ def init_single_subject_wf(subject_id: str):
481
568
s .metadata for s in estimator .sources if s .suffix in ("bold" , "sbref" )
482
569
]
483
570
syn_preprocessing_wf = init_syn_preprocessing_wf (
484
- omp_nthreads = config . nipype . omp_nthreads ,
571
+ omp_nthreads = omp_nthreads ,
485
572
debug = config .execution .sloppy ,
486
573
auto_bold_nss = True ,
487
574
t1w_inversion = False ,
0 commit comments