Skip to content

Commit

Permalink
Merge pull request #1324 from nipreps/fix/1315
Browse files Browse the repository at this point in the history
FIX: Resolve numeric overflow in drift estimation node
  • Loading branch information
oesteban authored Aug 19, 2024
2 parents 18e0f3a + e8ee30f commit 164be35
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
Expand Up @@ -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'])
Expand Down

0 comments on commit 164be35

Please sign in to comment.