Widget 3D Head
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 visualization of the 3D Head data available for a patient:
- surfaces of different types (cortex, face, skull, etc)
- connectivity region centers and edges
- sensors locations (SEEG, MEG, EEG)
On cortical surfaces, it can also display region parcellation.
Inputs
It supports the above data in the form of their corresponding TVB datatypes:
- Surface (CorticalSurface, FaceSurface, etc)
- Parcellation (RegionMapping)
- Connectivity
- Sensors (SensorsInternal, SensorsMEG, SensorsEEG)
Installation
pip install tvb-widgets
API usage
We need to first import the widget API from tvbwidgets package, together with the TVB API and the display function:
2
3
from tvb.simulator.lab import *
from IPython.core.display_functions import display
Then, there are 2 options to work with the widget:
- Use a file browser to load the data and automatically display it
- Use directly the API to load the data and display it
For the first option, you have to run the following 2 lines of code in a notebook cell and then just use the UI controls:
2
display(widget)
For the second option, the API is described below:
In a cell, we load the data using the TVB API:
2
3
4
5
6
7
8
9
10
11
12
13
surface.configure()
face = surfaces.Surface.from_file('face_8614.zip')
face.configure()
reg_map = region_mapping.RegionMapping.from_file()
conn = connectivity.Connectivity.from_file()
conn.configure()
seeg = sensors.SensorsInternal.from_file()
seeg.configure()
Then we prepare the HeadWidget for display:
2
display(widget)
Next, we can continue adding other datatypes to this widget, by calling add_datatype multiple times.
In the code below, we add the CorticalSurface with a RegionMapping as parcellation:
In the upper-right corner, a menu is displayed. This will allow us to control what we want to visualize. For example, I can hide the head in order to get a better view of the cortical surface:
I can rotate the surface and zoom in/out:
I could also make it transparent to visualize the connectivity centers and their edges, by moving the slider highlighted in red:
Or, I can hide the connectivity and display only the SEEG sensors: