Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
2.5 kB
2
Indexable
Never
labels = ['']
default_new_index = 'annotation/pes_annot_ori.vtk'
dataset = "public-fumpe"
database = vitamin.FilesDataBaseAdaptor(root_dir = os.path.join(r"C:\Users\Leonard\Desktop\Challenge_JFR",dataset), 
                                        mhd = True,
                                        case_label_from_dir_fct = lambda d: os.path.basename(os.path.dirname(d)) + r' / ' + os.path.basename(d), 
                                        tags = 'tags.json', 
                                        landmarks = 'landmarks.json', 
                                        bboxes = 'boxes.json')


def auto_init_fct(w, dataset ="cadpe"):
    if 'annotations\\per_1_annot_ori.vtk' in w.overlays or 'annotations\\per_2_annot_ori.vtk' in w.overlays:
        w.update_mask(w.overlays['annotations\\per_1_annot_ori.vtk'])
        w.update_mask(w.overlays['annotations\\per_2_annot_ori.vtk'])
        w.qgrid_annots.change_selection(rows=[])

simplicit = vitamin.InteractSimplicit(mode = vitamin.SimplicitLocalPreset.ACCURATE)
simplicit.simplicit.set_radius_ratio(0.5)
simplicit.simplicit.set_parameter('OneClickSegmRadius', str(3.))
simplicit.simplicit.set_parameter('FirstPassMinRadius', str(3.))
ccinter = vitamin.InteractThreshold(threshold_range=[200, 600], threshold_type=vitamin.ThresholdType.OUT_IN, continuous_update=True)

annot_widget = vitamin.Segmentation3DWidget(database,
                                            overlay_alpha = 0.05,
                                            overlay_border_alpha=1.,
                                            additional_interactors=[simplicit, ccinter, vitamin.InteractCC(),],
                                            auto_init_fct = auto_init_fct,
                                            default_new_index = default_new_index,)  

lm_widget = vitamin.Landmark3DWidget(database, labels = [""])
box_widget = vitamin.Bbox3DWidget(database, labels = [""], overlay_border_alpha=1.)
tag_widget = vitamin.TaggingWidget(database, tags = [''])

viewer = vitamin.Annotator3D(database, annotation_widgets={
                                'Im. Tr.': vitamin.ImageTransformWidget(database, transforms = [vitamin.InteractSmoothData(),]),
                                'Segmentation': annot_widget,
                                'Landmarks': lm_widget,
                                'BBox': box_widget,
                                'Tag': tag_widget}, 
                                 display_crosshair = True, intensity_range = [-400, 600])