-
Notifications
You must be signed in to change notification settings - Fork 18
Implement curation_callback and set_external_curation
#241
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
base: main
Are you sure you want to change the base?
Changes from all commits
cadfa5f
2911abf
db5eb0d
b9786e6
837b933
b4578ca
c198d6d
f6ed515
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import panel as pn | ||
| from pathlib import Path | ||
| from spikeinterface import load_sorting_analyzer | ||
| from spikeinterface_gui import run_mainwindow | ||
|
|
||
| pn.extension() | ||
|
|
||
|
|
||
| test_folder = Path(__file__).parent / 'my_dataset_small' | ||
|
|
||
|
|
||
| analyzer = load_sorting_analyzer(test_folder / "sorting_analyzer") | ||
|
|
||
| # State in the parent app | ||
| status_md = pn.pane.Markdown("No curation submitted yet.") | ||
|
|
||
|
|
||
| def on_curation_saved(curation_data, title): | ||
| """This runs in the parent app's context — pure Python, no JS.""" | ||
| status_md.object = f"{title}\n\nReceived curation data:\n```\n{curation_data}\n```" | ||
| # You can do anything here: save to DB, trigger a pipeline, etc. | ||
|
|
||
| # Create the embedded GUI with the callback | ||
| win = run_mainwindow( | ||
| analyzer, | ||
| mode="web", | ||
| start_app=False, | ||
| panel_window_servable=False, | ||
| curation=True, | ||
| curation_callback=on_curation_saved, | ||
| curation_callback_kwargs={"title": "✅ Curation received!\n"}, | ||
| ) | ||
|
|
||
| # Compose the parent layout | ||
| parent_layout = pn.Column( | ||
| "# Parent Application", | ||
| status_md, | ||
| pn.layout.Divider(), | ||
| win.main_layout, | ||
| sizing_mode="stretch_both", | ||
| ) | ||
|
|
||
| parent_layout.servable() | ||
|
|
||
| pn.serve(parent_layout, port=12345, show=True) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,12 @@ def get_selected_unit_ids(self): | |
| elif self.backend == 'panel': | ||
| return self._panel_get_selected_unit_ids() | ||
|
|
||
| def update_manual_labels(self): | ||
| if self.backend == 'qt': | ||
| self._qt_full_table_refresh() | ||
| elif self.backend == 'panel': | ||
| self._panel_update_labels() | ||
|
|
||
| ## Qt ## | ||
| def _qt_make_layout(self): | ||
|
|
||
|
|
@@ -710,6 +716,17 @@ def _panel_on_edit(self, event): | |
| self.notify_manual_curation_updated() | ||
| self.notifier.notify_active_view_updated() | ||
|
|
||
| def _panel_update_labels(self): | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make full refresh instead, which includes the labels
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you plan to do this or can I merge this PR ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can merge |
||
| # this is called after a label change to update the table values | ||
| for col in self.label_definitions: | ||
| for row in range(len(self.table.value)): | ||
| unit_id = self.table.value.index[row] | ||
| label_value = self.controller.get_unit_label(unit_id, col) | ||
| if label_value is None: | ||
| label_value = "" | ||
| self.table.value.at[unit_id, col] = label_value | ||
| self.refresh() | ||
|
|
||
| def _panel_on_only_selection(self): | ||
| selected_unit = self.table.selection[0] | ||
| unit_id = self.table.value.index.values[selected_unit] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrishalcrow could this be needed by the Qt backend too? e.g., UnitRefine or similar could use it?