pyplati / platipy

Processing Library and Analysis Toolkit for Medical Imaging in Python
https://pyplati.github.io/platipy/
Apache License 2.0
103 stars 24 forks source link

RTStruct to Nifti generates negative z_index #172

Open yidilozdemir opened 1 year ago

yidilozdemir commented 1 year ago
    198     filled_indices_x, filled_indices_y = polygon(
    199         x_vertex_arr_image, y_vertex_arr_image, shape=slice_arr.shape
    200     )
    201     slice_arr[filled_indices_y, filled_indices_x] = 1
--> 203     image_blank[z_index] += slice_arr
    205 if not skip_contour:
    206     struct_image = sitk.GetImageFromArray(1 * (image_blank > 0))

IndexError: index -138 is out of bounds for axis 0 with size 116

z_index is being set correctly for this contour point, which probably is a carry-over error from fix_missing_data(). I don't know the reason why, but as a solution it looks like rtstruct_to_nifti needs to have another if statement for z values below 0 that sets skip_contour argument to True.

yidilozdemir commented 1 year ago

I am also curious about a possible link between this and #165

pchlap commented 1 year ago

Thanks for the bug report @yidilozdemir. I will look into this (although might not have a chance until early January). Cheers.