Skip to content

Commit

Permalink
Merge pull request #287 from pyplati/handle-transform-override
Browse files Browse the repository at this point in the history
Warn which inconsistent slice thickness
  • Loading branch information
pchlap authored Aug 20, 2024
2 parents 596437d + 9e49e68 commit e83359f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions platipy/dicom/io/rtstruct_to_nifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def transform_point_set_from_dicom_struct(dicom_image, dicom_struct, spacing_ove

# Track in case something goes wrong in here we will skip the contour
skip_contour = False
last_z_loc = None
for sl in range(len(struct_point_sequence[struct_index].ContourSequence)):

contour_data = fix_missing_data(
Expand All @@ -181,6 +182,11 @@ def transform_point_set_from_dicom_struct(dicom_image, dicom_struct, spacing_ove
skip_contour = True
break

if last_z_loc is not None and np.abs((np.abs(vertex_arr_physical[2][0] - last_z_loc)) - dicom_image.GetSpacing()[2]) > 0.01:
logger.warning("RTSTRUCT slice increment doesn't match image spacing. Check data and override if necessary.")

last_z_loc = vertex_arr_physical[2][0]

if z_index >= dicom_image.GetSize()[2]:
logger.debug("Warning: Slice index greater than image size. Skipping slice.")
logger.debug("Structure: %s", struct_name)
Expand Down

0 comments on commit e83359f

Please sign in to comment.