def transform_point_set_from_dicom_struct(image, dicom_struct, spacing_override=False):
    '\n    This function is used to generate a binary mask from a set of vertices.\n    This allows us to convert from DICOM-RTStruct format to any imaging format.\n\n    Args:\n        image ([SimpleITK.Image]): The image, used to copy imaging information\n            (e.g. resolution, spacing)\n        dicom_struct ([pydicom.Dataset]): The DICOM-RTStruct file\n        spacing_override (bool | tuple, optional): Overwrite the spacing.\n            Set with (axial_spacing, coronal_spacing, sagittal spacing). Defaults to False.\n\n    Returns:\n        list, list : final_struct_name_sequence, structure_list\n    '
    if spacing_override:
        current_spacing = list(image.GetSpacing())
        new_spacing = tuple([(current_spacing[k] if (spacing_override[k] == 0) else spacing_override[k]) for k in range(3)])
        image.SetSpacing(new_spacing)
    struct_point_sequence = dicom_struct.ROIContourSequence
    struct_name_sequence = ['_'.join(i.ROIName.split()) for i in dicom_struct.StructureSetROISequence]
    structure_list = []
    final_struct_name_sequence = []
    for (structIndex, structure_name) in enumerate(struct_name_sequence):
        image_blank = np.zeros(image.GetSize()[::(- 1)], dtype=np.uint8)
        logger.info('    Converting structure {0} with name: {1}'.format(structIndex, structure_name))
        if (structIndex >= len(struct_point_sequence)):
            logger.warning('    Contour sequence is missing, skipping.')
            continue
        if (not hasattr(struct_point_sequence[structIndex], 'ContourSequence')):
            logger.warning('    No contour sequence found for this structure, skipping.')
            continue
        if (len(struct_point_sequence[structIndex].ContourSequence) == 0):
            logger.warning('    Contour sequence is empty, skipping.')
            continue
        if (not (struct_point_sequence[structIndex].ContourSequence[0].ContourGeometricType == 'CLOSED_PLANAR')):
            logger.warning('    This is not a closed planar structure, skipping.')
            continue
        for sl in range(len(struct_point_sequence[structIndex].ContourSequence)):
            contour_data = fix_missing_data(struct_point_sequence[structIndex].ContourSequence[sl].ContourData)
            struct_slice_contour_data = np.array(contour_data, dtype=np.double)
            vertexArr_physical = struct_slice_contour_data.reshape((struct_slice_contour_data.shape[0] // 3), 3)
            point_arr = np.array([image.TransformPhysicalPointToIndex(i) for i in vertexArr_physical]).T
            [xVertexArr_image, yVertexArr_image] = point_arr[[0, 1]]
            zIndex = point_arr[2][0]
            if np.any((point_arr[2] != zIndex)):
                logger.error('    Axial slice index varies in contour. Quitting now.')
                logger.error('    Structure:   {0}'.format(structure_name))
                logger.error('    Slice index: {0}'.format(zIndex))
                quit()
            if (zIndex >= image.GetSize()[2]):
                logger.warning('    Slice index greater than image size. Skipping slice.')
                logger.warning('    Structure:   {0}'.format(structure_name))
                logger.warning('    Slice index: {0}'.format(zIndex))
                continue
            sliceArr = np.zeros(image.GetSize()[:2], dtype=np.uint8)
            (filledIndicesX, filledIndicesY) = polygon(xVertexArr_image, yVertexArr_image, shape=sliceArr.shape)
            sliceArr[(filledIndicesX, filledIndicesY)] = 1
            image_blank[zIndex] += sliceArr.T
        struct_image = sitk.GetImageFromArray((1 * (image_blank > 0)))
        struct_image.CopyInformation(image)
        structure_list.append(sitk.Cast(struct_image, sitk.sitkUInt8))
        structure_name_clean = re.sub('[^\\w]', '_', structure_name).upper()
        while ('__' in structure_name_clean):
            structure_name_clean = structure_name_clean.replace('__', '_')
        final_struct_name_sequence.append(structure_name_clean)
    return (final_struct_name_sequence, structure_list)
This function is used to generate a binary mask from a set of vertices.
This allows us to convert from DICOM-RTStruct format to any imaging format.

Args:
    image ([SimpleITK.Image]): The image, used to copy imaging information
        (e.g. resolution, spacing)
    dicom_struct ([pydicom.Dataset]): The DICOM-RTStruct file
    spacing_override (bool | tuple, optional): Overwrite the spacing.
        Set with (axial_spacing, coronal_spacing, sagittal spacing). Defaults to False.

Returns:
    list, list : final_struct_name_sequence, structure_list
def transform_point_set_from_dicom_struct(image, dicom_struct, spacing_override=False):
    '\n    This function is used to generate a binary mask from a set of vertices.\n    This allows us to convert from DICOM-RTStruct format to any imaging format.\n\n    Args:\n        image ([SimpleITK.Image]): The image, used to copy imaging information\n            (e.g. resolution, spacing)\n        dicom_struct ([pydicom.Dataset]): The DICOM-RTStruct file\n        spacing_override (bool | tuple, optional): Overwrite the spacing.\n            Set with (axial_spacing, coronal_spacing, sagittal spacing). Defaults to False.\n\n    Returns:\n        list, list : final_struct_name_sequence, structure_list\n    '
    if spacing_override:
        current_spacing = list(image.GetSpacing())
        new_spacing = tuple([(current_spacing[k] if (spacing_override[k] == 0) else spacing_override[k]) for k in range(3)])
        image.SetSpacing(new_spacing)
    struct_point_sequence = dicom_struct.ROIContourSequence
    struct_name_sequence = ['_'.join(i.ROIName.split()) for i in dicom_struct.StructureSetROISequence]
    structure_list = []
    final_struct_name_sequence = []
    for (structIndex, structure_name) in enumerate(struct_name_sequence):
        image_blank = np.zeros(image.GetSize()[::(- 1)], dtype=np.uint8)
        logger.info('    Converting structure {0} with name: {1}'.format(structIndex, structure_name))
        if (structIndex >= len(struct_point_sequence)):
            logger.warning('    Contour sequence is missing, skipping.')
            continue
        if (not hasattr(struct_point_sequence[structIndex], 'ContourSequence')):
            logger.warning('    No contour sequence found for this structure, skipping.')
            continue
        if (len(struct_point_sequence[structIndex].ContourSequence) == 0):
            logger.warning('    Contour sequence is empty, skipping.')
            continue
        if (not (struct_point_sequence[structIndex].ContourSequence[0].ContourGeometricType == 'CLOSED_PLANAR')):
            logger.warning('    This is not a closed planar structure, skipping.')
            continue
        for sl in range(len(struct_point_sequence[structIndex].ContourSequence)):
            contour_data = fix_missing_data(struct_point_sequence[structIndex].ContourSequence[sl].ContourData)
            struct_slice_contour_data = np.array(contour_data, dtype=np.double)
            vertexArr_physical = struct_slice_contour_data.reshape((struct_slice_contour_data.shape[0] // 3), 3)
            point_arr = np.array([image.TransformPhysicalPointToIndex(i) for i in vertexArr_physical]).T
            [xVertexArr_image, yVertexArr_image] = point_arr[[0, 1]]
            zIndex = point_arr[2][0]
            if np.any((point_arr[2] != zIndex)):
                logger.error('    Axial slice index varies in contour. Quitting now.')
                logger.error('    Structure:   {0}'.format(structure_name))
                logger.error('    Slice index: {0}'.format(zIndex))
                quit()
            if (zIndex >= image.GetSize()[2]):
                logger.warning('    Slice index greater than image size. Skipping slice.')
                logger.warning('    Structure:   {0}'.format(structure_name))
                logger.warning('    Slice index: {0}'.format(zIndex))
                continue
            sliceArr = np.zeros(image.GetSize()[:2], dtype=np.uint8)
            (filledIndicesX, filledIndicesY) = polygon(xVertexArr_image, yVertexArr_image, shape=sliceArr.shape)
            sliceArr[(filledIndicesX, filledIndicesY)] = 1
            image_blank[zIndex] += sliceArr.T
        struct_image = sitk.GetImageFromArray((1 * (image_blank > 0)))
        struct_image.CopyInformation(image)
        structure_list.append(sitk.Cast(struct_image, sitk.sitkUInt8))
        structure_name_clean = re.sub('[^\\w]', '_', structure_name).upper()
        while ('__' in structure_name_clean):
            structure_name_clean = structure_name_clean.replace('__', '_')
        final_struct_name_sequence.append(structure_name_clean)
    return (final_struct_name_sequence, structure_list)