take this Nifti file
and export to DICOM
result is horrible wrong.
It happens because GDCM uses Multi Frame Grayscale Byte SC Image IOD Modules.
Internally GDCM takes origin and adds positions one by one, calculating right handed cross product, so far GDCM does nothing wrong, but RPI orientation is not compatible with this approach. IMHO, IO could catch incompatible orientations and apply “change orientation filter” (RPI to RPS in particular case) to re-slice such images to compatible orientation.
Code to reproduce (trivial, read nifti, save dcm, nothing more):
In physical space it looks like:
There are already enough messy multi-frame files, were good not produce more.
P.S. It is not related to discussion about sorting frames in multi-frame images several months ago. Here sorting will not help, wrong positions are written in the image.
Sorry i don have this problem in my app and will not work on the issue.
another screenshot (exported image), from Slicer