Skip to content

Commit d60d5c6

Browse files
oestebanmgxd
authored andcommitted
enh: remove binarization and dilation
1 parent d425bec commit d60d5c6

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

niworkflows/func/util.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,6 @@ def init_enhance_and_skullstrip_bold_wf(
376376
name="outputnode",
377377
)
378378

379-
# Dilate pre_mask
380-
pre_dilate = pe.Node(BinaryDilation(), name="pre_mask_dilate")
381-
382-
# Ensure mask's header matches reference's
383-
check_hdr = pe.Node(MatchHeader(), name="check_hdr", run_without_submitting=True)
384-
385379
# Run N4 normally, force num_threads=1 for stability (images are small, no need for >1)
386380
n4_correct = pe.Node(
387381
N4BiasFieldCorrection(
@@ -436,7 +430,6 @@ def init_enhance_and_skullstrip_bold_wf(
436430

437431
if not pre_mask:
438432
from nipype.interfaces.ants.utils import AI
439-
from ..interfaces.nibabel import Binarize
440433

441434
bold_template = get_template(
442435
"MNI152NLin2009cAsym", resolution=2, desc="fMRIPrep", suffix="boldref"
@@ -489,10 +482,12 @@ def init_enhance_and_skullstrip_bold_wf(
489482
),
490483
name="map_brainmask",
491484
)
492-
binarize_mask = pe.Node(Binarize(thresh_low=brainmask_thresh), name="binarize_mask")
485+
# Ensure mask's header matches reference's
486+
check_hdr = pe.Node(MatchHeader(), name="check_hdr", run_without_submitting=True)
493487

494488
# fmt: off
495489
workflow.connect([
490+
(inputnode, check_hdr, [("in_file", "reference")]),
496491
(inputnode, init_aff, [("in_file", "moving_image")]),
497492
(inputnode, map_brainmask, [("in_file", "reference_image")]),
498493
(inputnode, norm, [("in_file", "moving_image")]),
@@ -501,22 +496,19 @@ def init_enhance_and_skullstrip_bold_wf(
501496
("reverse_invert_flags", "invert_transform_flags"),
502497
("reverse_transforms", "transforms"),
503498
]),
504-
(map_brainmask, binarize_mask, [("output_image", "in_file")]),
505-
(binarize_mask, pre_dilate, [("out_mask", "in_file")]),
499+
(map_brainmask, check_hdr, [("output_image", "in_file")]),
500+
(check_hdr, n4_correct, [("out_file", "weight_image")]),
506501
])
507502
# fmt: on
508503
else:
509504
# fmt: off
510505
workflow.connect([
511-
(inputnode, pre_dilate, [("pre_mask", "in_file")]),
506+
(inputnode, n4_correct, [("pre_mask", "weight_image")]),
512507
])
513508
# fmt: on
514509

515510
# fmt: off
516511
workflow.connect([
517-
(inputnode, check_hdr, [("in_file", "reference")]),
518-
(pre_dilate, check_hdr, [("out_file", "in_file")]),
519-
(check_hdr, n4_correct, [("out_file", "weight_image")]),
520512
(inputnode, n4_correct, [("in_file", "input_image")]),
521513
(inputnode, fixhdr_unifize, [("in_file", "hdr_file")]),
522514
(inputnode, fixhdr_skullstrip2, [("in_file", "hdr_file")]),

0 commit comments

Comments
 (0)