2

below is the python code

def load_scan(path):
print(path)
slices = [dicom.read_file(path + '/' + s) for s in os.listdir(path)]
slices.sort(key = lambda x: int(x.InstanceNumber))
try:
    slice_thickness = np.abs(slices[0].ImagePositionPatient[2] - slices[1].ImagePositionPatient[2])
except:
    slice_thickness = np.abs(slices[0].SliceLocation - slices[1].SliceLocation)

for s in slices:
    s.SliceThickness = slice_thickness

return slices


patient = load_scan(filepath)

i downloaded the sample dicom files from link

any help would be great... how to read dicom files and then process them.

Radhi
  • 6,289
  • 15
  • 47
  • 68

2 Answers2

1

Find where filereader.py is. You can see the directory from the traceback itself.

Replace raise StopIteration with return and you are set to go.

Your filereader.py directory will look like this : /usr/local/lib/python3.7/site-packages/dicom/filereader.py

Pygirl
  • 12,969
  • 5
  • 30
  • 43
0

I believe dicom is no longer supported, Use pydicom instead of dicom.