This is not a single set of steps that work every time. One of the challenges is that Nifti can lack header information that contains image orientation. Putting these images into DICOM frequently results in unexpected orientations relative to customary DICOM orientations.
The general steps are
- Convert Nifti to DICOM with the code in https://bitbucket.org/xnatx/nifti2dcm/src/master/
There are tests in Nift2DcmTest.java that run the code on the data. This was done as a quick way to script the running of the application and not having to leave the IDE to run the code.
- Flip and rotate the images to get the DICOM in the desired orientation. This can be done with a variety of tools and performed on the Nifti prior to conversion or on the DICOM after conversion. Fiji (ImageJ) and Horos are two examples.
- Set additional DICOM attributes. It may be necessary to further alter attributes in the DICOM images. This can be done using the DicomEdit command line.