Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add curation keyboard shortcuts #366

Merged
merged 6 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading