Skip to content

Commit 00fbf05

Browse files
committed
enh: replace the binary mask of MNI152NLin2009cAsym with the new probseg
Closes #476
1 parent bbd65e1 commit 00fbf05

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

niworkflows/func/util.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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([

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ install_requires =
3838
seaborn
3939
svgutils
4040
transforms3d
41-
templateflow >= 0.4.2
41+
templateflow >= 0.5.2
4242
test_requires =
4343
coverage < 5
4444
pytest >= 4.4

0 commit comments

Comments
 (0)