dcmunpack is a script to unpack DICOM files from any vendor. It has flexible output formats, including the ability to unpack data into the FSFAST directory structure. Use this routine instead of unpacksdcmdir (unpacksdcmdir can only handle Siemens DICOM and only when all DICOMS are in the same folder).

SUMMARY

Required Arguments:

Other Arguments

   -targ targetdir
   -run run subdir format stemname <<nskip> ndrop>
   -scanonly file : only scan the directory and put result in file
   -one-per-dir : assume that there is only one dicom series in each subdir
   -gedcm : same as -one-per-dir -ext dcm
   -ext extension : input extension (eg, dcm)
   -pre prefix : input prefix (ie, input file name init string)
   -pat pattern : input pattern (ie, string that occurs in the middle of file name)
   -no-infodump : do not create infodump.dat
   -generic : do not use fs-fast hierarchy
   -copy-only
   -no-convert : do not convert to output format
   -max : print out max in given dicom file
   -base : report filename without path
   -key keystring : put keystring before each run line (good for searching)
   -index-out dcm.index.dat : save index of files to index.out.dat (for re-use with -index-in)
   -index-in  dcm.index.dat : read index of files (can make things much faster on 2nd run) 
   -itdicom : add -it dicom to mri_convert cmd line

   -fips project site birnid visit
   -fips-run run paradigm <<nskip> ndrop>
   -xml-only : for fips, only create xml file, do not convert to output

   -log logfile
   -debug
   -help

Sorts and converts a directory of Siemens or GE DICOM files into an output hierarchy with nifti (nii), mgh, mgz, or analyze output formats (will not create a series of 3D SPM files). This will recursively search through all the subdirectories of the source directory. To a large extent, this replaces unpacksdcmdir (the Siemens-only unpacker) and will take most of its command-line arguments.

-src dcmdir <-src dcmdir>

Dicom source directory. You can specify more than one. If you just specify a source directory, it will give a summary of what it finds (like -scanonly did for unpacksdcmdir). You should still give it -one-per-dir or -martinos if applicable.

-targ targetdir

Output directory. Do not need to include when just getting information about what is in the directory.

-run run subdir format stemname <<nskip> ndrop>

Specify unpacking rules for a given run (series), subdir is the subdirectory under the target dir, format is the format extension (nii, mgh, mgz, img), stemname is the base file name, nskip is the number of time points to skip (optional, good for some fMRI), and ndrop is the number of time points to drop from the end. The output file will be targetdir/subdir/RRR/fname.format if using the FSFAST output hierarchy (the default) or targetdir/subdir/fname.format with -generic, where RRR is the 3-digit, zero-padded run number. Eg, "-run 3 bold nii f" would become targetdir/bold/003/f.nii in fsfast or targetdir/bold/f.nii in generic. If the stemname has an extension, that extension is ignored.

-one-per-dir

Assume that the source directory (or subdirectory) contains only one series. This is usually the case for GE, and this can speed things up tremendously.

-martinos -mgh -bourget

Assume that the DICOM file names have the form produced at the MGH Martinos Center when you "push something to bourget" from the scanner, namely that each series will have one file that ends in "1.dcm", eg 397000-000007-000001.dcm. This can speed things up considerably. Note: as of August, 2012, the naming convention that allows for fast unpacking does not exist. If you have to run this twice, it will be faster if you run it with --index-out index.dat when you are getting a list of runs, then run it again with --index-in index.dat when you go to unpack it.

-no-infodump

Do not create the fname-infodump.dat file

-generic

Do not use FSFAST hierarchy.

-no-convert

Do not actually run mri_convert

-copy-only

Only copy dicom files to output directory (implies -no-convert)

EXAMPLE

# CD into the dicom directory
cd Avanto-25096-20100325-162822-229000

# See what's there
dcmunpack -src . -index-out dcm.index.dat
---------------------------------------
Searching for matching files
Mon Jul 12 10:21:10 EDT 2010
Mon Jul 12 10:21:10 EDT 2010
Found 6 total files.
Found 6 unique series: 1 2 3 4 5 6
Subject Subj5
Date 20100325
Time 162822.229000
Institution Martinos Center Bay 2
1 Localizer 2.95 7 20 0.546875 ROW 285 ./229000-000001-000001.dcm
2 AAScout 1.23 2.6 0 2.5\2.5 ROW 1085 ./229000-000002-000001.dcm
3 ge_functionals 40 2000 90 3.125\3.125 COL 2300 ./229000-000003-000001.dcm
4 ge_functionals 40 2000 90 3.125\3.125 COL 2300 ./229000-000004-000001.dcm
5 ge_functionals 40 2000 90 3.125\3.125 COL 2300 ./229000-000005-000001.dcm
6 ge_functionals 40 2000 90 3.125\3.125 COL
---------------------------------------

# Now unpack it

dcmunpack -src . -index-in dcm.index.dat -targ /space/ProjectDir/subj5 \
  -run 3 bold nii f.nii \
  -run 4 bold nii f.nii \
  -run 5 bold nii f.nii \
  -run 6 bold nii f.nii 

RELATIONSHIP TO UNPACKSDCMDIR

unpacksdcmdir is the Siemens-only unpacker. dcmunpack will take the same command-line arguments except: -cfg, -seqcfg, -nspmzeropad, -no-unpackerr (it unpacks everything), and -scanonly (you can still get a scanonly-like summary of the data). dcmunpack does not accept SPM as an output format. The seq.info file is not created (it is not needed for newer versions of FSFAST). These features can be programmed, I just have not gotten around to it. Unlike unpacksdcmdir, dcmunpack searches subdirectories and can unpack GE data.

dcmunpack (last edited 2016-10-12 16:20:59 by 172)