Wiki source code of Widget PSE

Version 9.1 by teodoramisan on 2023/03/24 16:07

Hide last authors
teodoramisan 7.1 1 (% class="wikigeneratedid" id="HWidgetPSE" %)
teodoramisan 6.1 2 Source code: [[https:~~/~~/github.com/the-virtual-brain/tvb-widgets>>https://github.com/the-virtual-brain/tvb-widgets]]
3
4 == **Purpose** ==
5
6
7 It is composed of two separate Jupyter Widgets(PSE Launcher and PSE Visualizer) intended for the visualization of launching custom simulations. The launcher works locally for now, but in the future a HPC launch will be available.
8
9 The simulation can be customized by:
10
11 * Getting a list of connectivities given as API
12 * Setting up parameters and ranges
13 * Selecting multiple metrics
14
15 == **Inputs** ==
16
17 * PSELauncher(Simulator, List_of_Connectivities)
18 * PSEVisualizer(Filename), the file will contain all the customized parameters from the launcher
19
20 == **Requirements and installation** ==
21
22 Before installing the tvb-widgets library containing the PSE widgets, the following python library and Jupyter extensions should be installed:
23
24 * Libraries
25 ** [[plotly>>https://plotly.com/python/getting-started/#installation]]
26 * Extensions
27
28 (% class="box" %)
29 (((
30 jupyter labextension install @jupyter-widgets/jupyterlab-manager
31
32 jupyter labextension install jupyter-matplotlib
33 )))
34
35 Then, to install the tvb-widgets library, just type:
36
37 (% class="box" %)
38 (((
39 pip install tvb-widgets
40 )))
41
42 == **API usage ** ==
43
44 First, the correct matplotlib backend must be set, which enables the interaction with the PSE widgets, by running the following command:
45
46 (% class="box" %)
47 (((
48 %matplotlib widget
49 )))
50
51 Then, the PSELauncher and PSEWidget(from the tvb-widgets API) and the package lab(from tvb simulator) should be imported:
52
53 (% class="box" %)
54 (((
55 from tvbwidgets.api import PSELauncher, PSEWidget
56 from tvb.simulator.lab import *
57 )))
58
59 The launcher widget can be initialized with the required parameters (simulator and the list of connectivities) as it shows below:
60
61 (% class="box" %)
62 (((
63 sim = simulator.Simulator(connectivity = connectivity.Connectivity.from_file())
64 conn_66 = connectivity.Connectivity.from_file("connectivity_66.zip")
65 conn_68 = connectivity.Connectivity.from_file("connectivity_68.zip")
66 conn_76 = connectivity.Connectivity.from_file()
67 launch = PSELauncher(sim, [conn_66, conn_68, conn_76])
68 )))
69
70 The outcome will be something like in the image bellow.
71 You can create a customized simulation by choosing different values for parameters, by setting ranges for them and by selecting the metrics for the simulation.
72
73 [[image:setup_parameters.png||alt="setup_parameters"]]
74
75 Then, a file name has to be inserted in the indicated box(for storing the data) and as a last set-up, a launch type has to be chosen.
76
77 [[image:launch.png||alt="launch"]]
78
79 A file with the name you specified will be generated.
80
81 Then, the PSEVisualizer can be called with the required parameter(file_name) as it shows below:
82
83 (% class="box" %)
84 (((
85 pse = PSEWidget("test.h5")
86 )))
87
88 The outcome will be something like in the image bellow.
89
90 There will be a representation for every metric that was chosen before, in the launcher. The widget has some features for the type of visualization, the change of color and the option for choosing between metrics.
91
92 [[image:result.png||alt="result"]]
Public

TVB Widgets