Attention: The Collaboratory IAM will down for up to 1 hour on Monday, the 7th of July 2025 starting from 5pm CEST (my timezone) for up to 1 hour. Any and all services, which require a user login with an EBRAINS account, will be un-available during that time


Widget 3D Head

Last modified by paulapopa on 2025/05/30 15:03

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:

1
2
3
import tvbwidgets.api as api
from tvb.simulator.lab import *
from IPython.core.display_functions import display 

Then, there are 2 options to work with the widget:

  1. Use a file browser to load the data and automatically display it
  2. 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:

1
2
widget = api.HeadBrowser()
display(widget)

For the second option, the API is described below:

In a cell, we load the data using the TVB API:

1
2
3
4
5
6
7
8
9
10
11
12
13
surface = surfaces.Surface.from_file()
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:

1
2
widget = api.HeadWidget([face, conn, seeg])
display(widget)

head.png

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:

1
widget.add_datatype(surface, reg_map)

cort.png

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:

parcel.png

I could also make it transparent to visualize the connectivity centers and their edges, by moving the slider highlighted in red:

transp.png

Or, I can hide the connectivity and display only the SEEG sensors:

seeg.png

Public

TVB Widgets