def create_cornea(pm, examination, ss, source_roi, box_roi, roi, subtraction_roi): if SSF.has_named_roi_with_contours(ss, source_roi.name): center_x = SSF.roi_center_x(ss, source_roi.name) center_z = SSF.roi_center_z(ss, source_roi.name) source_roi_box = ss.RoiGeometries[source_roi.name].GetBoundingBox() y_min = source_roi_box[1].y if y_min > 0: y_min = -source_roi_box[1].y delete_roi(pm, box_roi.name) box = pm.CreateRoi(Name=box_roi.name, Color=box_roi.color, Type=box_roi.type) pm.RegionsOfInterest[box_roi.name].CreateBoxGeometry( Size={ 'x': 5, 'y': 5, 'z': 4 }, Examination=examination, Center={ 'x': center_x, 'y': y_min + 2.5, 'z': center_z }) exclude_roi_from_export(pm, box_roi.name) if source_roi.name == ROIS.lens_l.name: wall_roi = ROIS.z_eye_l elif source_roi.name == ROIS.lens_r.name: wall_roi = ROIS.z_eye_r delete_roi(pm, wall_roi.name) create_wall_roi(pm, examination, ss, wall_roi) exclude_roi_from_export(pm, wall_roi.name) if not SSF.is_approved_roi_structure(ss, roi.name): if is_approved_roi_structure_in_one_of_all_structure_sets( pm, roi.name): intersection = ROI.ROIAlgebra(roi.name + "1", roi.type, roi.color, sourcesA=[source_roi], sourcesB=[box_roi], operator='Intersection') # In the rare case that this ROI already exists, delete it (to avoid a crash): delete_roi(pm, intersection.name) create_algebra_roi(pm, examination, ss, intersection) GUIF.handle_creation_of_new_roi_because_of_approved_structure_set( intersection.name) else: subtraction = ROI.ROIAlgebra(subtraction_roi.name, subtraction_roi.type, subtraction_roi.color, sourcesA=[wall_roi], sourcesB=[box_roi], operator='Subtraction') # In the rare case that this ROI already exists, delete it (to avoid a crash): delete_roi(pm, subtraction.name) create_algebra_roi(pm, examination, ss, subtraction) else: GUIF.handle_missing_roi_for_derived_rois(subtraction_roi.name, source_roi.name)
def create_bottom_part_x_cm(pm, examination, ss, source_roi, roi, distance): if SSF.has_named_roi_with_contours(ss, source_roi.name): center_x = SSF.roi_center_x(ss, source_roi.name) center_y = SSF.roi_center_y(ss, source_roi.name) center_z = SSF.roi_center_z(ss, source_roi.name) source_roi_box = ss.RoiGeometries[source_roi.name].GetBoundingBox() x_min = source_roi_box[0].x x_max = source_roi_box[1].x x = source_roi_box[1].x - source_roi_box[0].x y_min = source_roi_box[0].y y_max = source_roi_box[1].y y = source_roi_box[1].y - source_roi_box[0].y z_min = source_roi_box[0].z z = source_roi_box[1].z - source_roi_box[0].z z_cutoff = z_min + distance / 2 delete_roi(pm, ROIS.box.name) box = pm.CreateRoi(Name=ROIS.box.name, Color=ROIS.box.color, Type=ROIS.box.type) pm.RegionsOfInterest[ROIS.box.name].CreateBoxGeometry( Size={ 'x': x, 'y': y, 'z': distance }, Examination=examination, Center={ 'x': center_x, 'y': center_y, 'z': z_cutoff }) if not SSF.is_approved_roi_structure(ss, roi.name): if is_approved_roi_structure_in_one_of_all_structure_sets( pm, roi.name): intersection = ROI.ROIAlgebra(roi.name + "1", roi.type, roi.color, sourcesA=[source_roi], sourcesB=[ROIS.box], operator='Intersection') # In the rare case that this ROI already exists, delete it (to avoid a crash): delete_roi(pm, intersection.name) create_algebra_roi(pm, examination, ss, intersection) GUIF.handle_creation_of_new_roi_because_of_approved_structure_set( intersection.name) else: intersection = ROI.ROIAlgebra(roi.name, roi.type, roi.color, sourcesA=[source_roi], sourcesB=[ROIS.box], operator='Intersection') # In the rare case that this ROI already exists, delete it (to avoid a crash): delete_roi(pm, intersection.name) create_algebra_roi(pm, examination, ss, intersection) delete_roi(pm, ROIS.box.name) else: GUIF.handle_missing_roi_for_derived_rois(roi.name, source_roi.name)