-
-
Notifications
You must be signed in to change notification settings - Fork 668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Behaviour change between ITK 5.3 and 5.4 with DICOM spacing #4794
Comments
The behavior change may probably be related to these lines introduced in the commit malaterre/GDCM@836f7a7. In fact BTW, the 'Multiple' series is just duplicated file, both with the same Instance UID (this is invalid) and z-spacing is just a matter of fallback (it is 0 or undefined). |
CC @dclunie |
The spacing parameter on the z axis when reading a single image changed between ITK 5.3 and 5.4. Issue with change raised here: InsightSoftwareConsortium/ITK#4794 This is due to the underlying change in GDCM (MediaStorage::SecondaryCaptureImageStorage deriving the z spacing from this information): malaterre/GDCM@836f7a7
I looked into this some more and I'm thinking now that the new behavior is generally correct. For the case of the single file, it has a
In the code pointed to by @issakomi it looks to me like all the Media Storage types above the For the multiple slices it's a little weirder. It seems the test case the positions are the same for the two slices, so probably
The ITK readers defaulting to a spacing of 1 when the value really should be undefined is probably a bit of legacy behavior we can't easily change now, even if it's confusing since you don't know if 1 is valid or not. Then again, I'm not sure what the correct answer is here: the files are in the same location but claim to be 5mm apart, so it's not clear which part of the file should take precedence. So while I think the GDCM change is okay, something about the behavior of the series reader is causing a problem in Slicer on some real CT data that is being discussed further here: https://discourse.slicer.org/t/regression-in-the-dicom-data-base/37913/8. |
I suppose we could still change this behaviour, using the |
Fixes Slicer#7937 See original report here about a dataset being scrambled that loaded well in the 5.6.2 release: https://discourse.slicer.org/t/regression-in-the-dicom-data-base/37913 This corresponds to the change in behavior described here, where spacing from ITK that used to be 1 is now, for example 5 or -1: InsightSoftwareConsortium/ITK#4794 Which is believed to be due to the changes here, which was added so that for Secondary Capture files the spacing would be respected if present: InsightSoftwareConsortium/ITK#4521 However adding this code in GDCM meant that if the SpacingBetweenSlices tag is present, even in a CT, it is being used by ITK to calculate spacing, and also ITKToRAS transforms when trying to orthogonalize the transform. Since Slicer doesn't rely on orthogonal IJKToRAS transforms, this change tells ITK to skip that step and instead it relies on the positions and orientations of the slices to calculate the IJKToRAS transform, which is compatible with what Slicer expects. This code was tested on both the CT scan with the negative spacing that was reported in the original issue, and on other CT cans without that tag and the geometry matches what was obtained in 5.6.2. This change was discussed in the Slicer developer meeting 2024-10-08 and determined to be the best course of action. Further fixes in GDCM or ITK were not pursued because it was unclear whta the correct behavior should be at the library level considering that a negative spacing between slices is technically invalid for CT scans according to the DICOM standard.
Fixes #7937 See original report here about a dataset being scrambled that loaded well in the 5.6.2 release: https://discourse.slicer.org/t/regression-in-the-dicom-data-base/37913 This corresponds to the change in behavior described here, where spacing from ITK that used to be 1 is now, for example 5 or -1: InsightSoftwareConsortium/ITK#4794 Which is believed to be due to the changes here, which was added so that for Secondary Capture files the spacing would be respected if present: InsightSoftwareConsortium/ITK#4521 However adding this code in GDCM meant that if the SpacingBetweenSlices tag is present, even in a CT, it is being used by ITK to calculate spacing, and also ITKToRAS transforms when trying to orthogonalize the transform. Since Slicer doesn't rely on orthogonal IJKToRAS transforms, this change tells ITK to skip that step and instead it relies on the positions and orientations of the slices to calculate the IJKToRAS transform, which is compatible with what Slicer expects. This code was tested on both the CT scan with the negative spacing that was reported in the original issue, and on other CT cans without that tag and the geometry matches what was obtained in 5.6.2. This change was discussed in the Slicer developer meeting 2024-10-08 and determined to be the best course of action. Further fixes in GDCM or ITK were not pursued because it was unclear whta the correct behavior should be at the library level considering that a negative spacing between slices is technically invalid for CT scans according to the DICOM standard.
@seanm It seems like a related, but slightly different issue. |
I'd suggest adding APIs that could report back when the reader used default values for things it couldn't determine from the files themselves. That way applications could know and report to the user when the data is not well defined geometrically. It could also be good to add accessor methods like |
Further to some discussions in #4647 and #4521, we still have a situation that isn't quite clear to us, and since those are merged already, we thought we'd create a new ticket.
Basically, there is a change in behaviour between ITK 5.3 and 5.4 that we are trying to understand if it's a bug or deliberate & correct.
If we query a DICOM file for its image spacing information, we get different results depending on:
itk::ImageSeriesReader
vs usingitk::GDCMImageIO
A small C++ test case is attached: inconsistency_in_spacing.zip
It uses a DICOM file named
D_CLUNIE_CT1_J2KR1.dcm
, from the GDCM test suite I think, but from David Clunie's collection ultimately I suppose.In ITK 5.3:
Notice everything agrees: the z spacing is 1.
In ITK 5.4 / master:
Notice now everything does not agree.
The change from 1 to 5 is presumably deliberate from #4521.
But then shouldn't that lone 1 (in the bottom left) also be 5?
Thanks.
The text was updated successfully, but these errors were encountered: