What Is dcm2niix? The DICOM to NIfTI Converter Explained

What Is dcm2niix? The DICOM to NIfTI Converter Explained

If you have ever tried to open MRI scan data in a research tool, you have probably run into a format mismatch. Scanners save images as DICOM, a detailed medical format built for hospitals. Research tools for brain imaging mostly want NIfTI, a simpler format built for analysis. Moving data from one world to the other is a daily job in neuroimaging labs, and it is exactly the job dcm2niix was built to do. dcm2niix is a free, open source command line tool by Chris Rorden that converts MRI DICOM images into NIfTI files. It is fast, it handles data from the major scanner vendors, and it has become the standard first step in modern brain imaging pipelines. This article explains what it does, why it exists, and where it fits in your workflow.

What dcm2niix actually does

At its simplest, dcm2niix takes a folder full of DICOM files and turns it into NIfTI images you can actually analyze. You point it at a folder, like this:

dcm2niix /path/to/dicom/folder

It reads the DICOM headers, groups the images into series, and writes out one NIfTI file per series. A typical session folder might hold a structural scan, a functional run, and a diffusion scan, each stored in its own subfolder. dcm2niix searches those subfolders recursively and sorts everything out for you, so you can hand it a whole session at once instead of converting one series at a time.

The tool is deliberately small and focused. It does not try to be an image viewer, a statistics package, or a full pipeline. It does one job, conversion, and it does that job across data from Siemens, Philips, and GE scanners. That vendor robustness matters more than it sounds. Every scanner maker stores DICOM a little differently, with its own quirks in private tags and slice ordering. A converter that only works cleanly on one vendor’s data will waste your week. dcm2niix was designed to cope with that real world mess.

Why two formats exist at all

DICOM is the language of clinical radiology. A DICOM file is really a bundle: the image pixels plus a long header full of metadata about the patient, the scanner, the acquisition settings, and the study. Hospitals need that richness for archiving, viewing, and legal records, and the format is maintained as a huge international standard.

NIfTI came from the research world, where the priorities are different. Analysis tools want a simple 3D or 4D volume with a small header describing voxel size, orientation, and little else. NIfTI files are easy to load, easy to share, and easy to feed into statistics and machine learning code. They strip away the clinical baggage and keep what analysis needs.

So conversion is not just a file rename. It is a translation between two philosophies: the hospital archive and the research workstation. dcm2niix reads the DICOM metadata it needs, such as slice timing, gradient directions, and echo times, and carries the important parts across into NIfTI and its companion files.

What you get from a conversion

Run dcm2niix on a session folder and you will typically find these outputs waiting for you:

  • A NIfTI image (.nii, or compressed .nii.gz if you ask for compression with -z y). This is the volume itself, the brain data your analysis tools will open.
  • A JSON sidecar (.json) holding the useful DICOM metadata in a readable form: repetition time, echo time, slice timing, phase encoding direction, and more. This sidecar is on by default, and it is a core part of modern BIDS datasets.
  • .bval and .bvec files for diffusion scans, which record the diffusion weighting values and gradient directions that tractography and diffusion models need.

If you do not specify an output folder, the results land in the same folder as the input DICOM. That is convenient for a quick test, but for real work you will usually send output somewhere clean with the -o option, especially when the DICOM files sit on read only media like a disc or a locked archive.

Who uses dcm2niix

The short answer is: almost everyone who works with MRI data in research. If you run fMRIPrep, the popular preprocessing pipeline, your data almost certainly passed through dcm2niix first. If you build BIDS datasets, the converter’s JSON sidecars are the standard way to carry metadata along. University imaging centers, multi site studies, and open data projects all rely on it to turn scanner output into something shareable and analyzable.

Part of the appeal is that dcm2niix is a command line tool. That makes it scriptable. When you have fifty subjects, or five hundred, you do not want to click through a converter fifty times. You write a small loop, point dcm2niix at each subject folder, and let it run. The graphical interface in MRIcroGL exists for learning and for one off jobs, but the command line is where serious volume gets handled.

The tool is also free and open source, developed publicly at github.com/rordenlab/dcm2niix. That openness matters for science. When a conversion question comes up, you can look at the code, check the documentation, and reproduce exactly what happened. Closed, mysterious converters make that kind of checking much harder.

dcm2niix and the older dcm2nii

If you have been around neuroimaging for a while, you may remember dcm2nii, the earlier tool by the same author. dcm2niix is its successor, and the extra “x” marks a rewrite aimed at modern needs. The newer tool handles current scanner software better, writes BIDS sidecars by default, and deals more reliably with tricky cases like multi echo and multi band data.

For new work, dcm2niix is the right choice. The older tool still shows up in old tutorials and old scripts, which is why you will see both names floating around. If you are following a tutorial that says dcm2nii, check whether the steps still apply, and consider switching to dcm2niix for anything you run today.

A quick word on privacy

DICOM headers contain protected health information: patient names, IDs, and dates. That data travels with the files unless you remove it. dcm2niix offers an anonymized BIDS option (-ba y, on by default for sidecars) that helps keep sidecars clean, but you should still treat raw DICOM as sensitive material. Keep it on secured systems, anonymize before sharing anything, and never post raw DICOM publicly. Conversion is a good moment to think about this, because it is often the point where hospital data becomes research data.

How dcm2niix fits a typical project

Picture a small study with twenty subjects. Each subject arrives as a folder of DICOM from the scanner. Your first step is conversion: run dcm2niix on each folder, check the NIfTI files and JSON sidecars, and place the results into your project structure. From there, preprocessing tools take over, quality control follows, and statistics come last. Conversion sits at the base of that stack, and its quality shapes everything above it. A careful conversion step, with checked sidecars and consistent naming, pays off in every later stage, because errors caught at conversion cost minutes, while errors caught at statistics cost weeks.

Conclusion

dcm2niix is a small tool with a big job: turning scanner DICOM output into clean NIfTI data that research tools can use. It handles the major vendors, writes BIDS friendly sidecars, supports diffusion data properly, and scales from a single folder to a whole study through the command line. If you work with MRI data, learning it is time well spent, and it will likely be the first step of every pipeline you build. The next guides in this series walk you through installing it, running your first conversion, and mastering its options.

Read next:

1 thought on “What Is dcm2niix? The DICOM to NIfTI Converter Explained”

  1. Pingback: dcm2niix vs Other DICOM Converters

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top