I am in a position where I have a 3D numpy array with dose values, along with the ImagePositionPatient DICOM values for each slice. These position values are extracted from a CT DICOM series which I also have access to.
I am trying to save this 3D array into an RTDOSE file, and up until now I have simply ordered the slices from lowest z position to highest z position (from ImagePositionPatient). I am however noticing that this leads to some issues in certain cases where say the CT has ImageOrientationPatient=[1, 0, 0, 0, 1, 0]
and PatientPosition=FFS
when these RTDOSE are loaded in 3DSLICER alongside the CT. As is, the shoulders of the patient end up on opposite ends of the z-slider; which is evidently a problem for any overlaying task.
So essentially, what is the standard for the slice-order in the 3D RTDOSE pixel data? Do I take the ImagePositionPatient-sorted array, and flip it if the PatientPosition is some form of "feet first", and again if the ImageOrientationPatient is of the form [1, 0, 0, 0, -1, 0]
(if that even happens?) ?
I realize I may also just be completely missing a key detail about this whole thing, so I would greatly appreciate any input on the subject.
It's been a while since I've been working with RTDOSE, but I think GridFrameOffsetVector may be the element you are missing. I'd suggest looking at the dicompyler-core library where this is all handled including code for various patient orientations.
It may be a mix of PatientPosition not being added and the offset vector always assuming a negative "displacement".