Issue using Dcm2niixPlugin for 4D DTI Dicom data

Hi, I have been using Dcm2niixPlugin to convert 4D DTI Dicom files to a 4D NIFTI file (.nii).

However, when I checked the output from the plugin’s load(self,loadable) function, it returned a 3D volume node while it’s supposed to return a 4D volume (or a series of 3D volumes).

I tried tracing the issue and noticed that load(self,loadable) function has a call to slicer.util.loadVolume() at line 175.

While dcm2niix command correctly produced a 4D NIFTI file, it appears that a call to the loadVolume() has converted it to a 3D volume. According to this related post and my testing, I believe 4D NIFTI file can’t be properly loaded using slicer.util.loadVolume(). (Please correct me if I am wrong.)

So I was wondering why we are using slicer.util.loadVolume() instead of MultiVolumeImporter as mentioned in this post.

Any explanation would be greatly appreciated. Thank you in advance for your help!

If the plugin isn’t working for your data I’d suggest running dcm2niix independently from Slicer to confirm that your data is compatible.

There’s a nrrd export option for dcm2niix that should make the results directly compatible with SlicerDMRI. If it turns out your data isn’t compatible, the dcm2niix developer may be able to help.

1 Like

Thank you @pieper for your reply.

I tried running dcm2niix independently and checked that my data is compatible. It produced a 4D .nii file.

The part that I still don’t understand from the plugin is that call to slicer.util.loadVolume() at line 175. By any chance, do you know why it’s calling loadVolume() instead of MultiVolumeImporter.read4DNIfTI()? Is that a mistake or was the plugin designed to support only 3D Dicoms and not 4D dicoms?

Thank you for your help!

I think dcm2niix can create nrrd files. If you generate a 4D nrrd file then Slicer should be able to read it (just choose “Volume Sequence” in the “Description” column in “Add data” window).

1 Like

If the scan is a compatible dwi scan (depends on both the scanner model and acquisition protocol) then dcm2niix can convert it to a valid nrrd file. slicer.util.loadVolume automatically detects and loads nrrd files as scalar, vector, tensor, or dwi automatically based on the content.

1 Like

Thank you for your prompt replies @lassoan & @pieper!

I followed your suggestion and changed the dcm2niixPlugin to convert it to a 4D .nrrd file and now the slicer.util.loadVolume() works well.

Screen Shot 2021-06-30 at 2.10.08 PM

And now I would like to save the loaded 4D nrrd volume to 4D NIFTI file but slicer.util.saveNode() doesn’t seem to allow me to do that. Is there a way I can save a 4D nrrd to a 4D NIFTI?

Screen Shot 2021-06-30 at 2.08.29 PM

Not directly in Slicer but you can use this code:

1 Like

Thank you @pieper! I will try using the conversion package.