Skip to content

Commit

Permalink
WID-223: fix bug related to cutting unselected tracts and remove labe…
Browse files Browse the repository at this point in the history
…l due to poor performance
  • Loading branch information
davidbacter01 committed Sep 14, 2023
1 parent 7266e66 commit 1b67e38
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 25 deletions.
82 changes: 75 additions & 7 deletions notebooks/Connectivity.ipynb

Large diffs are not rendered by default.

19 changes: 2 additions & 17 deletions tvbwidgets/ui/connectivity_ipy/connectivity_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ def __init__(self, **kwargs):

def init_view_connectivity(self):
self.output.plotter.clear()
points, edges, labels = self.add_actors()
points, edges = self.add_actors()
points_toggle, edges_toggle, labels_toggle = self._init_controls()
if not labels_toggle.value:
self.output.hide_actor(labels)

def on_change_points(change):
if change['new']:
Expand All @@ -139,15 +137,6 @@ def on_change_edges(change):

edges_toggle.observe(on_change_edges, 'value')

def on_change_labels(change):
if change['new']:
self.output.display_actor(labels)
else:
self.output.hide_actor(labels)
self.output.update_plot()

labels_toggle.observe(on_change_labels, 'value')

window_controls = self.output.get_window_controls()

self.children = [
Expand Down Expand Up @@ -177,21 +166,17 @@ def add_actors(self):

mesh_points = pv.PolyData(points)

labels = CONTEXT.connectivity.region_labels
labels_actor = plotter.add_point_labels(points, labels)

points_color = self.output.CONFIG.points_color
points_size = self.output.CONFIG.point_size
edge_color = self.output.CONFIG.edge_color

points_actor = plotter.add_points(mesh_points, color=points_color, point_size=points_size)

edges_coords = self._extract_edges()

edges_actor = plotter.add_lines(edges_coords, color=edge_color, width=1)
plotter.camera_position = 'xy'

return points_actor, edges_actor, labels_actor
return points_actor, edges_actor

def _extract_edges(self):
connectivity = CONTEXT.connectivity
Expand Down
2 changes: 1 addition & 1 deletion tvbwidgets/ui/connectivity_ipy/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _cut_connectivity_edges(self, interest_areas, selected=False):
if i not in interest_areas or j not in interest_areas:
if not selected:
new_weights[i][j] = 0
elif i in interest_areas or j in interest_areas and selected:
elif selected:
new_weights[i][j] = 0

final_conn = Connectivity()
Expand Down

0 comments on commit 1b67e38

Please sign in to comment.