From 996d7049426dbbe38fd18f07ee75363bf1fe055a Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Mon, 3 Feb 2025 15:42:57 -0500 Subject: [PATCH] FIX: Match mask header prior to n4 correction --- nibabies/workflows/anatomical/surfaces.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nibabies/workflows/anatomical/surfaces.py b/nibabies/workflows/anatomical/surfaces.py index 54d831f1..1432cf46 100644 --- a/nibabies/workflows/anatomical/surfaces.py +++ b/nibabies/workflows/anatomical/surfaces.py @@ -15,6 +15,7 @@ from niworkflows.interfaces.freesurfer import ( PatchedRobustRegister as RobustRegister, ) +from niworkflows.interfaces.header import MatchHeader from niworkflows.interfaces.morphology import BinaryDilation from niworkflows.interfaces.patches import FreeSurferSource from smriprep.interfaces.freesurfer import MakeMidthickness @@ -126,6 +127,9 @@ def init_mcribs_surface_recon_wf( mask_dil = pe.Node(BinaryDilation(radius=3), name='mask_dil') mask_las = pe.Node(ReorientImage(target_orientation='LAS'), name='mask_las') + # N4 has low tolerance for mismatch between input / mask + match_header = pe.Node(MatchHeader(), name='match_header') + # N4BiasCorrection occurs in MCRIBTissueSegMCRIBS (which is skipped) # Run it (with mask to rescale intensities) prior injection n4_mcribs = pe.Node( @@ -177,7 +181,9 @@ def init_mcribs_surface_recon_wf( ('subjects_dir', 'subjects_dir'), ('subject_id', 'subject_id')]), (t2w_las, n4_mcribs, [('out_file', 'input_image')]), - (mask_las, n4_mcribs, [('out_file', 'mask_image')]), + (mask_las, match_header, [('out_file', 'in_file')]), + (t2w_las, match_header, [('out_file', 'reference')]), + (match_header, n4_mcribs, [('out_file', 'mask_image')]), (n4_mcribs, mcribs_recon, [('output_image', 't2w_file')]), (seg_las, mcribs_recon, [('out_file', 'segmentation_file')]), (inputnode, mcribs_postrecon, [