Skip to content

Commit 25b39a8

Browse files
Add curation keyboard shortcuts (#366)
* 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]>
1 parent d248806 commit 25b39a8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cellfinder/napari/curation.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(
7070
self.output_directory: Optional[Path] = None
7171

7272
self.setup_main_layout()
73+
self.setup_keybindings()
7374

7475
@self.viewer.layers.events.connect
7576
def update_layer_list(v: napari.viewer.Viewer):
@@ -182,13 +183,15 @@ def add_loading_panel(self, row: int, column: int = 0):
182183
self.load_data_layout,
183184
self.mark_as_cell,
184185
row=5,
186+
tooltip="Mark all selected points as non cell. Shortcut: 'c'",
185187
)
186188
self.mark_as_non_cell_button = add_button(
187189
"Mark as non cell(s)",
188190
self.load_data_layout,
189191
self.mark_as_non_cell,
190192
row=5,
191193
column=1,
194+
tooltip="Mark all selected points as non cell. Shortcut: 'x'",
192195
)
193196
self.add_training_data_button = add_button(
194197
"Add training data layers",
@@ -208,6 +211,10 @@ def add_loading_panel(self, row: int, column: int = 0):
208211
self.load_data_panel.setVisible(True)
209212
self.layout.addWidget(self.load_data_panel, row, column, 1, 1)
210213

214+
def setup_keybindings(self):
215+
self.viewer.bind_key("c", self.mark_as_cell)
216+
self.viewer.bind_key("x", self.mark_as_non_cell)
217+
211218
def set_signal_image(self):
212219
"""
213220
Set signal layer from current signal text box selection.
@@ -304,10 +311,10 @@ def _add_training_data_layers(self, cell_name: str, non_cell_name: str):
304311
)
305312
self.training_data_non_cell_choice.setCurrentText(non_cell_name)
306313

307-
def mark_as_cell(self):
314+
def mark_as_cell(self, viewer=None):
308315
self.mark_point_as_type("cell")
309316

310-
def mark_as_non_cell(self):
317+
def mark_as_non_cell(self, viewer=None):
311318
self.mark_point_as_type("non-cell")
312319

313320
def mark_point_as_type(self, point_type: str):

0 commit comments

Comments
 (0)