DWIConvert is not working to convert DICOM to NRRD

Operating system: MacOS
Slicer version:4.10.2
Expected behavior:NRRD file
Actual behavior: I had a problem when I try to convert DICOM file to NRRD with DWIConvert library.
Everything is OK when I used Slicer tool with UI to load and save DICOM file as NRRD.
However, I have multiple DICOM files and want to convert automatically.
I use a command
/Applications/Slicer.app/Contents/lib/Slicer-4.10/cli-modules/DWIConvert -i /Users/aaa/Desktop/dicom/1.3.6.1.4.1.14519.5.2.1.6279.6001.975254950136384517744116790879 -o /Users/aaa/Desktop/dicom/a.nrrd

I got a error
Dicom images are ordered in a volume interleaving way.

ImageOrientationPatient (0020:0037): LPS Orientation Matrix

1 0 0

0 1 0

0 0 1

this->m_SpacingMatrix

0.599609 0 0

0 0.599609 0

0 0 2.5

NRRDSpaceDirection

0.599609 0 0

0 0.599609 0

0 0 2.5

Slice 0: -171.7 -153.5 -8.09

Slice 1: -171.7 -153.5 -10.59

Slice order is SI

Number of Slices: 124

Number of Volume: 1

Number of Slices in each volume: 124

WARNING: Missing B Value

Exception extracting gradient vectors

itk::ExceptionObject (0x7fb09d9a7610)

Location: “unknown”

File: /Volumes/Dashboards/Stable/Slicer-4102-build/ITK/Modules/IO/DCMTK/src/itkDCMTKFileReader.cxx

Line: 963

Description: itk::ERROR: Cant find tag 19 10bb

I found the reason is my DICOM file were removed some private tags, right?
But it is still converted by Slicer tool
Could you give me some solution.
Thank you very much.

Slicer’s dicom reader doesn’t always use DWIConvert, so it’s probably going through a different path when you use the UI.

For batch converting dicom to nrrd, there are many possible options depending on the exact data, but typically we find dcm2niix to be the best option. You can get it via slicerdmri or directly from the source (linked in thes readme).

Dear Pieper,
Thanks for your suggestion, I have tried to use dcm2niix to convert into NRRD but I have some problems:

  1. The nrrd file converted from dcm2niix has more size than 3D slicer 65MB compared with 42MB for same DICOM
  2. I have further task like create a segmentation file using MITK Phenotyping library. When I load generated .nrrd file, something is different in bordered

The output of nrrd file of dcm2niix, and it could not be done
0.489] loading /storage/cuongnc/LIDC-IDRI-processing/new_nrrd/0873a/0873a_ct_scan.nrrd via itk::ImageIOFactory…
[0.489] ioRegion: ImageIORegion (0x7fff3cf6df20)
Dimension: 3
Index: 0 0 0
Size: 512 512 124
[0.533] [135, -153.8, -6.84]
[0.533] [-172, 153.2, -316.84]

The output of nrrd file of Slicer , it works successful
0.486] loading /storage/cuongnc/LIDC-IDRI-processing/new_nrrd/0873a/0873a_ct_scan.nrrd via itk::ImageIOFactory…
[0.487] ioRegion: ImageIORegion (0x7ffc39afae40)
Dimension: 3
Index: 0 0 0
Size: 512 512 124
[1.158] [135, 153.2, -6.84]
[1.158] [-172, -153.8, -316.84]

In addition, I also use MITK Phenotyping to convert into NRRD file, but it doesnt work with some DICOM file. The NRRD files are not merged into one file, such as 0873a_ct_scan_1.nrrd, 0873a_ct_scan_2.nrrd 0873a_ct_scan_3.nrrd …

Is there a reason you are trying to use MITK Phenotyping instead of 3D Slicer? Slicer, along with extensions such as SlicerRadiomics should be able to do everything that MITK Phenotyping offers and much more.

Yeah, I agree with you, Slice is amazing tool for medical image processing with multiple extensions. But I my working environment is on the remote server and do not family with UI application along with a huge of data.
I am trying to build Slicer app and use its library to convert DICOM to NRRD file but it still do not work.
Do you have any advise for me ?
Thank you very much.

You can use pyradiomics outside of slicer.

For format conversion, it really depends on your data. Here’s some background that may help:

Volume reconstruction project

A previous thread about conversion.

@Nguyen_Cuong

  1. The nrrd file converted from dcm2niix has more size than 3D slicer 65MB compared with 42MB for same DICOM

I am very surprised by this, the NRRD header is far more concise than the DICOM header. dcm2niix will strive to losslessly convert your data. Therefore, dcm2niix files are virtually always smaller than the incoming DICOMs. The typical situation where this is not the case is where the distance between slices varies, since NRRD and NIfTI require equidistant slices. This is sometimes seen in CT scans (e.g. for CT scans of brain, more slices near brain stem, fewer slices for superior cortex), but never (to my knowledge) seen in DWI scans (where you typically desire both equidistant slices and isotropic voxels).

I also note “CT” in the file name (0873a_ct_scan) and a spatial resolution that does not look like DWI (0.6x0.6x2.5, the voxels are not isotropic, and such a high in-plane resolution would result in low SNR, strong eddy currents, huge EPI artifacts, long readout times).

Can I suggest you run dcm2niix from the command line and see what messages it gives. If this is a CT scan, interpolated slice gaps is appropriate, but if this is really a DWI scan it suggests that not all of the data was transferred.

Dear Chris_Rorden,
Thank you very much for deep knowledges about medical image. I’am just starting to work with these image types.

Blockquote
Therefore, dcm2niix files are virtually always smaller than the incoming DICOMs.

My DICOM is 65.5 MB and the output NRRD file of dcm2niix have equal size. Weird
The DICOM dataset I got from LIDC
As your proposing, I run the command line to convert DICOM to NRRD

/Applications/MRIcroGL.app/Contents/Resources/dcm2niix -f "%f_%p_%t_%s" -p n -z n -e y -b n -o "/Users/cuongnc/Desktop/dicom" "/Users/cuongnc/Desktop/dicom/1.3.6.1.4.1.14519.5.2.1.6279.6001.975254950136384517744116790879"

Compression will be faster with 'pigz' installed http://macappstore.org/pigz/

Chris Rorden's dcm2niiX version v1.0.20190902 (JP2:OpenJPEG) (JP-LS:CharLS) Clang10.0.1 (64-bit MacOS)

Found 124 DICOM file(s)

Warning: Unable to append protocol name (0018,1030) to filename (it is empty).

Convert 124 DICOM as /Users/cuongnc/Desktop/dicom/1.3.6.1.4.1.14519.5.2.1.6279.6001.975254950136384517744116790879__20000101170254_4034901608a (512x512x124x1)

NRRD writer is experimental

Conversion required 0.327573 seconds (0.320474 for core code).

Thank you very much for your solutions.
I have tried many approaches but it do not work for me :frowning:
The last way is using 3D slicer tool to convert DICOM image manually

Can you view the converted NRRD file with MRIcroGL? More details regarding MRIcroGL are here. You could also try using dcm2niix to convert to NIfTI (remove -e y from the call) instead of NRRD and see if that helps. In theory they should be the same, but NRRD is a very new feature for dcm2niix.

Yeah, it can be shown normally. The .nii generated file . as you say have the same size and can be displayed