# reads DCM volume with grid transform, python

**URL:** https://discourse.itk.org/t/reads-dcm-volume-with-grid-transform-python/5878
**Category:** Beginner Questions
**Tags:** python, dicom, transforms, simpleitk
**Created:** [April 18, 2023, 11:02pm UTC](https://discourse.itk.org/t/reads-dcm-volume-with-grid-transform-python/5878 "2023-04-18T23:02:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Thirawat](https://discourse.itk.org/user_avatar/discourse.itk.org/thirawat/32/3402_2.png) [@Thirawat](https://discourse.itk.org/u/Thirawat)
#### Post date: [April 18, 2023, 11:02pm UTC](https://discourse.itk.org/t/reads-dcm-volume-with-grid-transform-python/5878/1 "2023-04-18T23:02:53Z")

</div>

Hi all,

I have Dicom file that contains

- Dicom volume
- grid transform

so, I want to read Dicom with that transformation.  
now I can only read raw Dicom

My code:

```auto
def readDCM(folder_path, win_level=50, win_width=100):
  series_reader = sitk.ImageSeriesReader()
  series_IDs = series_reader.GetGDCMSeriesIDs(folder_path)
  if not series_IDs:
      raise Exception("No DICOMs were found in the directory. Please select a different directory.")
      
  series_file_names = series_reader.GetGDCMSeriesFileNames(folder_path, series_IDs[0])
  series_reader.SetFileNames(series_file_names)
  image = series_reader.Execute()

  image_array = sitk.GetArrayFromImage(image)
  image_array = np.clip(image_array, win_level - 0.5 - (win_width - 1) / 2, win_level - 0.5 + (win_width - 1) / 2)
  image_array = (image_array - (win_level - 0.5)) / (win_width - 1)

  return image_array

```

Best,  
Thirawat

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 19, 2023, 12:16pm UTC](https://discourse.itk.org/t/reads-dcm-volume-with-grid-transform-python/5878/2 "2023-04-19T12:16:23Z")

</div>

Maybe you need to read the DICOM transform using [IOTransformDCMTK](https://itk.org/Doxygen/html/group__IOTransformDCMTK.html)? And then apply it using [TransformGeometryImageFilter](https://itk.org/Doxygen/html/classitk_1_1TransformGeometryImageFilter.html) or ordinary resampling filter.

---

<div class="post-metadata">

### Author: ![Thirawat](https://discourse.itk.org/user_avatar/discourse.itk.org/thirawat/32/3402_2.png) [@Thirawat](https://discourse.itk.org/u/Thirawat)
#### Post date: [April 28, 2023, 4:38am UTC](https://discourse.itk.org/t/reads-dcm-volume-with-grid-transform-python/5878/3 "2023-04-28T04:38:25Z")

</div>

Thank you for the guide. but I can’t find the example usage, So I haven’t tried doing what you said.  
and now I solve all of my problems in another way.  
[if interest click this](https://discourse.slicer.org/t/transforme-segmentaion/29150/5?u=thirawat)
