Plot Dicom data in sagittal and coronal plane with "slicelocation" in stead of slice number in python

19 Views Asked by At

I'm currently using this code to plot my dicom data in all planes:

for i, s in enumerate(slices):
    img2d = s.pixel_array
    img3d[:, :, i] = img2d

However, you need to set aspects of the axis to plot the correct scale of the images. I want to change the values of "i" to the values of "s.SliceLocation"

Something like this:

for i, s in slices:
    img2d = s.pixel_array
    slices = s.slicelocations
    img3d[:, :, i] = img2d, slices(i)

I tried different methods but it keeps giving me errors like:

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

Or that the first column is filled with the values of slicelocation.

Can someone help me to figure this out?

0

There are 0 best solutions below