Converting a series of MR case to numpy array

Viewed 20

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.

1 Answers

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