Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .gz'ipped DICOM files conversion #287

Open
yarikoptic opened this issue Dec 10, 2018 · 1 comment
Open

Support .gz'ipped DICOM files conversion #287

yarikoptic opened this issue Dec 10, 2018 · 1 comment

Comments

@yarikoptic
Copy link
Member

I haven't looked at yet either dcm2niix handles them but I guess on python side there should also be support for them if want to handle them "natively" without first extracting to some TEMPDIR

@neurolabusc
Copy link

neurolabusc commented Jan 10, 2019

dcm2niix will not detect DICOMs compressed with GZ (or any other method). In theory, one could rapidly decompress the first 132 bytes of each GZip file to look for the "DICM" signature. This will accurately detect DICOM images with the part 10 meta header. However, this algorithm would fail to detect DICOM data stored without this header. The issue becomes how much of the file must be decompressed to accurately determine if the data is DICOM. If you consider the user passing a folder where there are huge numbers of GZip files that are not DICOM data, or a situation where multiple DICOM images are put into a TAR.GZ, a huge amount of time will be spent interrogating these files. Therefore, seems better handled by external scripts that know about the users particular preferences with data storage.

By the way, my center stores each individual session of DICOM data as a single TAR/GZ file (.tgz). For decoding and converting these we use a ram disk. This is faster than a SSD or Hard Disk. In Matlab the command would be
untar('/SlowDrive/src.tgz',/ramdisk');
and then you can run dcm2niix where the input folder is the RAM disk.

One final slightly related comment. If you want the output images to be saved in compressed .nii.gz format instead of raw .nii format, you will find that the conversion time of dcm2niix is trivial compared to the compression time. You can accelerate this substantially by using pigz to conduct parallel compression. Unfortunately, in the past dcm2niix would need to save the uncompressed data to disk, which pigz would then need to read from disk. So while the compression might be faster, one had to tradeoff the speed of the disk (with networks and clusters often having very slow disk IO). The development branch of dcm2niix includes a new option '-z o' for 'optimal' compression: if this is selected dcm2niix will use a named pipe to transfer data directly to pigz. The caveat is this requires Unix (Linux/MacOS) and a recent version of pigz ( 2.3.4 or later). This can accelerate dcm2niix, in particular if you have slow disk I/O.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants