Dcm2bids with tgz inputs?

I have dcm2bids installed, and I want to use it on my own data to start. The data is a set of .tgz files in one directory.

I wrote a config.json file in what looks like the appropriate way; it loads when I run (following a tutorial I followed here; BIDS Overview and Tutorial — Andy's Brain Book 1.0 documentation):

dcm2bids_scaffold -o BIDS/bidsout
dcm2bids -d PilotStudy/PilotSession11/data/dicoms -p 01 -c BIDS/BIDS_config_p11.json -o BIDS/bidsout --forceDcm2niix

but then dcm2bids fails because:

INFO:dcm2bids.dcm2bids:BIDS directory: /Volumes/vision/Data/BIDS/bidsout
INFO:dcm2bids.utils:Running ['dcm2niix', '-b', 'y', '-ba', 'y', '-z', 'y', '-f', '%3s_%f_%p_%t', '-o', PosixPath('BIDS/bidsout/tmp_dcm2bids/sub-01'), PosixPath('PilotStudy/PilotSession11/data/dicoms')]
Error: Unable to find any DICOM images in PilotStudy/PilotSession11/data/dicoms (or subfolders 5 deep)

But that is the directory with the data. Am I not formatting the command correctly? Surely I don’t have to pre-extract the dcms from each tgz (i have used dcm2niix from within matlab and python packages and pointing it at tgz files works - is that some extra capability of other packages?)… Or…?

Thanks!
-andrew

I would presume those packages untar the tgz files in the directory you point to.

Why not write a simple bash function to automate the workflow?

1 Like

dcm2niix does not extract DICOMs from compressed files. It assumes that the input folder is read only (e.g. DICOMs often come on CD-ROMs).

You can always write a wrapper for dcm2niix that extracts .tgz files to a temporary folder, calls dcm2niix and then deletes the temporary folder. Be aware that servers often have very slow disk storage, so you may want the temporary folder to be on a RAM disk.

As an aside, whereas one can rapidly read the contents of a .zip format archive and randomly access the contents the same is not true for .tar.gz archives.

1 Like

Hi @amhaun01,

I’m pretty sure now you have all the answers needed to fix your issue with dcm2bids/dcm2niix.
Thank you for rising the issue about dcm2bids tutorials. It should now be fixed.
Arnaud

1 Like

Great! Thank you, now I know. I will figure out how to do something like this. (dcm2bids does work nicely with the uncompressed inputs, first time I’ve gotten something like this to work!)