From e8ee30fbc685ca697875227ed13c850c6c1645f9 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Sun, 18 Aug 2024 22:55:14 +0200 Subject: [PATCH] fix: resolve numeric overflow in drift estimation node Resolves: #1315. --- mriqc/interfaces/diffusion.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mriqc/interfaces/diffusion.py b/mriqc/interfaces/diffusion.py index c24c39cd7..24e78a6d8 100644 --- a/mriqc/interfaces/diffusion.py +++ b/mriqc/interfaces/diffusion.py @@ -662,10 +662,17 @@ def _run_interface(self, runtime): self.inputs.full_epi, suffix='_nodriftfull', newpath=runtime.cwd ) full_img = nb.load(self.inputs.full_epi) + + # Read slope and intercept (see #1315) + slope, intercept = full_img.header.get_slope_inter() + slope = slope if slope is not None else 1.0 + intercept = intercept if intercept is not None else 0.0 + corrected = ( + full_img.get_fdata() * fitted[np.newaxis, np.newaxis, np.newaxis, :] / slope + - intercept + ) full_img.__class__( - (full_img.get_fdata() * fitted[np.newaxis, np.newaxis, np.newaxis, :]).astype( - full_img.header.get_data_dtype() - ), + corrected.astype(full_img.header.get_data_dtype()), full_img.affine, full_img.header, ).to_filename(self._results['out_full_file'])