# Issue using Dcm2niixPlugin for 4D DTI Dicom data

**URL:** https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402
**Category:** Support
**Tags:** extensions-manager, dicom
**Created:** [June 29, 2021, 4:49pm UTC](https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402 "2021-06-29T16:49:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![andieku](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/andieku/32/8934_2.png) [@andieku](https://discourse.slicer.org/u/andieku)
#### Post date: [June 29, 2021, 4:49pm UTC](https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402/1 "2021-06-29T16:49:30Z")

</div>

Hi, I have been using [Dcm2niixPlugin](https://github.com/SlicerDMRI/SlicerDcm2nii/blob/master/Dcm2niixPlugin/Dcm2niixPlugin.py) 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](https://github.com/SlicerDMRI/SlicerDcm2nii/blob/4f09c628c72aee04a410431c3a08168601a2cc76/Dcm2niixPlugin/Dcm2niixPlugin.py#L175).

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](https://discourse.slicer.org/t/how-can-i-import-nifti-files-to-dscmrianalysis-module/3645) 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](https://github.com/fedorov/MultiVolumeImporter) as mentioned in [this post](https://discourse.slicer.org/t/how-can-i-import-nifti-files-to-dscmrianalysis-module/3645/2).

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

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [June 29, 2021, 9:07pm UTC](https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402/2 "2021-06-29T21:07:21Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![andieku](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/andieku/32/8934_2.png) [@andieku](https://discourse.slicer.org/u/andieku)
#### Post date: [June 29, 2021, 11:32pm UTC](https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402/3 "2021-06-29T23:32:25Z")

</div>

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](https://github.com/SlicerDMRI/SlicerDcm2nii/blob/4f09c628c72aee04a410431c3a08168601a2cc76/Dcm2niixPlugin/Dcm2niixPlugin.py#L175). 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!

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [June 30, 2021, 1:53am UTC](https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402/4 "2021-06-30T01:53:40Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [June 30, 2021, 12:45pm UTC](https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402/5 "2021-06-30T12:45:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![andieku](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/andieku/32/8934_2.png) [@andieku](https://discourse.slicer.org/u/andieku)
#### Post date: [June 30, 2021, 9:15pm UTC](https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402/6 "2021-06-30T21:15:25Z")

</div>

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](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/4/b4b2d23e32fd379e4aa7ae22ec47a7c1a6d5ca0e.png)

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](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/e/ce99adb1763543047d18780d457c533aa2f6921f.png)

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [June 30, 2021, 10:52pm UTC](https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402/7 "2021-06-30T22:52:08Z")

</div>

> [@andieku](#):
>
> Is there a way I can save a 4D nrrd to a 4D NIFTI?

Not directly in Slicer but you can use this code:

> **[GitHub - pnlbwh/conversion: Various mri conversion/modification scripts](https://github.com/pnlbwh/conversion)**
>
> Various mri conversion/modification scripts. Contribute to pnlbwh/conversion development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![andieku](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/andieku/32/8934_2.png) [@andieku](https://discourse.slicer.org/u/andieku)
#### Post date: [July 5, 2021, 5:39pm UTC](https://discourse.slicer.org/t/issue-using-dcm2niixplugin-for-4d-dti-dicom-data/18402/8 "2021-07-05T17:39:09Z")

</div>

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