There are two issues here. First, the NIfTI uses a different spatial coordinate system than DICOM. Specifically, NIfTI uses Talairach-Tournoux coordinates:
X: Increasing value toward the Right
Y: Increasing value toward the Anterior
Z: Increasing value toward the Superior
In contrast, the DICOM coordinate system is
X: Increasing value toward the Left
Y: Increasing value toward the Posterior
Z: Increasing value toward the Superior
The other thing to remember is the row order. Following NIfTI convention I will refer to the stored order as I,J,K instead of X,Y,Z to avoid confusion with spatial dimensions. The data is stored Columns (I) followed by Rows (J) followed by slices (K). For a NIfTI image
I: first column on LEFT of screen, columns ascending toward RIGHT
J: first row at BOTTOM of screen, subsequent columns ascending toward TOP
with DICOM
I: first column on LEFT of screen, columns ascending toward RIGHT
J: first row at TOP of screen, subsequent columns ascending toward BOTTOM
I like to think of how we draw a 2D Cartesian graph, with a higher position on the graph showing a higher value. In contrast, DICOM is how I write English, with the first row at the top of the screen and subsequent rows descending down the page.
dcm2niix will losslessly convert DICOM to NIfTI. It will preserve spatial information. By default, it will also flip the row order. This flipping means that a viewing tool that ignores the Form/QForm will display a 2D slice in the same way that a DICOM viewer would with respect to the top and bottom of the computer screen. The undocumented argument -y n will disable this row flipping. Since the SForm/QForm are also updated, the resulting images will look identical in a tool that respects the SForm/QForm, but will look flipped in tools that ignore this. To see this, launch MRIcron and choose Preferences. Make sure both the “Reorient images when loading” and “Rotate to nearest orthogonal angle” options are unchecked. This will show the order data is saved to disk.