# Reading a 4D volume (3D + time) from a dcm format and plotting it

**URL:** https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832
**Category:** Uncategorized
**Tags:** python, dicom, simpleitk
**Created:** [March 16, 2020, 2:44pm UTC](https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832 "2020-03-16T14:44:44Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![bjce](https://discourse.itk.org/user_avatar/discourse.itk.org/bjce/32/1310_2.png) [@bjce](https://discourse.itk.org/u/bjce)
#### Post date: [March 16, 2020, 2:44pm UTC](https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832/1 "2020-03-16T14:44:44Z")

</div>

Hi everyone. I have a DICOM from echocardiography which is a 4D Volume (3D space + time) that I could save in a .dcm format. I want to use SimpleITK to open it and plot it. Is it possible to read the .dcm file and plot it directly or should I convert it into a .nii first (e.g. through MITK)?

Many Thanks in advance

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [March 16, 2020, 3:13pm UTC](https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832/2 "2020-03-16T15:13:41Z")

</div>

Hello @bjce

The original DICOM should be readable using SimpleITK, but till you try you won’t know:

```auto
import SimpleITK as sitk
file_name = 'abc.dcm'

image = sitk.ReadImage(file_name)

# Not sure if Fiji will work as expected, but should.
sitk.Show(image)

```

---

<div class="post-metadata">

### Author: ![bjce](https://discourse.itk.org/user_avatar/discourse.itk.org/bjce/32/1310_2.png) [@bjce](https://discourse.itk.org/u/bjce)
#### Post date: [March 16, 2020, 3:19pm UTC](https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832/3 "2020-03-16T15:19:29Z")

</div>

Many thanks @zivy for your answer. I copied your code in a file that I named `read\_dcm.py" and ran it. I got the following message:

```auto
Traceback (most recent call last):
  File "read_dcm.py", line 7, in <module>
    sitk.Show(image)
  File "/research/3D_Dicom_reader/py3_8_3D_Dicom/lib/python3.8/site-packages/SimpleITK/SimpleITK.py", line 7887, in Show
    return _SimpleITK.Show(*args, **kwargs)
RuntimeError: Exception thrown in SimpleITK Show: /Users/runner/runners/2.160.0/work/1/sitk/Code/IO/src/sitkShow.cxx:495:
sitk::ERROR: No appropriate executable found.

```

Do you have any idea about what I could try next?

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [March 16, 2020, 3:27pm UTC](https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832/4 "2020-03-16T15:27:31Z")

</div>

The good news is that it looks like reading the image works.

The “bad” news, SimpleITK couldn’t find the Fiji image viewer. This is easily corrected.  
Do you have Fiji installed? If yes, it may not be in the expected location ([details in the FAQ](https://simpleitk.readthedocs.io/en/master/faq.html#why-isn-t-imagej-found-by-the-show-function-runtimeerror-exception-thrown)). You can [use another viewer](https://simpleitk.readthedocs.io/en/master/faq.html#can-i-use-another-image-file-viewer-beside-imagej) (e.g. ITK-SNAP) if you already have it installed.

---

<div class="post-metadata">

### Author: ![bjce](https://discourse.itk.org/user_avatar/discourse.itk.org/bjce/32/1310_2.png) [@bjce](https://discourse.itk.org/u/bjce)
#### Post date: [March 16, 2020, 4:01pm UTC](https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832/5 "2020-03-16T16:01:44Z")

</div>

Many thanks for your answer @zivy

The output of the command is:

```auto
Debug: In /Users/runner/runners/2.160.0/work/1/sitk/Code/IO/src/sitkShow.cxx, line 434: FindApplication search path: [/Applications, /Applications/, /Developer, /opt/, /usr/local/]
Result:

Debug: In /Users/runner/runners/2.160.0/work/1/sitk/Code/IO/src/sitkShow.cxx, line 434: FindApplication search path: [/Applications, /Applications/ImageJ, /Developer, /opt/ImageJ, /usr/local/ImageJ]
Result:

Debug: In /Users/runner/runners/2.160.0/work/1/sitk/Code/IO/src/sitkShow.cxx, line 434: FindApplication search path: [/Applications, /Applications/ImageJ, /Developer, /opt/ImageJ, /usr/local/ImageJ]
Result:

Traceback (most recent call last):
  File "show_path.py", line 8, in <module>
    sitk.Show(image, debugOn=True)
  File "/Users/.../py3_8_3D_Dicom/lib/python3.8/site-packages/SimpleITK/SimpleITK.py", line 7887, in Show
    return _SimpleITK.Show(*args, **kwargs)
RuntimeError: Exception thrown in SimpleITK Show: /Users/runner/runners/2.160.0/work/1/sitk/Code/IO/src/sitkShow.cxx:495:
sitk::ERROR: No appropriate executable found.

```

---

<div class="post-metadata">

### Author: ![bjce](https://discourse.itk.org/user_avatar/discourse.itk.org/bjce/32/1310_2.png) [@bjce](https://discourse.itk.org/u/bjce)
#### Post date: [March 16, 2020, 4:11pm UTC](https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832/6 "2020-03-16T16:11:42Z")

</div>

Ok, in terminal, I entered:

```auto
export SITK_SHOW_COMMAND=/Applications/Slicer.app/Contents/MacOS/Slicer

```

And that successfully linked the ITK viewer to Slicer. In the meantime I also installed Fiji but couldn’t link with

```auto
export SITK_SHOW_COMMAND=/Applications/Fiji.app

```

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [March 16, 2020, 4:14pm UTC](https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832/7 "2020-03-16T16:14:33Z")

</div>

Hello @bjce,

The output is just showing us all the paths in which the code was searching for Fiji but couldn’t find it. Is Fiji installed in one of these locations?

If not, you can [download it](https://fiji.sc/#download) and install:

- Windows: into your user directory (e.g. C:\Users[your\_user\_name]).
- Linux: into ~/bin/ .
- Mac: into /Applications/

---

<div class="post-metadata">

### Author: ![bjce](https://discourse.itk.org/user_avatar/discourse.itk.org/bjce/32/1310_2.png) [@bjce](https://discourse.itk.org/u/bjce)
#### Post date: [March 16, 2020, 4:22pm UTC](https://discourse.itk.org/t/reading-a-4d-volume-3d-time-from-a-dcm-format-and-plotting-it/2832/8 "2020-03-16T16:22:29Z")

</div>

Ok it worked! Many thanks for your help @zivy!
