-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature to extract shape keypoints from JSON files
This commit introduces a new feature to the file menu, enabling users to extract shape keypoints from JSON files. Users can now select a folder containing JSON files and input a space-separated list of instance names (e.g., 'mouse rat') to extract the shape keypoints for each instance. This functionality is accessible from the GUI, providing a convenient way for users to process their data.
- Loading branch information
1 parent
2dc5c17
commit a9dcbc0
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from qtpy.QtWidgets import (QVBoxLayout, QPushButton, | ||
QFileDialog, QLineEdit, QLabel, QDialog, | ||
QMessageBox) | ||
|
||
from annolid.postprocessing.skeletonization import main as extract_shape_keypoints | ||
|
||
|
||
class ExtractShapeKeyPointsDialog(QDialog): | ||
def __init__(self): | ||
super().__init__() | ||
self.setWindowTitle("Extract Keypoints") | ||
self.initUI() | ||
|
||
def initUI(self): | ||
layout = QVBoxLayout() | ||
|
||
self.selectFolderBtn = QPushButton("Select Folder") | ||
self.selectFolderBtn.clicked.connect(self.selectFolder) | ||
layout.addWidget(self.selectFolderBtn) | ||
|
||
self.folderLabel = QLabel() | ||
layout.addWidget(self.folderLabel) | ||
|
||
self.instanceNamesEdit = QLineEdit() | ||
self.instanceNamesEdit.setPlaceholderText( | ||
"Enter instance names separated by space") | ||
layout.addWidget(self.instanceNamesEdit) | ||
|
||
self.runBtn = QPushButton("Run") | ||
self.runBtn.clicked.connect(self.extract_keypoints) | ||
layout.addWidget(self.runBtn) | ||
|
||
self.setLayout(layout) | ||
|
||
def selectFolder(self): | ||
folder = QFileDialog.getExistingDirectory(self, "Select Folder") | ||
if folder: | ||
self.folderLabel.setText(folder) | ||
|
||
def extract_keypoints(self): | ||
input_folder = self.folderLabel.text() | ||
instance_names = self.instanceNamesEdit.text().split() | ||
extract_shape_keypoints(input_folder, instance_names) | ||
# Display message to the user | ||
QMessageBox.information(self, "Processing Complete", "Processing is complete.") | ||
self.accept() |