questions > RE: dcm2niix reorients all images to RPI, origins are changed
May 24, 2018  10:05 AM | Chris Rorden
RE: dcm2niix reorients all images to RPI, origins are changed
In brief, dcm2niix losslessy preserves the voxel data. Be aware that DICOM and NIfTI use different spatial coordinates, and these transforms are typically encoded in the SForm and QForm of the data. The software does not reorient all images to RPI. Spatial manipulation depends on the input.
 https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#Spatial_Coordinates

For 3D scans (e.g. MP-RAGE) it does re-orient to the nearest orthogonal to a NIfTI identity matrix, with the residual angulation saved in the SForm and QForm. You can disable this by commenting out the line 
   imgM = nii_setOrtho(imgM, &hdr0);
to read
   //imgM = nii_setOrtho(imgM, &hdr0);
I would also comment out the lines nii_saveCrop line in a similar fashion.

For non-3D sequences, the image row order is flipped. For sagittal and coronal scans this is the head-foot dimension, for axial scans this is the anterior-posterior dimension. Again, any change is encoded in the NIfTI header. The reason here is that the convention of DICOM and NIfTI is to store rows in the opposite order: in DICOM row number increases from top to bottom, like we would write a numbered list in english. In NIfTI, row increases toward the top of the page, as we would draw the Y coordinate on a cartesian grid. You can change this with
  opts.isFlipY

Finally, dcm2niix enforces that data is saved such that the first three dimensions are contiguous spatial dimensions while time is the fourth dimension. This is required by NIfTI and can not be changed. DICOM is much more flexible in this regard: the data can be stored to disk in any order (e.g. the jumbled order that slices come off the reconstructor, the order scans were acquired which would jitter the spatial dimension for interleaved acquisitions, etc). 

The origin never changes its spatial location, though it changes its coordinate system from DICOM to NIfTI. For MRI the origin is isocenter, for CT it is table center. Often, origin is the first thing you will want to change AFTER conversion - setting this to a location near the anterior commissure to provide a good starting estimate for normalization. dcm2niix does not do this for you. I use the script nii_setOrigin() to do this with my MRI data.

For your purposes, you may be better served by a different image converter. I list alternatives on the 
  https://github.com/rordenlab/dcm2niix
and
  https://www.nitrc.org/plugins/mwiki/inde... 

Threaded View

TitleAuthorDate
Angela Zhang May 24, 2018
RE: dcm2niix reorients all images to RPI, origins are changed
Chris Rorden May 24, 2018
Angela Zhang May 24, 2018
Chris Rorden May 24, 2018
Angela Zhang May 24, 2018
Virginia Flanagin Feb 20, 2019
Chris Rorden Feb 20, 2019