User Tools

Site Tools


dcm2nii (import DICOM images using SPM's DICOM Import)


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). SPM comes with an import function for this, and the dcm2nii function collects the required information and passes it on to the SPM Job manager.


To be able to use this function you must have

  • a working installation of SPM5 or SPM8 on the path
  • a single folder containing the DICOM images to be imported as one scan
  • an existing target folder to receive the imported/converted images

Function reference ('help dcm2nii')

  dcm2nii  - convert DICOM to NII files
  FORMAT:       dcm2nii(source, target, opts)
  Input fields:
        source      source folder containing DICOM files
        target      target folder
        opts        optional settings
         .dcmpat    DICOM file pattern, default: '*.dcm'
         .format    either {'img'} or 'nii'
  No output fields.

Usage notes

In case you have multiple sessions of data in the source folder, these files must have a unique filename pattern per session, so that by re-setting the .dcmpat field you can selectively choose which files to import!

Usage example

This code imports the DICOM files contained in one folder into a different folder:

% import DICOM images
% - from /Data/Study/Subjects/s04/func/raw/192_r1
% - into /Data/Study/Subjects/s04/func/prepro/r01_192
% - save resulting images as .nii files
dcm2nii( ...
    '/Data/Study/Subjects/s04/func/raw/192_r1', ...
    '/Data/Study/Subjects/s04/func/prepro/r01_192', ...
    struct('format', 'nii'));
dcm2nii.txt · Last modified: 2011/04/14 20:03 by jochen