Widget PhasePlane

Last modified by ldomide on 2023/03/08 17:28

Source code: https://github.com/the-virtual-brain/tvb-widgets

This is part of a Pypi release: https://pypi.org/project/tvb-widgets/

tvb-widgets is also already installed in the official image released for EBRAINS lab, where you can test it directly.

Purpose

It is a Jupyter Widget intended for the visualization of the interactive phase-plane for TVB math models (https://docs.thevirtualbrain.org/api/tvb.simulator.models.html#module-tvb.simulator.models).

It provides sliders for setting:

  •  The value of all parameters of the Model.

  •  The extent of the axes.

  •  A fixed value for the state-variables which aren't currently selected.

  •  The noise strength, if a stochastic integrator is specified.

and dropdown lists for selecting:

  •  Which state-variables to show on each axis.

  •  Which mode to show, if the Model has them.

Entering the coordinates in the X,Y Coordinate Boxes will generate a sample
trajectory, originating from the coordinates entered.

Inputs

Phase-Plane viewer will be represented in the beginning based on the parameters that it receives:

  • Model (Generic2dOscillator, Epileptor, Hopfield, etc.)
  • Integrator (HeunDeterministic, HeunStochastic, Identity, etc.)

Requirements and installation

Before installing the tvb-widgets library containing the PhasePlane widget, 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 PhasePlane widget, by running the following command:

%matplotlib widget

Then, the PhasePlaneWidget (from the tvb-widgets API), the package lab (from tvb simulator) and the display function should be imported:

from tvbwidgets.api import PhasePlaneWidget
from tvb.simulator.lab import *
from IPython.core.display_functions import display

The widget can be initialized with the required parameters (Model and Integrator) as it shows below:

w = PhasePlaneWidget(model=models.Generic2dOscillator(),
                     integrator=integrators.HeunDeterministic())

Finally, to display and interact with the PhasePlane widget, the get_widget method is used inside the display function: 

display(w.get_widget(plot_size=(6,7)))

The outcome will be something like in the image bellow.
You can explore the inputs in the TAB on the left, and click on the canvas in the right to select initial conditions for evaluating the Model equations from that point onward (no structural connectivity, as is the eq are solved for a single node, in isolation).

PhasePlaneWidget

PhasePlaneDifferentModel

Public

TVB Widgets