Reputation: 6339
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.
Upvotes: 2
Views: 2090
Reputation: 148
I believe dicom is no longer supported, Use pydicom instead of dicom.
Upvotes: 0
Reputation: 13349
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
Upvotes: 1