reads DCM volume with grid transform, python

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:

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


Maybe you need to read the DICOM transform using IOTransformDCMTK? And then apply it using TransformGeometryImageFilter or ordinary resampling filter.

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

1 Like