# Is there any way to import 4D perfusion NIFTI image to DSCMRIAnalysis?

**URL:** <https://discourse.slicer.org/t/is-there-any-way-to-import-4d-perfusion-nifti-image-to-dscmrianalysis/3782>\
**Category:** Support\
**Created:** [August 15, 2018, 6:59am UTC](https://discourse.slicer.org/t/is-there-any-way-to-import-4d-perfusion-nifti-image-to-dscmrianalysis/3782 "2018-08-15T06:59:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyu\_Sung\_Choi](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Kyu\_Sung\_Choi](https://discourse.slicer.org/u/Kyu_Sung_Choi)\
**Post date:** [August 15, 2018, 6:59am UTC](https://discourse.slicer.org/t/is-there-any-way-to-import-4d-perfusion-nifti-image-to-dscmrianalysis/3782/1 "2018-08-15T06:59:36Z")

</div>

Dear Dr. @fedorov, and Dr. @pieper,

**Is there any way to import 4D perfusion NIFTI image to DSCMRIAnalysis?**  
I understand that currently, only DICOM images can be imported as input to DSCMRIAnalysis module.  
However, I want to make some preprocessing (e.g. motion correction, registration) of DICOM images which will be saved as NIFTI files.  
So I need to figure out if there is any way to import 4D perfusion NIFTI image to DSCMRIAnalysis.  
If it’s impossible, then **could you please tell me how to 1) correct motion artifacts and 2) register to T1 contrast enhanced images with NRRD images that were made from mpReviewPreprocessor.py _in batch mode (i.e. in command lines)_ with appropriate Slicer modules?**  
Always appreciate your response.  
Thank you in advance!

Best,  
Kyu Sung

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [August 15, 2018, 1:54pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-import-4d-perfusion-nifti-image-to-dscmrianalysis/3782/2 "2018-08-15T13:54:36Z")

</div>

Please see the answer to this question in this post: [How can I import NIFTI files to DSCMRIAnalysis module?](https://discourse.slicer.org/t/how-can-i-import-nifti-files-to-dscmrianalysis-module/3645)

---

<div class="post-metadata">

**Author:** ![Kyu\_Sung\_Choi](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Kyu\_Sung\_Choi](https://discourse.slicer.org/u/Kyu_Sung_Choi)\
**Post date:** [August 15, 2018, 11:49pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-import-4d-perfusion-nifti-image-to-dscmrianalysis/3782/3 "2018-08-15T23:49:55Z")

</div>

Dear Dr. @fedorov,

Thanks to your help, I’ve already tried @pieper’s python code, and it was successful in saving NIFTI files in NRRD files.  
However, when I enter these NRRD files as inputs to DSCMRIAnalysis module, then _ **it does not recognize frame identifying DICOM tag** _ (error msg below).

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/1/d1ca8e949bac4a54f695f57fbfcbe1b3169d81a2.jpeg)

I’ll send you a 4D DSC DICOM as well as NIFTI files in email.  
Could you please fix this problem?  
I always appreciate it.

All the best,  
Kyu Sung

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [August 17, 2018, 6:45pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-import-4d-perfusion-nifti-image-to-dscmrianalysis/3782/4 "2018-08-17T18:45:17Z")

</div>

In the NRRD file you sent me, the attributes that are needed for the analysis are not initialized.

You should specify the following (this is how they are initialized if the DICOM series is imported directly from DICOM for the dataset you shared):

```auto
MultiVolume.FrameIdentifyingDICOMTagName:=Time
MultiVolume.FrameIdentifyingDICOMTagUnits:=ms

```

In the MultiVolumeImporter UI, you have place to initialize those:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/b/1bef49de041b11ffbe197c9b7bbc65ad482f1253.png)

You can also initialize those programmatically, as done here: [MultiVolumeImporter/MultiVolumeImporter.py at master · fedorov/MultiVolumeImporter · GitHub](https://github.com/fedorov/MultiVolumeImporter/blob/master/MultiVolumeImporter.py#L276-L277)

It does look like those attributes are not initialized from the GUI when import is done from 4D NIfTI, this is probably a bug that we should fix, but you can also fix this in your custom conversion code.

For now, I captured this in a bug report here: [MV attributes not propagated from GUI when imported from 4D NIfTI · Issue #33 · fedorov/MultiVolumeImporter · GitHub](https://github.com/fedorov/MultiVolumeImporter/issues/33)

---

<div class="post-metadata">

**Author:** ![Kyu\_Sung\_Choi](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Kyu\_Sung\_Choi](https://discourse.slicer.org/u/Kyu_Sung_Choi)\
**Post date:** [August 20, 2018, 11:57am UTC](https://discourse.slicer.org/t/is-there-any-way-to-import-4d-perfusion-nifti-image-to-dscmrianalysis/3782/5 "2018-08-20T11:57:27Z")

</div>

Dear Dr. @fedorov,

Thank you so much for your kind information.  
I managed to add some lines for the code, and the following result is acquired.

import os  
import slicer  
import MultiVolumeImporter

path1 = “/home/cndl/DSC/test/4d\_nifti/”  
path2 = “/home/cndl/DSC/test/nrrd/”  
#os.mkdir(path2)  
list = os.listdir(path1)

for filename in sorted(list):  
importer = MultiVolumeImporter.MultiVolumeImporterWidget()

mvNode = slicer.mrmlScene.CreateNodeByClass(‘vtkMRMLMultiVolumeNode’)  
slicer.mrmlScene.AddNode(mvNode)

importer.read4DNIfTI(mvNode, path1+filename)  
mvNode.SetAttribute(‘MultiVolume.FrameIdentifyingDICOMTagName’,‘Time’)  
mvNode.SetAttribute(‘MultiVolume.FrameIdentifyingDICOMTagUnits’,‘ms’)  
mvNode.SetAttribute(‘MultiVolume.DICOM.FlipAngle’,‘1.00’)  
mvNode.SetAttribute(‘MultiVolume.DICOM.EchoTime’,‘1.00’)  
mvNode.SetAttribute(‘MultiVolume.DICOM.RepetitionTime’,‘1.00’)  
fn\_ext = os.path.splitext(filename)  
true\_fn\_ext = os.path.splitext(fn\_ext[0])  
slicer.util.saveNode(mvNode, path2+true\_fn\_ext[0]+“.nrrd”)

exit()

(I’ve set all the additional information such as FlipAngle, EchoTime, and RepititionTime as ‘1.00’, which is default values of MultiVolumeImporter GUI.)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/3/4386d3066df0650776b9a6439007c66cca1e6f20.png)  
(Timing: values are seemed to be multiples of 0.00155, i.e. 0.00155 x 0, 1, 2, …, 95, which is the number of time points)

However, the “Timing:” seems a bit different from what I’ve got from the mpReviewPreprocessor.py.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/a/fa19b2d7934d3ce8a398dceebcf7152dd1647c7d.png)  
(Timing:0,1,2,3,4,)

The resultant CBV map obtained from DSCMRIAnalysis is attached below.

1. with NRRD from read4DNIfTI  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/3/23a247a4cf067f0857228cd9d56f199aa9171972.jpeg)

2. with NRRD from mpReviewPreprocessor.py  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/d/8d8cf35e53842c06da89ef5b342db9abc17c3c08.jpeg)

I think 1), and 2) images are a bit different.  
**Do you think it’s the problem of setting the FlipAngle, EchoTime, and RepititionTime as ‘1.00’?**  
_However, I’ve changed them to 90,40,1900, which are true values from DICOM header information, and it didn’t make any difference._  
Thank you in advance!

All the best,  
Kyu Sung

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [August 20, 2018, 4:44pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-import-4d-perfusion-nifti-image-to-dscmrianalysis/3782/6 "2018-08-20T16:44:42Z")

</div>

You should also initialize frame labels:

- [https://github.com/fedorov/MultiVolumeImporter/blob/master/MultiVolumeImporter.py#L223-L229](https://github.com/fedorov/MultiVolumeImporter/blob/master/MultiVolumeImporter.py#L223-L229)
- [https://github.com/fedorov/MultiVolumeImporter/blob/master/MultiVolumeImporter.py#L274-L277](https://github.com/fedorov/MultiVolumeImporter/blob/master/MultiVolumeImporter.py#L274-L277)

All of this metainformation is not populated when importing 4d NIFTI. If you know the correct timing of the acquisition, you should change the default value of 1.

You should also populate the relevant DICOM attributes if you know them.
