MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / LabelFrames

Class LabelFrames

deeplabcut/gui/tabs/label_frames.py:101–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99
100
101class LabelFrames(DefaultTab):
102 def __init__(self, root, parent, h1_description):
103 super().__init__(root, parent, h1_description)
104
105 self._set_page()
106
107 def _set_page(self):
108 self.label_frames_btn = QtWidgets.QPushButton("Label Frames")
109 self.label_frames_btn.clicked.connect(self.label_frames)
110 self.check_labels_btn = QtWidgets.QPushButton("Check Labels")
111 self.check_labels_btn.clicked.connect(self.check_labels)
112 self.build_skeleton_btn = QtWidgets.QPushButton("Build skeleton")
113 self.build_skeleton_btn.clicked.connect(self.build_skeleton)
114 self.main_layout.addWidget(self.label_frames_btn, alignment=Qt.AlignLeft)
115 self.main_layout.addWidget(self.check_labels_btn, alignment=Qt.AlignLeft)
116 self.main_layout.addWidget(self.build_skeleton_btn, alignment=Qt.AlignLeft)
117
118 def log_color_by_option(self, choice):
119 self.root.logger.info(f"Labeled images will by colored by {choice.upper()}")
120
121 def label_frames(self):
122 dialog = QtWidgets.QFileDialog(self)
123 dialog.setFileMode(QtWidgets.QFileDialog.Directory)
124 dialog.setViewMode(QtWidgets.QFileDialog.Detail)
125 dialog.setDirectory(os.path.join(os.path.dirname(self.root.config), "labeled-data"))
126 if dialog.exec_():
127 folder = dialog.selectedFiles()[0]
128 has_h5 = False
129 for file in os.listdir(folder):
130 if file.endswith(".h5"):
131 has_h5 = True
132 break
133 if not has_h5:
134 folder = [folder, self.root.config]
135 _ = launch_napari(folder)
136
137 def check_labels(self):
138 check_labels(self.root.config, visualizeindividuals=self.root.is_multianimal)
139 labeled_images = (Path(self.root.config).parent / "labeled-data").rglob("*_labeled/*.png")
140 _ = launch_napari(labeled_images, plugin="napari", stack=True)
141
142 def build_skeleton(self, *args):
143 SkeletonBuilder(self.root.config)

Callers 1

add_tabsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected