reading dicom issue

I have an issue about reading dicom series
the code is

#!/usr/bin/env python
# _*_ coding:utf-8 _*_
import vtkmodules.all as vtk

if __name__ == '__main__':
    # reader the dicom file
    reader = vtk.vtkDICOMImageReader()
    reader.SetDirectoryName('series-00000')
    # reader.SetDirectoryName('/home/icml-hqu/digest_article')
    reader.Update()

And I got an error like this

2021-12-19 15:04:12.133 (   0.252s) [        B51EB0C0]vtkDICOMImageReader.cxx:326    ERR| vtkDICOMImageReader (0x55df201ad0b0): There was a problem retrieving data from: series-00000/image-00000.dcm
2021-12-19 15:04:12.133 (   0.252s) [        B51EB0C0]       vtkExecutive.cxx:752    ERR| vtkCompositeDataPipeline (0x55df208d6d90): Algorithm vtkDICOMImageReader(0x55df201ad0b0) returned failure for request: vtkInformation (0x55df208d7710)
  Debug: Off
  Modified Time: 205
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_DATA
  FROM_OUTPUT_PORT: 0
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0

the dicom series have 361 dicom files


the enviornment is :
os:ubuntu18.04
python 3.7.10
vtk9.1.0

I seems wired because I can read the dataset at https://kitware.github.io/vtk-examples/site/Cxx/IO/ReadDICOMSeries/ normally.

The “problem retrieving data” error usually means that the image is compressed.
The vtkDICOMImageReader is not able to read compressed images.

One simple way to check if the DICOMs are compressed is to check the file sizes. If all the files in the series have nearly the same file size, then they are probably not compressed. If all the files have different sizes, they are probably compressed. (This is because the compression algorithms will always do better on some images than on others).

1 Like

Hi @dgobbi,

Is there any method to do this in VTK itself, I found your repo (GitHub - dgobbi/vtk-dicom: A set of classes for using DICOM in VTK.) but it is unclear for me the usage of it in python.

Thanks
Aju