Description
Summary
bval and bvec files are not kept during a conversion of certain dti dicoms using the dcm2niix interface. From what I can tell this might be due the appropriate pattern not being found in the stdout of dcm2niix. This search is performed on line 307 of the dcm2nii.py interface file :
elif 'DTI gradients' in line or 'DTI gradient directions' in line:
find_b = True
(https://github.com/nipy/nipype/blob/master/nipype/interfaces/dcm2nii.py, af2b7aa)
Actual behavior
Using nipype to convert from dicom to nifti, both .nii.gz. and .json files are retrieved but the bvec and bval files are deleted during the post conversion clean up.
Expected behavior
DTI sequence dicoms yield nifti, json, bvec, and bval given the appropriate conversion flags
How to replicate the behavior
I can't share the DICOM, it was collected recently on a GE scanner (DISCOVERY MR750).
Script/Workflow details
base_dir = '/data/troubleshooting_dti_failure/'
%cd {base_dir}
/data/troubleshooting_dti_failure
Dcm2niix
mkdir dcm2niix_output
tar_list = !tar xvf dti_test_dicoms_001_001.tar.gz
tar_list[:5]
['dti_dicoms/',
'dti_dicoms/mr_0017/',
'dti_dicoms/mr_0017/edti_2mm_cdif99-00073.dcm',
'dti_dicoms/mr_0017/edti_2mm_cdif99-00163.dcm',
'dti_dicoms/mr_0017/edti_2mm_cdif99-00087.dcm']
ls
�[0m�[01;34mdcm2niix_output�[0m/ �[01;34mdti_dicoms�[0m/ �[01;32mdti_test_dicoms_001_001.tar.gz�[0m*
!dcm2niix -b y -z i -x n -t n -m n -f dwi -o /data/troubleshooting_dti_failure/dcm2niix_output \
-s n -v n /data/troubleshooting_dti_failure/dti_dicoms/mr_0013/edti_2mm_cdif09_g01-00001.dcm
Compression will be faster with /usr/local/bin/pigz
Chris Rorden's dcm2niiX version v1.0.20170314 (64-bit Linux)
Found 1680 DICOM image(s)
Reorienting edti_2mm_cdif09_G01 : 20 GE DTI vectors: please validate. isCol=1 sliceDir=3 flp=0 0 1
Convert 1680 DICOM as /data/troubleshooting_dti_failure/dcm2niix_output/dwi (128x128x84x20)
Conversion required 2.709230 seconds.
ls dcm2niix_output/
dwi.bval dwi.bvec dwi.json dwi.nii.gz
Nipype
from nipype import __version__
__version__
u'0.13.0-dev'
from nipype import Function, Node
from nipype.interfaces.base import isdefined
from nipype.interfaces.dcm2nii import Dcm2nii, Dcm2niix
import os
%cd {base_dir}
tmpdir = '/data/troubleshooting_dti_failure/nipype_dicoms'
%rm -rf {tmpdir}
%mkdir {tmpdir}
!cp -R dti_dicoms/mr_0013/* {tmpdir}
%cd {tmpdir}
/data/troubleshooting_dti_failure
/data/troubleshooting_dti_failure/nipype_dicoms
# need to be abspaths!
dicoms = list(map(os.path.abspath, os.listdir('.')))
dicoms[:5]
['/data/troubleshooting_dti_failure/nipype_dicoms/edti_2mm_cdif09_g01-01440.dcm',
'/data/troubleshooting_dti_failure/nipype_dicoms/edti_2mm_cdif09_g01-00974.dcm',
'/data/troubleshooting_dti_failure/nipype_dicoms/edti_2mm_cdif09_g01-00793.dcm',
'/data/troubleshooting_dti_failure/nipype_dicoms/edti_2mm_cdif09_g01-01367.dcm',
'/data/troubleshooting_dti_failure/nipype_dicoms/edti_2mm_cdif09_g01-00909.dcm']
converter = 'dcm2niix'
prefix_name = 'dwi'
convertnode = Node(Dcm2niix(), name='convert')
convertnode.base_dir = os.path.abspath(tmpdir)
convertnode.inputs.source_names = dicoms
convertnode.inputs.out_filename = 'dwi'
convertnode.inputs.terminal_output = 'allatonce'
res = convertnode.run()
170705-20:08:48,121 workflow INFO:
Executing node convert in dir: /data/troubleshooting_dti_failure/nipype_dicoms/convert
170705-20:08:48,853 workflow INFO:
Running: dcm2niix -b y -z i -x n -t n -m n -f dwi -o /data/troubleshooting_dti_failure/nipype_dicoms/convert -s n -v n /data/troubleshooting_dti_failure/nipype_dicoms/convert/edti_2mm_cdif09_g01-01440.dcm
res.outputs
bids = /data/troubleshooting_dti_failure/nipype_dicoms/convert/dwi.json
bvals = <undefined>
bvecs = <undefined>
converted_files = /data/troubleshooting_dti_failure/nipype_dicoms/convert/dwi.nii.gz
Please put URL to code or code here (if not too long).
https://github.com/leej3/dti_conversion_issue
Platform details:
Please paste the output of: python -c "import nipype; print(nipype.get_info()); print(nipype.__version__)"
The above command doesn't working (its python 2 in the container).
NiPipye : 0.13.0-dev
Python : 2.7
Nibabel: 2.1.0
Execution environment
Running inside the nipy/heudiconv image: sha256:8b3b92bb63ac72ced5f2f92bd9e6c9312a98ef6b503ba53f29d4623d3f8fa8e1