InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

ENH: Add a NIfTI scl_slope metadata-precision regression test (follow-up to #6003)

Open Beginner friendly
#6,750 0 comments 0 reactions 0 assignees View on GitHub
area:IO type:Testing
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

No test asserts that a NIfTI `scl_slope` survives a write/read round trip at full precision. The two places `scl_slope` appears in the NIfTI tests use it for other purposes, so the precision fix in #6003 is currently unguarded against regression.

Current coverage, verified on upstream/main

`git grep scl_slope -- Modules/IO/NIFTI/test` returns exactly three lines:

| Location | What it does |
|---|---|
| `itkNiftiImageIOTest.cxx:192` | format string in a header printf |
| `itkNiftiImageIOTest.cxx:204` | the matching `hp->scl_slope` printf argument |
| `itkNiftiImageIOTest5.cxx:57` | sets `scl_slope = 1.0 / 256.0` to exercise pixel rescale-on-read |

Test5 sets the value but asserts on rescaled *pixel* data, not on the
round-tripped slope itself. Nothing fails if the stored slope loses precision.

Proposed test

Write an image with a `scl_slope` that is not exactly representable after a
narrowing conversion, read it back, and assert the recovered slope equals the
written one to full `double` precision. A value such as `1.0 / 3.0` or a
scanner-realistic slope with many significant digits exercises the path that
#6003 fixed.

Small and self-contained — one test function in the existing NIfTI driver.

Contributor guide

Open the contributing guide

Research direction

Start in Modules/IO/NIFTI/test, especially itkNiftiImageIOTest5.cxx and its existing scl_slope coverage. Add one self-contained regression test that writes a non-exact slope such as 1.0 / 3.0, reads it back, and verifies the recovered value matches at full double precision.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.