@@ -286,6 +286,7 @@ def init_enhance_and_skullstrip_bold_wf(
286286 apply_mask = pe .Node (fsl .ApplyMask (), name = 'apply_mask' )
287287
288288 if not pre_mask :
289+ from ..interfaces .nibabel import Binarize
289290 bold_template = get_template (
290291 'MNI152NLin2009cAsym' , resolution = 2 , desc = 'fMRIPrep' , suffix = 'boldref' )
291292 brain_mask = get_template (
@@ -316,10 +317,15 @@ def init_enhance_and_skullstrip_bold_wf(
316317 name = 'norm' ,
317318 n_procs = omp_nthreads )
318319 norm .inputs .fixed_image = str (bold_template )
319- map_brainmask = pe .Node (
320- ApplyTransforms (interpolation = 'MultiLabel' , float = True , input_image = str (brain_mask )),
320+ map_brainmask = pe .Node (ApplyTransforms (
321+ interpolation = 'BSpline' ,
322+ float = True ,
323+ # Use the higher resolution and probseg for numerical stability in rounding
324+ input_image = str (get_template (
325+ 'MNI152NLin2009cAsym' , resolution = 1 , desc = 'brain' , suffix = 'probseg' ))),
321326 name = 'map_brainmask'
322327 )
328+ binarize_mask = pe .Node (Binarize (thresh_low = 0.75 ), name = 'binarize_mask' )
323329 workflow .connect ([
324330 (inputnode , init_aff , [('in_file' , 'moving_image' )]),
325331 (inputnode , map_brainmask , [('in_file' , 'reference_image' )]),
@@ -328,7 +334,8 @@ def init_enhance_and_skullstrip_bold_wf(
328334 (norm , map_brainmask , [
329335 ('reverse_invert_flags' , 'invert_transform_flags' ),
330336 ('reverse_transforms' , 'transforms' )]),
331- (map_brainmask , pre_dilate , [('output_image' , 'in_file' )]),
337+ (map_brainmask , binarize_mask , [('output_image' , 'in_file' )]),
338+ (binarize_mask , pre_dilate , [('out_mask' , 'in_file' )]),
332339 ])
333340 else :
334341 workflow .connect ([
0 commit comments