From efa3528c0ccce035044f0578590ebeaec872a50f Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 15 Dec 2023 10:37:18 -0500 Subject: [PATCH] FIX: Drop header before resampling image to avoid unsafe cast --- sdcflows/interfaces/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdcflows/interfaces/utils.py b/sdcflows/interfaces/utils.py index 554139925b..6696c786d7 100644 --- a/sdcflows/interfaces/utils.py +++ b/sdcflows/interfaces/utils.py @@ -137,7 +137,12 @@ def _run_interface(self, runtime): nii.__class__(nii.dataobj, refaff, nii.header).to_filename(retval[i]) continue - resampler.apply(nii).to_filename(retval[i]) + # Hack around nitransforms' unsafe cast by dropping get_data_dtype that conflicts + # with effective dtype + # NT23_0_1: Isssue in nitransforms.base.TransformBase.apply + regridded_img = resampler.apply(nii.__class__(np.asanyarray(nii.dataobj), nii.affine)) + # Restore the original on-disk data type + nii.__class__(regridded_img.dataobj, refaff, nii.header).to_filename(retval[i]) self._results["out_data"] = retval