@@ -558,7 +558,8 @@ def init_bold_wf(
558
558
]),
559
559
]) # fmt:skip
560
560
561
- if config .workflow .cifti_output :
561
+ cifti_output = config .workflow .cifti_output
562
+ if cifti_output :
562
563
from niworkflows .interfaces .fixes import FixHeaderApplyTransforms as ApplyTransforms
563
564
564
565
from nibabies .workflows .bold .alignment import (
@@ -581,7 +582,7 @@ def init_bold_wf(
581
582
)
582
583
583
584
bold_fsLR_resampling_wf = init_bold_fsLR_resampling_wf (
584
- grayord_density = config . workflow . cifti_output ,
585
+ grayord_density = cifti_output ,
585
586
omp_nthreads = omp_nthreads ,
586
587
mem_gb = mem_gb ['resampled' ],
587
588
)
@@ -615,7 +616,7 @@ def init_bold_wf(
615
616
subcortical_mni_alignment_wf = init_subcortical_mni_alignment_wf ()
616
617
617
618
bold_grayords_wf = init_bold_grayords_wf (
618
- grayord_density = config . workflow . cifti_output ,
619
+ grayord_density = cifti_output ,
619
620
repetition_time = all_metadata [0 ]['RepetitionTime' ],
620
621
)
621
622
@@ -624,7 +625,7 @@ def init_bold_wf(
624
625
base_directory = output_dir ,
625
626
dismiss_entities = DEFAULT_DISMISS_ENTITIES ,
626
627
space = 'fsLR' ,
627
- density = config . workflow . cifti_output ,
628
+ density = cifti_output ,
628
629
suffix = 'bold' ,
629
630
compress = False ,
630
631
TaskName = all_metadata [0 ].get ('TaskName' ),
@@ -635,7 +636,8 @@ def init_bold_wf(
635
636
)
636
637
ds_bold_cifti .inputs .source_file = bold_file
637
638
638
- inputnode .inputs .mniinfant_mask = get_MNIInfant_mask (spaces )
639
+ mniinfant_res = 2 if cifti_output == '91k' else 1
640
+ inputnode .inputs .mniinfant_mask = get_MNIInfant_mask (spaces , mniinfant_res )
639
641
640
642
workflow .connect ([
641
643
# Resample BOLD to MNI152NLin6Asym, may duplicate bold_std_wf above
@@ -747,11 +749,11 @@ def init_bold_wf(
747
749
]) # fmt:skip
748
750
749
751
# MG: Carpetplot workflow only work with CIFTI
750
- if config . workflow . cifti_output :
752
+ if cifti_output :
751
753
carpetplot_wf = init_carpetplot_wf (
752
754
mem_gb = mem_gb ['resampled' ],
753
755
metadata = all_metadata [0 ],
754
- cifti_output = config . workflow . cifti_output ,
756
+ cifti_output = cifti_output ,
755
757
name = 'carpetplot_wf' ,
756
758
)
757
759
@@ -847,24 +849,20 @@ def _read_json(in_file):
847
849
return loads (Path (in_file ).read_text ())
848
850
849
851
850
- def get_MNIInfant_mask (spaces : 'SpatialReferences' ) -> str :
852
+ def get_MNIInfant_mask (spaces : 'SpatialReferences' , res : str | int ) -> str :
851
853
"""Parse spaces and return matching MNIInfant space, including cohort."""
852
854
import templateflow .api as tf
853
855
854
- mask = None
855
856
for ref in spaces .references :
856
- # str formats as <reference.name>:<reference.spec>
857
- if ref .space == 'MNIInfant' and ref .spec .get ('res' , '' ) != 'native' :
858
- mask = str (
857
+ if ref .space == 'MNIInfant' and f'res-{ res } ' in str (ref ):
858
+ return str (
859
859
tf .get (
860
860
'MNIInfant' ,
861
861
cohort = ref .spec ['cohort' ],
862
- resolution = 1 ,
862
+ resolution = res ,
863
863
desc = 'brain' ,
864
864
suffix = 'mask' ,
865
865
)
866
866
)
867
867
868
- if mask is None :
869
- raise FileNotFoundError ('MNIInfant brain mask not found.' )
870
- return mask
868
+ raise FileNotFoundError (f'MNIInfant mask (resolution { res } ) not found.' )
0 commit comments