Skip to content

Commit

Permalink
Add DeepLabCut import to menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
ntabris committed Mar 11, 2020
1 parent 24f8bfd commit 0883987
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ def add_submenu_choices(menu, title, options, key):
"COCO dataset...",
self.commands.importCoco,
)
add_menu_item(
import_types_menu,
"import_dlc",
"DeepLabCut dataset...",
self.commands.importDLC,
)
add_menu_item(
import_types_menu,
"import_dpk",
Expand Down
35 changes: 35 additions & 0 deletions sleap/gui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ def importCoco(self):
"""Imports COCO datasets."""
self.execute(ImportCoco)

def importDLC(self):
"""Imports DeepLabCut datasets."""
self.execute(ImportDeepLabCut)

def importLEAP(self):
"""Imports LEAP matlab datasets."""
self.execute(ImportLEAP)
Expand Down Expand Up @@ -581,6 +585,37 @@ def ask(context: "CommandContext", params: dict) -> bool:
return True


class ImportDeepLabCut(AppCommand):
@staticmethod
def do_action(context: "CommandContext", params: dict):

labels = Labels.load_deeplabcut_csv(
filename=params["filename"]
)

new_window = context.app.__class__()
new_window.showMaximized()
new_window.loadLabelsObject(labels=labels)

@staticmethod
def ask(context: "CommandContext", params: dict) -> bool:
filters = ["CSV (*.csv)"]

filename, selected_filter = FileDialog.open(
context.app,
dir=None,
caption="Import DeepLabCut dataset...",
filter=";;".join(filters),
)

if len(filename) == 0:
return False

params["filename"] = filename

return True


class SaveProjectAs(AppCommand):
@staticmethod
def _try_save(context, labels: Labels, filename: str):
Expand Down

0 comments on commit 0883987

Please sign in to comment.