platipy icon indicating copy to clipboard operation
platipy copied to clipboard

RTStruct to Nifti generates negative z_index

Open yidilozdemir opened this issue 2 years ago • 2 comments

    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 avatar Dec 19 '22 19:12 yidilozdemir

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

yidilozdemir avatar Dec 19 '22 19:12 yidilozdemir

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

pchlap avatar Dec 20 '22 02:12 pchlap