Skip to content

Commit

Permalink
fix: resolve numeric overflow in drift estimation node
Browse files Browse the repository at this point in the history
Resolves: #1315.
oesteban committed Aug 18, 2024
1 parent bba1360 commit e8ee30f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mriqc/interfaces/diffusion.py
Original file line number Diff line number Diff line change
@@ -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'])

0 comments on commit e8ee30f

Please sign in to comment.