Widget PSE
Source code: https://github.com/the-virtual-brain/tvb-widgets
Purpose
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 and on HPC.
The simulation can be customized by:
- Getting a list of connectivities and an HPC configuration given as APIs
- Setting up parameters and ranges
- Selecting multiple metrics
- Observing the progress of the launch by a monitor progress bar
Inputs
- PSELauncher(Simulator, List of Connectivities, HPC Configuration)
- PSEVisualizer(Filename), the file will contain all the customized parameters from the launcher
Requirements and installation
Before installing the tvb-widgets library containing the PSE widgets, the following python library and Jupyter extensions should be installed:
- Libraries
- Extensions
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib
Then, to install the tvb-widgets library, just type:
pip install tvb-widgets
API usage
First, the correct matplotlib backend must be set, which enables the interaction with the PSE widgets, by running the following command:
%matplotlib widget
Then, the PSELauncher and PSEWidget(from the tvb-widgets API) and the package lab(from tvb simulator) should be imported:
from tvbwidgets.api import PSELauncher, PSEWidget
from tvb.simulator.lab import *
The launcher widget can be initialized with more parameters: a simulator, a list of connectivities and an HPC configuration (only the simulator being a required argument).
For HPC launch, besides the configuration part, an EBrains token needs to be stored. A custom initialization, which includes the HPC launch, is shown below:
os.environ['CLB_AUTH'] = 'PUT YOUR EBRAINS TOKEN HERE IF YOU WANT HPC RUNS'
from pyunicore.helpers.jobs import Resources
res = Resources(cpus_per_node=4)
# !! Pay attention to env name and dir you might need to change if in conflict on the SAME project with another colleague of yours!!
hpc_config = HPCConfig(site="JUSUF", project="icei-hbp-2021-0007",
env_dir="tvb_widget", env_name="venv_tvb", n_threads=None, resources=res)
sim = simulator.Simulator(connectivity = connectivity.Connectivity.from_file())
conn_66 = connectivity.Connectivity.from_file("connectivity_66.zip")
conn_68 = connectivity.Connectivity.from_file("connectivity_68.zip")
conn_76 = connectivity.Connectivity.from_file()
launch = PSELauncher(sim, [conn_66, conn_68, conn_76], hpc_config)
The outcome will be something like in the image bellow.
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.

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.
The progress of the launch can be monitored by a progress bar (as shown below) and the data used for the HPC launch will be stored in a .toml file available besides the notebook.

A file with the name you specified will be generated in both approaches, HPC or local launch.
Then, the PSEVisualizer can be called with the required parameter(file_name) as it shows below:
pse = PSEWidget("test.h5")
The outcome will be something like in the image bellow.
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.
