Dcm2niix outputs NIFTI in unzipped format (.nii) and not in nii.gz format

I am running dcm2niix on my dicom data and some of the sequences are being output as “.nii” files rather than the zipped “nii.gz” format. Is this because that sequence is too large?

Did you use the -z parameter?

From the dcm2niix help:

-z : gz compress images (y/o/i/n/3, default n) [y=pigz, o=optimal pigz, i=internal:miniz, n=no, 3=no,3D]

As @tsalo points out, you can use the -z parameter to control whether an image is compressed. However, dcm2niix is wary about creating gzipped files larger than 2Gb using the internal compressor and 4 Gb using pigz. The rationale is that the Gzip footer originally stored uncompressed data size in bytes as a 32 bit integer, which limits the maximum size to 4Gb. The revised specification of Gzip states that this value should be the modulus of the file size, but not all tools are aware of this change.

If dcm2niix decides the file is too large to safely compress, it will generate one of these warnings:

Saving uncompressed data: internal compressor unable to process such large files.


Saving uncompressed data: image too large for pigz.
1 Like

Yes, it does seem like the file is too big :

“Warning: Saving uncompressed data: image too large for pigz.”

I am asking since I will be using fmriprep and it automatically assumes files are in “nii.gz” format when I indicate the “IntendedFor” in fieldmaps. Throws an error.

You can change the file size limit and recompile dcm2niix. Make sure your computer has a recent version of pigz (assuming you have pigz >= 2.3.4 you will get faster conversion with -z o). I would keep a careful eye on how fmriprep handles these huge images, this is really an edge case for these tools.

You may also want to carefully consider why your file sizes are so large. Most contemporary MRI systems have a thermal noise barrier that limits effective spatial resolution. While advances like multi-band allow you to obtain very high resolution images with reasonably short TRs, the shorter TR necessarily reduces overall SNR.