nipreps / sdcflows

Susceptibility Distortion Correction (SDC) workflows for EPI MR schemes
https://www.nipreps.org/sdcflows
Apache License 2.0
32 stars 26 forks source link

FIX: Drop header before resampling image to avoid unsafe cast #415

Closed effigies closed 11 months ago

effigies commented 11 months ago

int16 images with scale factors can get badly truncated or wrapped. This PR scales the data array and drops the header before passing to Affine().resample() to avoid this. We then re-add the dtype, though this may not be necessary. I think the effects of multiple interpolation are going to be minimal here, so keeping dtypes as expected is probably worth it.

codecov[bot] commented 11 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (5ef205f) 76.62% compared to head (efa3528) 76.59%.

Files Patch % Lines
sdcflows/interfaces/utils.py 0.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #415 +/- ## ========================================== - Coverage 76.62% 76.59% -0.03% ========================================== Files 32 32 Lines 2823 2824 +1 Branches 373 373 ========================================== Hits 2163 2163 - Misses 594 595 +1 Partials 66 66 ``` | [Flag](https://app.codecov.io/gh/nipreps/sdcflows/pull/415/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipreps) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/nipreps/sdcflows/pull/415/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipreps) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipreps#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

effigies commented 11 months ago

Not yet. Since that needs to work more broadly, a deeper review will be necessary.