Skip to content

Commit

Permalink
Merge branch 'main' of github.com:LaboratoryOpticsBiosciences/napari-…
Browse files Browse the repository at this point in the history
…swc-editor into main
  • Loading branch information
ClementCaporal committed Jan 5, 2025
2 parents 78e056f + a37d360 commit c7ce908
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)**
Expand All @@ -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

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/napari_swc_editor/_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ 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"
)

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)

Expand Down Expand Up @@ -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()
Expand Down
8 changes: 6 additions & 2 deletions src/napari_swc_editor/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,20 @@ 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]
new_parents = get_treenode_id_from_index([previous_selected], df)[
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
Expand Down

0 comments on commit c7ce908

Please sign in to comment.