From 183a74f32d7735177f47890b502c2717543eb68d Mon Sep 17 00:00:00 2001 From: Patrick Sadil Date: Wed, 2 Oct 2024 16:58:53 -0400 Subject: [PATCH] Dilate fmap and epi masks before coregistration --- sdcflows/workflows/apply/registration.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sdcflows/workflows/apply/registration.py b/sdcflows/workflows/apply/registration.py index a82f8c23a5..3e05811dda 100644 --- a/sdcflows/workflows/apply/registration.py +++ b/sdcflows/workflows/apply/registration.py @@ -97,6 +97,8 @@ def init_coeff2epi_wf( from packaging.version import parse as parseversion, Version from niworkflows.interfaces.fixes import FixHeaderRegistration as Registration + from sdcflows.interfaces import brainmask + workflow = Workflow(name=name) workflow.__desc__ = """\ The estimated *fieldmap* was then aligned with rigid-registration to the target @@ -114,6 +116,11 @@ def init_coeff2epi_wf( name="outputnode", ) + # Dilate only for coregistration purposes + # https://github.com/nipreps/sdcflows/issues/461 + dilate_target_mask = pe.Node(brainmask.BinaryDilation(radius=5), name="dilate_target_mask") + dilate_fmap_mask = pe.Node(brainmask.BinaryDilation(radius=5), name="dilate_fmap_mask") + # Register the reference of the fieldmap to the reference # of the target image (the one that shall be corrected) coregister = pe.Node( @@ -132,11 +139,17 @@ def init_coeff2epi_wf( # fmt: off workflow.connect([ (inputnode, outputnode, [("fmap_coeff", "fmap_coeff")]), + (inputnode, dilate_target_mask, [("target_mask", "in_file")]), + (inputnode, dilate_fmap_mask, [("fmap_mask", "in_file")]), (inputnode, coregister, [ ("target_ref", "moving_image"), ("fmap_ref", "fixed_image"), - ("target_mask", f"moving_image_mask{mask_trait_s}"), - ("fmap_mask", f"fixed_image_mask{mask_trait_s}"), + ]), + (dilate_target_mask, coregister, [ + ("out_file", f"moving_image_mask{mask_trait_s}") + ]), + (dilate_fmap_mask, coregister, [ + ("out_file", f"fixed_image_mask{mask_trait_s}") ]), (coregister, outputnode, [ ("warped_image", "target_ref"),