Skip to content

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

Description

@hjmjohnson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:IOIssues affecting the IO moduletype:TestingEnsure that the purpose of a class is met/the results on a wide set of test cases are correct

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions