@@ -249,6 +249,7 @@ def init_anat_derivatives_wf(
249
249
num_t1w ,
250
250
output_dir ,
251
251
spaces ,
252
+ cifti_output ,
252
253
name = "anat_derivatives_wf" ,
253
254
tpm_labels = BIDS_TISSUE_ORDER ,
254
255
):
@@ -314,6 +315,12 @@ def init_anat_derivatives_wf(
314
315
List of input T2w images
315
316
t2w_preproc
316
317
The T2w image in T1w space.
318
+ cifti_morph
319
+ Morphometric CIFTI-2 dscalar files
320
+ cifti_density
321
+ Grayordinate density
322
+ cifti_metadata
323
+ JSON files containing metadata dictionaries
317
324
"""
318
325
from niworkflows .interfaces .nibabel import ApplyMask
319
326
from niworkflows .interfaces .utility import KeySelect
@@ -347,6 +354,9 @@ def init_anat_derivatives_wf(
347
354
"t1w_fs_aparc" ,
348
355
"t2w_source_files" ,
349
356
"t2w_preproc" ,
357
+ "cifti_metadata" ,
358
+ "cifti_density" ,
359
+ "cifti_morph" ,
350
360
]
351
361
),
352
362
name = "inputnode" ,
@@ -706,6 +716,26 @@ def init_anat_derivatives_wf(
706
716
('source_files' , 'source_file' )]),
707
717
])
708
718
# fmt: on
719
+ if cifti_output :
720
+ ds_cifti_morph = pe .MapNode (
721
+ DerivativesDataSink (
722
+ base_directory = output_dir ,
723
+ suffix = ['curv' , 'sulc' , 'thickness' ],
724
+ compress = False ,
725
+ space = 'fsLR' ,
726
+ ),
727
+ name = 'ds_cifti_morph' ,
728
+ run_without_submitting = True ,
729
+ iterfield = ["in_file" , "meta_dict" , "suffix" ],
730
+ )
731
+ # fmt:off
732
+ workflow .connect ([
733
+ (inputnode , ds_cifti_morph , [('cifti_morph' , 'in_file' ),
734
+ ('source_files' , 'source_file' ),
735
+ ('cifti_density' , 'density' ),
736
+ (('cifti_metadata' , _read_jsons ), 'meta_dict' )])
737
+ ])
738
+ # fmt:on
709
739
return workflow
710
740
711
741
@@ -718,3 +748,9 @@ def _set_tpl_res(space, resolution):
718
748
return int (resolution )
719
749
except ValueError :
720
750
return 1
751
+
752
+ def _read_jsons (in_file ):
753
+ from json import loads
754
+ from pathlib import Path
755
+
756
+ return [loads (Path (f ).read_text ()) for f in in_file ]
0 commit comments