Skip to content

Commit 8285299

Browse files
oestebanmgxd
authored andcommitted
fix: use niworkflows' binary dilations
1 parent d60d5c6 commit 8285299

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

niworkflows/func/util.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def init_enhance_and_skullstrip_bold_wf(
363363
reportlet for the skull-stripping
364364
365365
"""
366-
from niworkflows.interfaces.nibabel import BinaryDilation
366+
from niworkflows.interfaces.nibabel import ApplyMask, BinaryDilation
367367

368368
workflow = Workflow(name=name)
369369
inputnode = pe.Node(
@@ -391,16 +391,8 @@ def init_enhance_and_skullstrip_bold_wf(
391391
skullstrip_first_pass = pe.Node(
392392
fsl.BET(frac=0.2, mask=True), name="skullstrip_first_pass"
393393
)
394-
bet_dilate = pe.Node(
395-
fsl.DilateImage(
396-
operation="max",
397-
kernel_shape="sphere",
398-
kernel_size=6.0,
399-
internal_datatype="char",
400-
),
401-
name="skullstrip_first_dilate",
402-
)
403-
bet_mask = pe.Node(fsl.ApplyMask(), name="skullstrip_first_mask")
394+
bet_dilate = pe.Node(BinaryDilation(radius=6), name="skullstrip_first_dilate")
395+
bet_mask = pe.Node(ApplyMask(), name="skullstrip_first_mask")
404396

405397
# Use AFNI's unifize for T2 constrast & fix header
406398
unifize = pe.Node(
@@ -426,7 +418,7 @@ def init_enhance_and_skullstrip_bold_wf(
426418
combine_masks = pe.Node(fsl.BinaryMaths(operation="mul"), name="combine_masks")
427419

428420
# Compute masked brain
429-
apply_mask = pe.Node(fsl.ApplyMask(), name="apply_mask")
421+
apply_mask = pe.Node(ApplyMask(), name="apply_mask")
430422

431423
if not pre_mask:
432424
from nipype.interfaces.ants.utils import AI
@@ -514,7 +506,7 @@ def init_enhance_and_skullstrip_bold_wf(
514506
(inputnode, fixhdr_skullstrip2, [("in_file", "hdr_file")]),
515507
(n4_correct, skullstrip_first_pass, [("output_image", "in_file")]),
516508
(skullstrip_first_pass, bet_dilate, [("mask_file", "in_file")]),
517-
(bet_dilate, bet_mask, [("out_file", "mask_file")]),
509+
(bet_dilate, bet_mask, [("out_file", "in_mask")]),
518510
(skullstrip_first_pass, bet_mask, [("out_file", "in_file")]),
519511
(bet_mask, unifize, [("out_file", "in_file")]),
520512
(unifize, fixhdr_unifize, [("out_file", "in_file")]),
@@ -523,7 +515,7 @@ def init_enhance_and_skullstrip_bold_wf(
523515
(skullstrip_second_pass, fixhdr_skullstrip2, [("out_file", "in_file")]),
524516
(fixhdr_skullstrip2, combine_masks, [("out_file", "operand_file")]),
525517
(fixhdr_unifize, apply_mask, [("out_file", "in_file")]),
526-
(combine_masks, apply_mask, [("out_file", "mask_file")]),
518+
(combine_masks, apply_mask, [("out_file", "in_mask")]),
527519
(combine_masks, outputnode, [("out_file", "mask_file")]),
528520
(apply_mask, outputnode, [("out_file", "skull_stripped_file")]),
529521
(n4_correct, outputnode, [("output_image", "bias_corrected_file")]),
@@ -565,6 +557,8 @@ def init_skullstrip_bold_wf(name="skullstrip_bold_wf"):
565557
reportlet for the skull-stripping
566558
567559
"""
560+
from niworkflows.interfaces.nibabel import ApplyMask
561+
568562
workflow = Workflow(name=name)
569563
inputnode = pe.Node(niu.IdentityInterface(fields=["in_file"]), name="inputnode")
570564
outputnode = pe.Node(
@@ -580,7 +574,7 @@ def init_skullstrip_bold_wf(name="skullstrip_bold_wf"):
580574
afni.Automask(dilate=1, outputtype="NIFTI_GZ"), name="skullstrip_second_pass"
581575
)
582576
combine_masks = pe.Node(fsl.BinaryMaths(operation="mul"), name="combine_masks")
583-
apply_mask = pe.Node(fsl.ApplyMask(), name="apply_mask")
577+
apply_mask = pe.Node(ApplyMask(), name="apply_mask")
584578
mask_reportlet = pe.Node(SimpleShowMaskRPT(), name="mask_reportlet")
585579

586580
# fmt: off
@@ -592,7 +586,7 @@ def init_skullstrip_bold_wf(name="skullstrip_bold_wf"):
592586
(combine_masks, outputnode, [("out_file", "mask_file")]),
593587
# Masked file
594588
(inputnode, apply_mask, [("in_file", "in_file")]),
595-
(combine_masks, apply_mask, [("out_file", "mask_file")]),
589+
(combine_masks, apply_mask, [("out_file", "in_mask")]),
596590
(apply_mask, outputnode, [("out_file", "skull_stripped_file")]),
597591
# Reportlet
598592
(inputnode, mask_reportlet, [("in_file", "background_file")]),

0 commit comments

Comments
 (0)