(more of a learning exercise. I am aware that there already tools available to create DICOM series from NIfTI files)
I am working on a small script that would write back a defaced NIfTI file to a set of DICOMS. I am using code from a small github repo.
Using a pre-existing DICOM slice as a template, a single NIfTI slice is written to (7FE0,0010) PixelData.
For this to work properly, I need to:
- Determine which plane the original DICOM data was stored in (i.e. sagittal, axial, or coronal). This determines which axis the NIfTI will be sliced along
- Conform the sliced 2-D image to the original DICOM orientation. This will determine if I need to either (a) rotate the image array (e.g. using
numpy.rot90) and/or (b) flip/mirror an axis (e.g. using
What tags from the original DICOMS can I use to figure 1. and 2.? I know orientations are given relative to the patient in the scanner and that several calculations must be made in order to find usable coordinates.
I know I would need (0020,0037) ImageOrientationPatient (e.g. -0 1 0 -0 -0 -1) and possibly (0020,0032) ImagePositionPatient; any others I would need to reference?