NRRD to FSL error with DWIConvert

Operating system: MacOS Mojave
3DSlicer v. 4.10.2

Hi everyone,

I have successfully used DWIConvert in Slicer to convert my dicom data to nrrd so I can process it in DTIPrep. However, I am running into problems when trying to convert the DTIPrep QCed nrrd files back into nifti using DWIConvert.

I am getting the following error message:

======= DWI Convert Tool Program=========
Error: file type of inputVoume is not supported currently
Error: the output file type is not supported currently
illegal input file type, exit
nrrd2nifti_test.sh: line 19: --inputVolume: command not found

After some time troubleshooting, I am not quite sure what has gone wrong and would greatly appreciate any help. I haven’t found a post on this topic, so my apologies if a similar problem has already been addressed.

This is the code I have used is below if that is helpful at all.

-----------------------------
### set paths to Slicer
export PATH=$PATH:/Applications/Slicer.app/Contents/lib/Slicer-4.10/cli-modules

#### Finds if path is set correctly
if [ `which DWIConvert | wc -l` -eq 0 ]; then
echo "Cannot find DWIConvert, is it in your PATH?"
exit;
fi

echo "Path found"

for directory in ????? ; do
	cd $directory
	# Convert corrected DWI image data from NRRD to NIFTI
	DWIConvert \
	--conversionMode NrrdToFSL
	--inputVolume ${directory}_QCed.nrrd \
        --outputVolume ${directory}_QCed.nii \
	--outputBValues ${directory}_QCed.bval \
	--outputBVectors ${directory}_QCed.bvec \
	--smallGradientThreshold 0.2 \

	echo $directory
	
	cd ../

done

We now suggest using dcm2niix, which has nrrd <–> nifti conversion support for diffusion. You can get it in SlicerDMRI. Also good to update to the latest preview version of Slicer.

Thanks for the tip regarding dcm2niix.

My apologies if I have completely missed something, but it seems that dcm2niix only has an option to go from dicom to NRRD using the following option in the command line.

-e : export as NRRD instead of NIfTI

I haven’t had success using dcm2niix within slicer (10.11.0) itself. I installed Slicer DMRI with the dcm2niix extension, and tried to run through the extension by adding my directory to “input directory” but no file seems to be created. It opens the data, but it does not seem to convert the NRRD file to nifti.

Let me know if I have just completely missed a step! Any help would be greatly appreciated.

Probably @Chris_Rorden can advise on dcm2niix.

For SlicerDMRI, are you working with the latest nightly preview build? If not, you should.

Hm ok I just gave this a try. I just downloaded the latest preview build of Slicer (4.11.0-2020-05-27). I then re-installed SlicerDMRI and SlicerDcm2niix.

I then go to Modules > Diffusion > Import and Export > DCM2niix(GUI). I get a GUI with the option to enter an input directory. I add my directory with only the DTIprepped files and when I click apply I get the following error message.

Screen Shot 2020-05-28 at 3.02.28 PM

I agree, that’s cryptic, and the module doesn’t have documentation that I can find.

But I believe the gui works only for directories of dwi dicom files, but there should be a command line option. @zhangfanmark or @tbillah can maybe comment?

Hi Steve, as far as I know, dcm2niix supports conversion from dicom, but not nrrd to nifti.

@amate I think there is an error in your command. It should be --outputNiftiFile, not --outputVolume.

Here is an example:
/Applications/Slicer200421.app/Contents/lib/Slicer-4.11/cli-modules/DWIConvert --conversionMode NrrdToFSL --inputVolume ~/Desktop/DTI.nrrd --outputNiftiFile ~/Desktop/a.nii --outputBValues ~/Desktop/a.bval --outputBVectors ~/Desktop/a.bvec --smallGradientThreshold 0.2 --allowLossyConversion

I know @Chris_Rorden and @tbillah were working on it and I thought it was done, but maybe it’s not in the release yet.

Hi @pieper, we made dcm2niix yield NRRD directly from dicoms apart from its default function of yielding NIFTI. However, conversion of NRRD<–>NIFTI is not the scope of dcm2niix and so it is not there.

Hi @amate, I see two issues you reported here:

  1. You are not able to convert NRRD–> NIFTI using DWIConvert:

In the community, we are inclined towards eliminating use of this converter. Instead, please use the Python tool I developed for achieving the stated conversion. dcm2niix uses the same tool to yield NRRD directly from dicoms.

  1. You are not able to run SlicerDcm2niix:

If you click on the red cross button on bottom right corner, you should find an elaborate log. If you can provide the elaborate log, we may be able to help you run that.

Hope this helps. Thanks.

1 Like

Cool - thanks @tbillah :+1: Looks like that is the direction @amate should investigate.

1 Like

Thanks @tbillah and @pieper! The Python tool worked perfectly!! Thanks for your help!

I know this is maybe too little too late to be relevant, but in the original code, you need a back slash after the line for conversionMode. That is why it is not recognizing the input volume and also thinks that --inputVolume is its own command.