Converting DICOM to NIfTI with dcm2niix is one of those jobs that looks technical from the outside and turns out to be pleasantly simple once you know the pattern. You give the tool a folder, it reads the scanner data, sorts it into series, and hands you clean NIfTI images plus JSON sidecars. This guide walks through the whole process: preparing your folder, running your first conversion, checking the results, and handling the small variations you will meet in real data. By the end you will be able to convert a session folder with confidence.
Start with your folder, not the command
Good conversions start before you type anything. Your DICOM data usually arrives as a session folder with nested subfolders, one per series: a structural scan here, a functional run there, a diffusion scan somewhere else. dcm2niix handles that layout natively. It searches subfolders recursively and organizes the images by series, so you can point it at the top level session folder and let it sort things out.
Before you run anything, take a quick look inside. Confirm the folder actually holds DICOM files and not, say, a zip archive you forgot to extract, or a folder of screenshots. Check that you have read permission on the files. And decide where the output should go. If you skip the output option, results land in the input folder, which is fine for a test but messy for real projects. A dedicated output folder keeps raw and converted data separate, and it is required when your DICOM lives on read only media.
Your first conversion
The minimal command is refreshingly short:
dcm2niix /path/to/dicom/folder
Run it and watch the output. dcm2niix reports each series it finds and each file it writes. When it finishes, look in your output location. For each series you should see a NIfTI image and a JSON sidecar with the same base name. Diffusion series add .bval and .bvec files. Open the NIfTI file in a viewer you trust, such as MRIcroGL or FSLeyes, and confirm the image looks right: correct orientation, no missing slices, no obviously scrambled anatomy.
One rule will save you from the most common beginner crash: never pass wildcards. Do not run dcm2niix /path/*.dcm. Your shell expands the wildcard into a huge list of filenames before dcm2niix ever sees it, and the tool can crash with “Argument list too long”. Pass a folder, or a single file, and let dcm2niix do the searching itself.
A typical explicit command
Once the minimal version works, you will usually want more control. A typical explicit command looks like this:
dcm2niix -z y -f myMRI%s -o /users/chris/outdir /users/chris/dir
Read it piece by piece. The -z y flag asks for gzip compressed output, so you get .nii.gz files instead of larger .nii files. The -f myMRI%s flag sets the output filename pattern, where %s is replaced by the series number, so a series might become myMRI33. The -o flag sends everything to a chosen output folder. The final argument is the input folder.
That command is a good template for daily work. Copy it, change the paths and the filename pattern to suit your project, and you have a repeatable conversion step you can paste into scripts and lab notebooks.
Reading the JSON sidecar
The JSON sidecar is easy to overlook and too valuable to ignore. Open one and you will see the acquisition details dcm2niix carried across from DICOM: repetition time, echo time, slice timing, phase encoding direction, and other parameters your analysis will need. Tools like fMRIPrep read these sidecars directly, and BIDS datasets require them.
Make a habit of glancing at the sidecar after each conversion. Does the repetition time match what the protocol promised? Is the phase encoding direction what you expected? Catching a mismatch here is far cheaper than catching it after a week of preprocessing. If a sidecar is missing entirely, check that the BIDS option is on (-b y, which is the default). Our troubleshooting guide covers the other causes.
What about tricky data
Real scanner data is rarely as tidy as tutorial data. A few situations come up often:
- Multi echo or multi band series may split or merge in ways you did not expect. The -m option controls merging of 2D slices from the same series: -m y merges them into one image regardless of echo or coil differences, while -m n keeps them separate. Try both and compare if the default result looks wrong.
- Philips data sometimes looks scaled oddly. The -p option controls Philips precision scaling, and toggling it to y can fix images that look washed out or oddly bright.
- Only one series needed. If a folder holds many series and you only want one, use -n with the series number, like -n 12 for the twelfth series. If you are not sure which number you want, run -n -1 first: it lists the available series and converts nothing, which is perfect for inspecting an unfamiliar folder.
When something looks off, the sidecar and the conversion log are your first clues. dcm2niix tells you what it found and what it wrote, and that log usually points straight at the cause.
Check your output before you move on
A short checklist after every conversion will prevent most downstream pain:
- Every expected series produced a NIfTI file and a JSON sidecar
- Diffusion series also produced .bval and .bvec files
- Image dimensions and voxel sizes look sane for the protocol
- Orientation looks right when you open the image in a viewer
- File names follow your project convention, or you know how to rename them for BIDS
This check takes a minute and saves hours. Preprocessing pipelines assume the conversion was correct, and they will happily process a bad conversion into bad results without complaining.
Privacy, one more time
DICOM headers carry patient names, IDs, and dates. The JSON sidecars dcm2niix writes are anonymized by default with the -ba option, but the raw DICOM itself is still sensitive. Keep it on secured storage, anonymize before sharing, and never post raw DICOM publicly. Make this part of your conversion routine, not an afterthought.
Converting a second series and comparing results
Your first conversion teaches you the mechanics. Your second conversion teaches you judgment. Convert a different series from the same session, perhaps a functional run after a structural scan, and compare the two outputs side by side. Do the JSON sidecars carry the values you expect for each sequence? Do the filenames stay unique and readable? Does the functional run have the volume count the protocol promised? This comparison habit catches the mistakes that a single conversion hides, like a filename pattern that collides across series or a default setting that suits one sequence but not another. Make it a rule: never trust a conversion setup until it has handled at least two different series correctly.
Conclusion
Converting DICOM to NIfTI with dcm2niix comes down to a simple rhythm: prepare a clean input folder, run the tool on the folder (never with wildcards), choose your output folder and filename pattern, and check the NIfTI files and JSON sidecars before you continue. The explicit command with -z, -f, and -o covers most daily work, and the -n and -m options handle the common tricky cases. Once this rhythm feels natural, you are ready to scale up to batch conversion and BIDS workflows, which the next guides cover.
Read next:

Pingback: dcm2niix Commands and Options Explained
Pingback: dcm2niix Batch Conversion: Whole Studies
Pingback: dcm2niix BIDS Output: JSON, fMRIPrep Guide
Pingback: dcm2niix Diffusion MRI: bval, bvec Guide
Pingback: dcm2niix Not Working? Common Errors, Fixes
Pingback: dcm2niix vs Other DICOM Converters