Some DICOM volumes are loaded flipped along Z axis in ITK-v5.1rc01 #1587
Some volumes are flipped along their Z axis (ordering of slices is inverted). Other axes are not inverted, so it is not a rotation but a mirroring along one axis. It worked well in the previous ITK 5 release.
Steps to Reproduce
Load the DICOM volume using ITK-5.0 and ITK-5.1rc01 and compare them in a sagittal view.
They should look the same.
There is a flip along the IS axis.
I can provide an anonymized data set on request but it is not for public sharing.
Windows, Visual Studio 2015
We have done some more testing and found that file names matter: by renaming files from 0001, 0002, 003, ... to 0400, 0399, 0398, ... we could make the image flip upside down.
@pieper did some more testing and it seems that the issue is related to how the DICOM reader is used in Slicer (we collect the DICOM files and pass the filename list to ITK). Something has changed in ITK that changed the behavior, for example, the filename list was previously sorted internally in ITK, but now it is considered to be already sorted?
Some more detail on what @lassoan reported, when users load data through Slicer's DICOM module, we sort the data according to geometry (and do some other consistency checks) and send the sorted data to itk for reading.
When users drop an arbitrary file on the application, we delegate down through some very old logic that was created in the early days of ITK and Slicer which tries to guess what the user might want to do with the data. It is in this old code or something related that things no longer work. Most of the original authors are long gone, and this old spaghetti code should go too, but it's odd that it worked for the last 14 years and now something broke.
May be the change, s. link
I only guess, sorry, i don't use this code in my app and didn't try to reproduce the issue.