Wiki source code of Widget Connectivity
Last modified by paulapopa on 2025/06/24 14:15
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
3.1 | 1 | == Widget Connectivity == |
2 | |||
3 | Source code: [[https:~~/~~/github.com/the-virtual-brain/tvb-widgets>>url:https://github.com/the-virtual-brain/tvb-widgets]] | ||
4 | |||
5 | This is part of a Pypi release: [[https:~~/~~/pypi.org/project/tvb-widgets/>>url:https://pypi.org/project/tvb-widgets/]] | ||
6 | |||
7 | //**tvb-widgets**// is also already installed in the official image released for EBRAINS lab, where you can test it directly. | ||
8 | |||
9 | |||
10 | == Purpose == | ||
11 | |||
![]() |
8.1 | 12 | Jupyter lab widgets for visualizing or do operations on a connectivity |
![]() |
3.1 | 13 | |
14 | |||
![]() |
8.2 | 15 | === 1. ConnectivityWidget === |
![]() |
3.1 | 16 | |
![]() |
8.1 | 17 | ==== Visualization: ==== |
18 | |||
![]() |
11.1 | 19 | - in 2D can visualize weights or tracts matrixes; |
![]() |
3.1 | 20 | |
![]() |
7.1 | 21 | [[image:conn2d.png||height="741" width="1700"]] |
![]() |
3.1 | 22 | |
![]() |
11.1 | 23 | - in 3D can visualize regions and their respective edges |
![]() |
3.1 | 24 | |
![]() |
7.1 | 25 | ==== [[image:conn3d.png||height="688" width="1700"]] ==== |
![]() |
3.1 | 26 | |
![]() |
11.1 | 27 | - to show/hide the Connectivity centers/edges, access the controls available in the upper-right corner: |
![]() |
3.1 | 28 | |
![]() |
7.1 | 29 | [[image:visible.png||height="543" width="500"]] |
![]() |
3.1 | 30 | |
![]() |
8.1 | 31 | ==== Operations: ==== |
![]() |
3.1 | 32 | |
33 | - remove selected nodes from a connectivity, results in a new connectivity containing only the nodes that were not selected; | ||
34 | |||
35 | - remove unselected nodes from a connectivity, results in a new connectivity containing only the selected nodes; | ||
36 | |||
37 | - remove unselected edges, results in a new connectivity with the same number of regions but without the edges of unselected regions; | ||
38 | |||
39 | - remove selected edges, results in a new connectivity with the same number of regions but without the edges of selected regions. | ||
40 | |||
41 | |||
![]() |
8.1 | 42 | ==== Usage: ==== |
![]() |
3.1 | 43 | |
![]() |
10.1 | 44 | - after instantiating the widget it allows export of the currently selected connectivity: |
![]() |
3.1 | 45 | |
46 | {{code language="python"}} | ||
47 | from tvbwidgets.api import ConnectivityWidget | ||
48 | from tvb.datatypes.connectivity import Connectivity | ||
49 | |||
50 | conn = Connectivity.from_file() # defaults to connectivy_76.zip | ||
51 | conn.configure() | ||
52 | |||
53 | wid = ConnectivityWidget(conn, default_active_tab='viewers') # default_active_tab can be any value between 'viewers'|'operations'|'both' | ||
54 | |||
55 | display(wid) | ||
56 | # ....do some operations... | ||
57 | # replace None in the method below with the gid of the connectivity you wish to export | ||
58 | # if no gid is provided it will export the connectivity currently viewed | ||
59 | |||
60 | new_connectivity = wid.get_connectivity(gid=None) | ||
61 | new_connectivity | ||
62 | {{/code}} | ||
63 | |||
![]() |
8.1 | 64 | |
65 | === 2. SpaceTimeVisualizerWidget === | ||
66 | |||
![]() |
9.1 | 67 | - this is a 3D representation of the delayed-connectivity structure |
![]() |
8.2 | 68 | |
![]() |
9.1 | 69 | - the space-time visualizer disaggregate the //weights// matrix and each slice corresponds to connections that fall into a particular distance (or delay) range. The first slice is the complete weights matrix. Click on any of the subsequent slices to see the corresponding 2D matrix plot. Also, choose the conduction speed and ranges you are interested to explore and the plot will update instantly. |
70 | |||
![]() |
12.1 | 71 | [[image:st1.png||height="1150" width="1700"]] |
![]() |
9.1 | 72 | |
![]() |
15.1 | 73 | - clicking on a connectivity slice, brings that particular slice in the center to be visualized in 2D mode. Click on the main slice to return to the main view. |
![]() |
9.1 | 74 | |
![]() |
14.1 | 75 | [[image:st3.png||height="239" width="350"]][[image:st4.png||height="239" width="350"]] |
![]() |
9.1 | 76 | |
77 | - in the tab called Plots Overview you get a 2D summary of all the current slices | ||
78 | |||
![]() |
12.1 | 79 | [[image:st2.png||height="1517" width="1700"]] |