Repository navigation
Conversation
…eITK#2292) Signed-off-by: Ilyass Emssaad <[email protected]>
There was a problem hiding this comment.
Thank you for adding this test.
This PR contains what appears to be excessive AI prose. The first line of the commit message should be very concise, we don't place an issue number in the commit message. Details and references can go in the body of the commit message.
The inline comments are too verbose they should describe "what the code does", not detail the whole issue or describe old behavior.
P.S. We do have a minimal AGENTS.md file in main that might help, but there is not one in the release branch right now.
|
You're right. Sorry, that was my sloppy writing, not the test's fault. I rewrote it: short subject with no issue number, the references moved into the commit body, and the comments now just say what the test does. Also ran clang-format, so the lint failure is gone. The cleaned-up version is in #2822. Thanks for catching it. |
|
Closing in favour of #2822. |
Replaces #2820 — same diff, re-committed with a shorter subject to satisfy the 78-character commit-message limit.
Fixes #2292.
The direction-matrix bug in #2292 was fixed upstream in ITK (InsightSoftwareConsortium/ITK#5357, backported in ITK#6930, shipped in SimpleITK 2.5.7): when ForceOrthogonalDirection is on (the default), the last direction column was taken from the DICOM row/column orientation cross product without checking its sign against the actual slice-traversal vector, so reading a series bottom-to-top (or any order implying negative inter-slice spacing) reported direction (0,0,-1) where (0,0,+1) was correct, while the origin and spacing were right. The existing DicomSeriesReader test was only adapted to tolerate both behaviors (magnitude-only z-column check, commit 6900990); nothing in the SimpleITK suite asserts the corrected behavior, so a reintroduction would go unnoticed.
This adds TEST(IO, ImageSeriesReader_DirectionFromSliceOrder) in Testing/Unit/sitkImageIOTests.cxx. It synthesizes the issue's 3-slice axial DICOM series (Image Position (Patient) z = 70 / -187.5 / -445, Image Orientation (Patient) = 1 0 0 / 0 1 0) with ImageFileWriter, in three SpacingBetweenSlices variants (absent / 1 / -1), reads it top-to-bottom and bottom-to-top, and asserts the exact origin, the full direction matrix, z-spacing 257.5, and the physical z of the first and last voxel planes against the ImagePositionPatient tags.
Test evidence
The C++ test itself was not compiled or run here — a full SimpleITK SuperBuild is not feasible on the CPU-only machine used for this change, so please let CI run it. What was verified instead is an exact Python mirror of the test logic (same tags, same file layout, same assertions) against pip-installed SimpleITK:
An independent pydicom-written reproduction of the issue geometry agrees: 2.5.7 passes 6/6 (order x SBS sign), 2.5.6 fails 3/6.
One deliberate limitation, documented in a NOTE comment in the test: the test does not assert the SpacingBetweenSlices value written to the files. While validating, I observed via the Python bindings that once a DICOM read has happened in a process, later DICOM writes stamp SpacingBetweenSlices (0018,0088) = "1" regardless of the value set on the slice (write-only processes round-trip the value correctly). The geometry assertions are unaffected by that — with the ITK fix the direction is correct for every SpacingBetweenSlices value — so the test still fails on the buggy behavior. That writer observation is separate from #2292 and is not asserted here.
Signed-off-by: Ilyass Emssaad [email protected]