Skip to content

Commit

Permalink
Add curation keyboard shortcuts (#366)
Browse files Browse the repository at this point in the history
* Move qtpy functionality to brainglobe-utils

* Prompt user before overwriting data

* Update use of brainglobe-utils functions

* Add keyboard shortcuts

---------

Co-authored-by: willGraham01 <[email protected]>
  • Loading branch information
adamltyson and willGraham01 authored Feb 7, 2024
1 parent d248806 commit 25b39a8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cellfinder/napari/curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(
self.output_directory: Optional[Path] = None

self.setup_main_layout()
self.setup_keybindings()

@self.viewer.layers.events.connect
def update_layer_list(v: napari.viewer.Viewer):
Expand Down Expand Up @@ -182,13 +183,15 @@ def add_loading_panel(self, row: int, column: int = 0):
self.load_data_layout,
self.mark_as_cell,
row=5,
tooltip="Mark all selected points as non cell. Shortcut: 'c'",
)
self.mark_as_non_cell_button = add_button(
"Mark as non cell(s)",
self.load_data_layout,
self.mark_as_non_cell,
row=5,
column=1,
tooltip="Mark all selected points as non cell. Shortcut: 'x'",
)
self.add_training_data_button = add_button(
"Add training data layers",
Expand All @@ -208,6 +211,10 @@ def add_loading_panel(self, row: int, column: int = 0):
self.load_data_panel.setVisible(True)
self.layout.addWidget(self.load_data_panel, row, column, 1, 1)

def setup_keybindings(self):
self.viewer.bind_key("c", self.mark_as_cell)
self.viewer.bind_key("x", self.mark_as_non_cell)

def set_signal_image(self):
"""
Set signal layer from current signal text box selection.
Expand Down Expand Up @@ -304,10 +311,10 @@ def _add_training_data_layers(self, cell_name: str, non_cell_name: str):
)
self.training_data_non_cell_choice.setCurrentText(non_cell_name)

def mark_as_cell(self):
def mark_as_cell(self, viewer=None):
self.mark_point_as_type("cell")

def mark_as_non_cell(self):
def mark_as_non_cell(self, viewer=None):
self.mark_point_as_type("non-cell")

def mark_point_as_type(self, point_type: str):
Expand Down

0 comments on commit 25b39a8

Please sign in to comment.