From 935f2332f8030ee6b13d0540a1c8e102df0f6d50 Mon Sep 17 00:00:00 2001 From: Notion Bot Date: Sun, 5 Jan 2025 01:41:45 +0100 Subject: [PATCH 1/3] Refactor point addition to use structure IDs instead of raw structures --- src/napari_swc_editor/bindings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/napari_swc_editor/bindings.py b/src/napari_swc_editor/bindings.py index 97a9f24..5c8ad43 100644 --- a/src/napari_swc_editor/bindings.py +++ b/src/napari_swc_editor/bindings.py @@ -133,8 +133,12 @@ def event_add_points(event): 0 ] + structure_id = symbol_to_structure_id( + [structure.value for structure in new_structure] + ) + new_swc, df = add_points( - raw_swc, new_pos, new_radius, new_structure, new_parents, df + raw_swc, new_pos, new_radius, structure_id, new_parents, df ) event.source.metadata["raw_swc"] = new_swc From 762370dc683784e01f9d65366c855539b79c5a36 Mon Sep 17 00:00:00 2001 From: Notion Bot Date: Sun, 5 Jan 2025 01:42:26 +0100 Subject: [PATCH 2/3] Refactor linking functionality in SWCEditorWidget: update checkbox and metadata handling --- src/napari_swc_editor/_widget.py | 6 +++--- src/napari_swc_editor/bindings.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/napari_swc_editor/_widget.py b/src/napari_swc_editor/_widget.py index 48f2d54..6816a94 100644 --- a/src/napari_swc_editor/_widget.py +++ b/src/napari_swc_editor/_widget.py @@ -47,9 +47,9 @@ def __init__(self, viewer: "napari.viewer.Viewer"): ) self._link_previous_node_checkbox = create_widget( label="link previous node with new node (same as using CTRL+Click)", - annotation=float, widget_type="CheckBox", ) + self._show_table_button = create_widget( label="Show swc table", annotation=bool, widget_type="PushButton" ) @@ -57,10 +57,10 @@ def __init__(self, viewer: "napari.viewer.Viewer"): self._get_layer_data() # connect your own callbacks + self._point_layer_combo.changed.connect(self._get_layer_data) self._link_previous_node_checkbox.changed.connect( self._set_link_previous_node ) - self._link_previous_node_checkbox.changed.connect(self._get_layer_data) self._show_table_button.changed.connect(self._set_table) @@ -123,7 +123,7 @@ def _set_link_previous_node(self, value): layer = self._point_layer_combo.value if layer is None: return - layer.metadata["link_previous_node"] = value + layer.metadata["widget_link_activated"] = value def _table_clicked(self, event): row = event.row() diff --git a/src/napari_swc_editor/bindings.py b/src/napari_swc_editor/bindings.py index 5c8ad43..554b504 100644 --- a/src/napari_swc_editor/bindings.py +++ b/src/napari_swc_editor/bindings.py @@ -125,7 +125,7 @@ def event_add_points(event): # if shift is activated, the add the new edges from previous selected point if ( event.source.metadata["Ctrl_activated"] - or event.source.metadata["link_previous_node"] + or event.source.metadata["widget_link_activated"] ) and len(event.source.selected_data) > 0: previous_selected = list(event.source.selected_data)[-1] From a37d360565a41cb110e38de0b1a2f4a0cfbc1912 Mon Sep 17 00:00:00 2001 From: Clement Caporal <94049435+ClementCaporal@users.noreply.github.com> Date: Sun, 5 Jan 2025 01:54:57 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 72db683..0633774 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,15 @@ SWC_SYMBOL = { ``` ![image](https://github.com/user-attachments/assets/618aa000-370d-43f9-8645-8a3b7e9b9739) +You can also visualize the swc data in a table using the widget under `Plugin > SWC Editor Widget` + +![image](https://github.com/user-attachments/assets/ed43f4c2-582b-4bc1-bbb1-54e8d9487f1d) + +When using the "Show swc table" you will have an interactive table widget: +- left-click on table: highlight + center on the corresponding point +- **double**-left-click on table: highlight + center on the correspongind point **+ zoom** +- selection on the point layer: highlight the corresponding row on the table + #### SWC Edition **ALL INTERACTIONS ARE ONLY BOUND TO THE `point_layer`** **THERE IS NO CTRL-Z (please save your progress)** @@ -60,7 +69,11 @@ SWC_SYMBOL = { - **Add edge**: Select 2 or more point(s) and press on your keyboard `l` (aka: link). - **Remove edge**: Select 1 or more point(s) and press on your keyboard `u` (aka: unlink). +If you want to link point as you are adding them you have two solutions: +- press "CTRL" while you add points, this will create a link with the previously selected point +- use the `Plugin > SWC Editor Widget` Checkbox ("link previous node with new node (same as using CTRL+Click)"): when selected, all new points will be selected with the previously selected point +https://github.com/user-attachments/assets/273f1221-2882-4a7c-ab7f-6d3ecb7f3fa6 ## Installation @@ -70,6 +83,10 @@ You can install `napari-swc-editor` via [pip]: + + + + To install latest development version : pip install git+https://github.com/LaboratoryOpticsBiosciences/napari-swc-editor.git