1

I have an MR case and i want to to convert the Each series (which consisit of multiple dicoms) into numpy array which i will be sending for an infrencing. But i am not able to convert that MR series (which i am considering as a 3D (number of slices in a series, len, breadth)).

Can any one please help me on that please.

NeedToCodeAgain
  • 129
  • 2
  • 9
  • There is an [example](https://github.com/pydicom/contrib-pydicom/blob/ad7d60e73da0b45f67217d0e66ef8e09078ac5c7/input-output/pydicom_series.py) in `contrib-pydicom` which you can use. – MrBean Bremen Sep 02 '22 at 07:19

1 Answers1

1

You can use SimpleITK as an alternative to pydicom.

import SimpleITK as sitk

# set up the DICOM filename reader
reader = sitk.ImageSeriesReader()

# this function returns a list of DICOM files in the correct order
dcm_list = reader.GetGDCMSeriesFileNames("path/to/dicom/directory")

# load the image in
img = sitk.ReadImage(dcm_list)

# now convert to array
arr = sitk.GetArrayFromImage(arr)
Robbie
  • 4,672
  • 1
  • 19
  • 24