Attention: The EBRAINS IAM will be down Monday, the 21st July 2025, from 17.00 CEST (my timezone) for up to 1 hour. This will any affect services requiring an EBRAINS login, we apologise for any inconvenience caused.


Widget 3D Head

Version 28.1 by paulapopa on 2025/05/30 14:46

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

Public

TVB Widgets