User Tools

Site Tools


dicom2nii (import DICOM or PAR/REC images)


Neuroimaging data is usually acquired in a format unsuitable for data processing (e.g. missing or incomplete support for data manipulation in existing files), such as DICOM or PAR/REC (Philips proprietary). For those who do not have SPM available but still want to be able to convert DICOM or PAR/REC images, NeuroElf also offers an experimental function that converts from those formats into 3D/4D NIftI files.


You simply need the list of files (or the single file in case of a PAR file) to import.

Function reference ('help dicom2nii')

  dicom2nii  - create a NIftI object from a set of IMA/DCM files
  FORMAT:       nii = dicom2nii(imafiles [, flags])
  Input fields:
        imafiles    FxC char or Fx1/1xF cell array with IMA filenames
                    multiple-slice files must be sorted correctly
        flags       optional settings
         .disdaqs   if given, remove first N volumes of 4D data (0)
         .dtype     datatype, either of 'int16' or {'single'}
         .flip      additionally flip data (e.g. 'xy')
         .mosaic    flag to force mosaic processing
         .mosdimord mosaic dimension order (default: [1, 2])
         .nslices   number of slices for 1-slice DCM files
         .xyres     functional x/y resolution (default [64, 64])
  Output fields:
        nii         NIftI object



This option can be used to remove the first few images from the scan, which is important if the scanner has not already discarded the data from the very beginning of the scan that lacks proper T2* contrast stabilization. In that case, typical values would be between 3 and 6, depending on the TR.


Can be used to override the default datatype (single), so that images will be stored as int16. While this is clearly enough to store the data (in most cases, both DICOM and PAR/REC will only ever have up to 16-bit integer data), subsequent processing of the data requires additional precision to avoid rounding error build-up! It is thus advised to use single precision values for any data that is to be processed!


String flag. If it contains an 'x', the data will be flipped along the first axis, a.s.f.


Boolean flag to force interpreting the data as mosaic.


Order of slices for mosaic'ed DICOM files (are slices first stacked along the left-right or front-back direction). Probably needs testing to confirm that images are converted correctly!


Option to set the number of slices for a DICOM images in a one-file-per-slice series.


Functional x/y resolution used to detect the number of slices in a mosaic image (defaults to [64, 64]). If your data is stored as mosaic'ed images and you use a different in-plane resolution (e.g. 80-x-80 voxels), you need to set this option!

Usage notes

Other than the dcm2nii function, this will *not* create a file by itself. The resulting output (xff object) needs to be saved using the .SaveAs method!

dicom2nii.txt · Last modified: 2011/04/14 20:15 by jochen