# reading dicom issue

**URL:** https://discourse.vtk.org/t/reading-dicom-issue/7431
**Category:** Support
**Created:** [December 19, 2021, 7:14am UTC](https://discourse.vtk.org/t/reading-dicom-issue/7431 "2021-12-19T07:14:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nightmare4214](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nightmare4214/32/4416_2.png) [@Nightmare4214](https://discourse.vtk.org/u/Nightmare4214)
#### Post date: [December 19, 2021, 7:14am UTC](https://discourse.vtk.org/t/reading-dicom-issue/7431/1 "2021-12-19T07:14:32Z")

</div>

I have an issue about reading dicom series  
the code is

```python
#!/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

```auto
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

 ![image](https://discourse.vtk.org/uploads/default/original/2X/4/473f362af230031376902f3786b6762e01028b3e.png)  
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/](https://kitware.github.io/vtk-examples/site/Cxx/IO/ReadDICOMSeries/) normally.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [December 20, 2021, 5:28pm UTC](https://discourse.vtk.org/t/reading-dicom-issue/7431/2 "2021-12-20T17:28:25Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ajugeorge97](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ajugeorge97/32/8455_2.png) [@ajugeorge97](https://discourse.vtk.org/u/ajugeorge97)
#### Post date: [February 13, 2024, 7:04pm UTC](https://discourse.vtk.org/t/reading-dicom-issue/7431/3 "2024-02-13T19:04:52Z")

</div>

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.](https://github.com/dgobbi/vtk-dicom)) but it is unclear for me the usage of it in python.

Thanks  
Aju
