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

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

Hello @bjce

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

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)
1 Like

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:

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?

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). You can use another viewer (e.g. ITK-SNAP) if you already have it installed.

2 Likes

Many thanks for your answer @zivy

The output of the command is:

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.

Ok, in terminal, I entered:

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

export SITK_SHOW_COMMAND=/Applications/Fiji.app

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 and install:

  • Windows: into your user directory (e.g. C:\Users[your_user_name]).
  • Linux: into ~/bin/ .
  • Mac: into /Applications/
1 Like

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