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

Version of dcm2niix should be checked along with config file #42

Closed
jcohenadad opened this issue Mar 4, 2019 · 7 comments
Closed

Version of dcm2niix should be checked along with config file #42

jcohenadad opened this issue Mar 4, 2019 · 7 comments

Comments

@jcohenadad
Copy link
Contributor

jcohenadad commented Mar 4, 2019

With the evolution of dcm2niix, some config files might become obsolete, making it difficult to debug if users have conversion problem (is it dcm2niix? is it their OS? is it their syntax? is it dcm2bids? etc.).

One workaround would be to specify dcm2niix version that was used to generate a config file.

Below is an example to reproduce the issue:

Version dcm2bids (from Pypi): (1.1.8)

Dicom dataset:
https://www.dropbox.com/s/tis1i50egxo1b4q/20180611_tokyo_prisma.zip?dl=0

Config file:
config_spine.txt

Syntax:

dcm2bids -d 20180611_prisma/DICOM/ -p sub-99 -c config_spine.txt

Output with dcm2niix v1.0.20181125:

dcm2bids -d 20180611_prisma/DICOM/ -p sub-99 -c config_spine.txt 
INFO:dcm2bids:--- dcm2bids start ---
INFO:dcm2bids:subprocess: dcm2niix
INFO:dcm2bids:
Chris Rorden's dcm2niiX version v1.0.20181125  (JP2:OpenJPEG) (JP-LS:CharLS) Clang8.1.0 (64-bit MacOS)
usage: dcm2niix [options] <in_folder>
 Options :
  -1..-9 : gz compression level (1=fastest..9=smallest, default 6)
  -b : BIDS sidecar (y/n/o [o=only: no NIfTI], default y)
   -ba : anonymize BIDS (y/n, default y)
  -c : comment stored in NIfTI aux_file (up to 24 characters)
  -d : directory search depth. Convert DICOMs in sub-folders of in_folder? (0..9, default 5)
  -f : filename (%a=antenna (coil) name, %b=basename, %c=comments, %d=description, %e=echo number, %f=folder name, %i=ID of patient, %j=seriesInstanceUID, %k=studyInstanceUID, %m=manufacturer, %n=name of patient, %p=protocol, %r=instance number, %s=series number, %t=time, %u=acquisition number, %v=vendor, %x=study ID; %z=sequence name; default '%3s_%f_%p_%t')
  -g : generate defaults file (y/n/o/i [o=only: reset and write defaults; i=ignore: reset defaults], default n)
  -h : show help
  -i : ignore derived, localizer and 2D images (y/n, default n)
  -l : losslessly scale 16-bit integers to use dynamic range (y/n, default n)
  -m : merge 2D slices from same series regardless of study time, echo, coil, orientation, etc. (y/n, default n)
  -n : only convert this series number - can be used up to 16 times (default convert all)
  -o : output directory (omit to save to input folder)
  -p : Philips precise float (not display) scaling (y/n, default y)
  -r : rename instead of convert DICOMs (y/n, default n)
  -s : single file mode, do not convert other images in folder (y/n, default n)
  -t : text notes includes private patient details (y/n, default n)
  -u : up-to-date check
  -v : verbose (n/y or 0/1/2 [no, yes, logorrheic], default 0)
  -x : crop (y/n, default n)
  -z : gz compress images (y/i/n/3, default y) [y=pigz, i=internal:zlib, n=no, 3=no,3D]
 Defaults file : /Users/julien/.dcm2nii.ini
 Examples :
  dcm2niix /Users/chris/dir
  dcm2niix -c "my comment" /Users/chris/dir
  dcm2niix -o /users/cr/outdir/ -z y ~/dicomdir
  dcm2niix -f %p_%s -b y -ba n ~/dicomdir
  dcm2niix -f mystudy%s ~/dicomdir
  dcm2niix -o "~/dir with spaces/dir" ~/dicomdir

INFO:dcm2bids:dcm2niix:version: v1.0.20181125
INFO:dcm2bids:participant: sub-99
INFO:dcm2bids:session: None
INFO:dcm2bids:config: /Users/julien/Desktop/config_spine.txt
INFO:dcm2bids:BIDS directory: /Users/julien/Desktop
INFO:dcm2bids:
INFO:dcm2bids:--- running dcm2niix ---
INFO:dcm2bids:subprocess: dcm2niix -b y -ba y -z y -f '%3s_%f_%p_%t' -o /Users/julien/Desktop/tmp_dcm2bids/sub-99 20180611_prisma/DICOM/
INFO:dcm2bids:
Chris Rorden's dcm2niiX version v1.0.20181125  (JP2:OpenJPEG) (JP-LS:CharLS) Clang8.1.0 (64-bit MacOS)
Found 398 DICOM file(s)
Warning: interpolated protocol 'Localizer' may be unsuitable for dwidenoise/mrdegibbs. 20180611_prisma/DICOM/20180611/18550000/55350010/37578694
Warning: interpolated protocol 'Localizer' may be unsuitable for dwidenoise/mrdegibbs. 20180611_prisma/DICOM/20180611/18550000/55350010/37578587
Convert 192 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/003_DICOM_T1w_20180611174332 (260x320x192x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/003_DICOM_T1w_20180611174332.nii"
slices stacked despite varying acquisition numbers (if this is not desired recompile with 'mySegmentByAcq')
Warning: Weird CSA 'ProtocolSliceNumber' (System/Miscellaneous/ImageNumbering reversed): VALIDATE SLICETIMING AND BVECS
Saving 35 DTI gradients. Validate vectors.
Convert 35 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/005_DICOM_DWI_20180611174332 (96x36x15x35)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/005_DICOM_DWI_20180611174332.nii"
Convert 64 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/004_DICOM_T2w_20180611174332 (320x320x64x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/004_DICOM_T2w_20180611174332.nii"
Convert 22 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/007_DICOM_GRE-MT0_20180611174332 (256x256x22x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/007_DICOM_GRE-MT0_20180611174332.nii"
Convert 22 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/008_DICOM_GRE-T1w_20180611174332 (256x256x22x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/008_DICOM_GRE-T1w_20180611174332.nii"
slices not stacked: orientation varies (vNav or localizer?) [1 0 0 0 0 -1] != [0 1 0 0 0 -1]
Convert 5 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/002_DICOM_Localizer_20180611174332_i00004 (512x512x5x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/002_DICOM_Localizer_20180611174332_i00004.nii"
Warning: Weird CSA 'ProtocolSliceNumber' (System/Miscellaneous/ImageNumbering reversed): VALIDATE SLICETIMING AND BVECS
Convert 15 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/009_DICOM_GRE-ME_20180611174332 (448x448x15x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/009_DICOM_GRE-ME_20180611174332.nii"
Convert 22 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/006_DICOM_GRE-MT1_20180611174332 (256x256x22x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/006_DICOM_GRE-MT1_20180611174332.nii"
Convert 5 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/001_DICOM_Localizer_20180611174332_i00004 (512x512x5x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/001_DICOM_Localizer_20180611174332_i00004.nii"
Warning: Weird CSA 'ProtocolSliceNumber' (System/Miscellaneous/ImageNumbering reversed): VALIDATE SLICETIMING AND BVECS
Convert 3 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/002_DICOM_Localizer_20180611174332_i00001 (512x512x3x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/002_DICOM_Localizer_20180611174332_i00001.nii"
Warning: Weird CSA 'ProtocolSliceNumber' (System/Miscellaneous/ImageNumbering reversed): VALIDATE SLICETIMING AND BVECS
Convert 3 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/001_DICOM_Localizer_20180611174332_i00001 (512x512x3x1)
compress: "/Applications/mricron/pigz" -n -f -6 "/Users/julien/Desktop/tmp_dcm2bids/sub-99/001_DICOM_Localizer_20180611174332_i00001.nii"
Conversion required 1.627434 seconds (0.474355 for core code).

INFO:dcm2bids:
INFO:dcm2bids:Sidecars matching:
INFO:dcm2bids:NO MATCH        001_DICOM_Localizer_20180611174332_i00001.json
INFO:dcm2bids:NO MATCH        001_DICOM_Localizer_20180611174332_i00004.json
INFO:dcm2bids:NO MATCH        002_DICOM_Localizer_20180611174332_i00001.json
INFO:dcm2bids:NO MATCH        002_DICOM_Localizer_20180611174332_i00004.json
INFO:dcm2bids:MATCH           003_DICOM_T1w_20180611174332.json
INFO:dcm2bids:MATCH           004_DICOM_T2w_20180611174332.json
INFO:dcm2bids:MATCH           005_DICOM_DWI_20180611174332.json
INFO:dcm2bids:MATCH           006_DICOM_GRE-MT1_20180611174332.json
INFO:dcm2bids:MATCH           007_DICOM_GRE-MT0_20180611174332.json
INFO:dcm2bids:MATCH           008_DICOM_GRE-T1w_20180611174332.json
INFO:dcm2bids:MATCH           009_DICOM_GRE-ME_20180611174332.json
INFO:dcm2bids:
INFO:dcm2bids:Checking if a description matches several sidecars ...
INFO:dcm2bids:
INFO:dcm2bids:moving acquisitions into BIDS output directory

Output with dcm2niix v1.0.20170130

dcm2bids -d 20180611_prisma/DICOM/ -p sub-99 -c config_spine.txt 
INFO:dcm2bids:--- dcm2bids start ---
INFO:dcm2bids:subprocess: dcm2niix
INFO:dcm2bids:
Compression will be faster with /usr/local/bin/pigz
Chris Rorden's dcm2niiX version v1.0.20170130 (openJPEG build) (64-bit MacOS)
usage: dcm2niix [options] <in_folder>
 Options :
  -b : BIDS sidecar (y/n, default n)
  -f : filename (%a=antenna  (coil) number, %c=comments, %d=description, %e echo number, %f=folder name, %i ID of patient, %m=manufacturer, %n=name of patient, %p=protocol, %s=series number, %t=time, %u=acquisition number, %z sequence name; default '%3s_%f_%p_%t')
  -h : show help
  -m : merge 2D slices from same series regardless of study time, echo, coil, orientation, etc. (y/n, default n)
  -o : output directory (omit to save to input folder)
  -s : single file mode, do not convert other images in folder (y/n, default n)
  -t : text notes includes private patient details (y/n, default n)
  -v : verbose (y/n, default n)
  -x : crop (y/n, default n)
  -z : gz compress images (y/i/n, default y) [y=pigz, i=internal, n=no]
 Defaults file : /Users/julien/.dcm2nii.ini
 Examples :
  dcm2niix /Users/chris/dir
  dcm2niix -o /users/cr/outdir/ -z y ~/dicomdir
  dcm2niix -f mystudy%s ~/dicomdir
  dcm2niix -o "~/dir with spaces/dir" ~/dicomdir

INFO:dcm2bids:dcm2niix:version: v1.0.20170130
INFO:dcm2bids:participant: sub-99
INFO:dcm2bids:session: None
INFO:dcm2bids:config: /Users/julien/Desktop/config_spine.txt
INFO:dcm2bids:BIDS directory: /Users/julien/Desktop
INFO:dcm2bids:
INFO:dcm2bids:--- running dcm2niix ---
INFO:dcm2bids:subprocess: dcm2niix -b y -ba y -z y -f '%3s_%f_%p_%t' -o /Users/julien/Desktop/tmp_dcm2bids/sub-99 20180611_prisma/DICOM/
INFO:dcm2bids:
Compression will be faster with /usr/local/bin/pigz
Chris Rorden's dcm2niiX version v1.0.20170130 (openJPEG build) (64-bit MacOS)
Found 398 DICOM image(s)
Convert 192 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/003_DICOM_T1w_20180611174332 (260x320x192x1)
slices stacked despite varying acquisition numbers (if this is not desired please recompile)
Warning: Weird CSA 'ProtocolSliceNumber' (14): SPATIAL, SLICE-ORDER AND DTI TRANSFORMS UNTESTED
Warning: DTI gradient directions only tested for axial (transverse) acquisitions. Please validate bvec files.
Convert 35 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/005_DICOM_DWI_20180611174332 (96x36x15x35)
Convert 64 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/004_DICOM_T2w_20180611174332 (320x320x64x1)
Convert 22 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/007_DICOM_GRE-MT0_20180611174332 (256x256x22x1)
Convert 22 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/008_DICOM_GRE-T1w_20180611174332 (256x256x22x1)
slices not stacked: orientation varies (localizer?) [1 0 0 0 0 -1] != [0 1 0 0 0 -1]
Convert 5 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/002_DICOM_Localizer_20180611174332 (512x512x5x1)
Warning: Weird CSA 'ProtocolSliceNumber' (14): SPATIAL, SLICE-ORDER AND DTI TRANSFORMS UNTESTED
Convert 15 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/009_DICOM_GRE-ME_20180611174332 (448x448x15x1)
Convert 22 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/006_DICOM_GRE-MT1_20180611174332 (256x256x22x1)
slices not stacked: orientation varies (localizer?) [1 0 0 0 0 -1] != [0 1 0 0 0 -1]
Convert 5 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/001_DICOM_Localizer_20180611174332 (512x512x5x1)
slices not stacked: orientation varies (localizer?) [0 1 0 0 0 -1] != [1 0 0 0 0 -1]
Warning: Weird CSA 'ProtocolSliceNumber' (5): SPATIAL, SLICE-ORDER AND DTI TRANSFORMS UNTESTED
Convert 3 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/002_DICOM_Localizer_20180611174332a (512x512x3x1)
slices not stacked: orientation varies (localizer?) [0 1 0 0 0 -1] != [1 0 0 0 0 -1]
Warning: Weird CSA 'ProtocolSliceNumber' (5): SPATIAL, SLICE-ORDER AND DTI TRANSFORMS UNTESTED
Convert 3 DICOM as /Users/julien/Desktop/tmp_dcm2bids/sub-99/001_DICOM_Localizer_20180611174332a (512x512x3x1)
Conversion required 3.553113 seconds.

INFO:dcm2bids:
INFO:dcm2bids:Sidecars matching:
INFO:dcm2bids:NO MATCH        001_DICOM_Localizer_20180611174332.json
INFO:dcm2bids:NO MATCH        001_DICOM_Localizer_20180611174332a.json
INFO:dcm2bids:NO MATCH        002_DICOM_Localizer_20180611174332.json
INFO:dcm2bids:NO MATCH        002_DICOM_Localizer_20180611174332a.json
INFO:dcm2bids:NO MATCH        003_DICOM_T1w_20180611174332.json
INFO:dcm2bids:NO MATCH        004_DICOM_T2w_20180611174332.json
INFO:dcm2bids:NO MATCH        005_DICOM_DWI_20180611174332.json
INFO:dcm2bids:NO MATCH        006_DICOM_GRE-MT1_20180611174332.json
INFO:dcm2bids:NO MATCH        007_DICOM_GRE-MT0_20180611174332.json
INFO:dcm2bids:NO MATCH        008_DICOM_GRE-T1w_20180611174332.json
INFO:dcm2bids:NO MATCH        009_DICOM_GRE-ME_20180611174332.json
INFO:dcm2bids:
INFO:dcm2bids:Checking if a description matches several sidecars ...
INFO:dcm2bids:
INFO:dcm2bids:moving acquisitions into BIDS output directory
@neurolabusc
Copy link

@jcohenadad this seems like a reasonable proposal. In general, new versions often add new tags that were not generated by older versions. This is the case here, where your config file is looking for tags that were not generated in older versions. It is very rare for a tag value to change between versions. Each commit of dcm2niix is now tested across a series of DICOM images from the different vendors, and Travis sends me an email if there is any change in the NIfTI or BIDS files relative to a previous commit. dcm2niix needs to be updated as vendors update their hardware, but we strive to maintain backward compatibility.

The main exception to this is the handling of special characters: old versions of dcm2niix would allow any character that was allowed in a filename by the operating system used for conversion. This could in theory lead to different outputs for Windows versus Unix systems. Recent versions of dcm2niix mask any characters that are illegal in the file naming of any operating system. This gives consistent results.

Assuming that later versions of dcm2niix get better, maybe one option is to have a minimum version check. In other words, if your config file was generated with dcm2niix 1.0.20181125, the user should get an error if they use an older version and a warning if they use a more recent version.

@cbedetti
Copy link
Collaborator

cbedetti commented Mar 4, 2019

I'm currently rewriting some parts of the code to deal with the other issues, implementing tests along the way.
I'll add this for sure.

@cbedetti
Copy link
Collaborator

I understand throwing an error if the version is old.
But why warn if the version is newer ?

@jcohenadad
Copy link
Contributor Author

But why warn if the version is newer ?

Assuming there could be cross-compatibility breakage, although based on @neurolabusc's comment, on new versions of dcm2niix this is less likely to happen from now on (hence the warning vs. the error).

@neurolabusc
Copy link

Yes, hopefully new versions are better, and each commit is tested against dcm_qa to highlight any regressions. However, having a warning would at least give the user a clue if a script stopped working.

If the user is connected to the web you could also check whether the user has the latest version of dcm2niix and Dcm2Bids. There are Python projects for this, but a command line CURL call can do the trick, e.g. for dcm2niix:

	#define URL "/rordenlab/dcm2niix/releases/"
	#define APIURL "\"https://api.github.com/repos" URL "latest\""
	#define HTMURL "https://github.com" URL
	#define SHELLSCRIPT "#!/usr/bin/env bash\n curl --silent " APIURL " | grep '\"tag_name\":' | sed -E 's/.*\"([^\"]+)\".*/\\1/'"

@arnaudbore
Copy link
Contributor

@cbedetti should we close this issue since it has been fixed?

@cbedetti
Copy link
Collaborator

Latest version of dcm2bids and dcm2niix are now checked directly on github and reported in the log.
Implemented with b14541a

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

4 participants