Use of user-defined cortical mesh

Skip to first unread message


Aug 21, 2023, 7:00:21 AM8/21/23
to TVB Users
Dear TVB experts,

I am creating this new post to ask for your help.
I am using my data to create the cortex surface in TVB: I have generated the data with Freesurfer recon-all command and then converted to TVB format with the script .

I have successfully generated all the outputs of the cortex (zipped in a file):
- normals.txt
- triangles.txt
- vertices.txt

They are 15206 vertices, 15206 normals, and 29999 triangles.

At the same time when I try to use this cortex in the Jupiter Notebooks included with TVB, like "exploring_a_surface_mesh" or "display_surface_local_connectivity", modifying only the command  cortex.Cortex.from_file() to add the path to my zipped cortex file, and then running the cell, it returns a "Dead kernel" error or "The kernel appears to have died. It will restart automatically". This does not happen with the default TVB cortex.

I found a similar topic in a previous conversation
but cannot find the resolution.

I would be grateful if you could help me with the above.

Thank you very much, appreciated your support!


Lia Domide

Aug 21, 2023, 10:44:24 AM8/21/23
to TVB Users
Hi Michelangelo,

Any chance that you privately send me your mesh ZIP to look into more details ?


Lia Domide

Aug 21, 2023, 4:05:19 PM8/21/23
to TVB Users
Hi Michelangelo,

Please have a look at the new form for the 2 mentioned notebooks: 

I trust in this form, they can be easier adapted to usage of a custom mesh.
Let me know if this works for you.



Sep 4, 2023, 12:53:33 PM9/4/23
to TVB Users
Dear Lia,

with the last version of the Jupyter Notebooks and using last version of TVB (2.7.2), both the Notebooks now work with my own data!
I tried to use also the Notebook "tutorial_s2_surface_simulation.ipynb", replacing as suggested the class "cortex" with the class "surfaces.CorticalSurface"

%pylab inline

#Import a bunch of stuff to ease command line usage
from tvb.simulator.lab import *

#Initialise a Model, Coupling, and Connectivity.

oscillator = models.Generic2dOscillator()

white_matter = connectivity.Connectivity.from_file('/')

white_matter.speed = numpy.array([4.0])


white_matter_coupling = coupling.Linear(a=numpy.array([0.014]))


#Initialise an Integrator

heunint = integrators.HeunDeterministic(dt=2**-4)


#Initialise a surface

default_cortex = surfaces.CorticalSurface.from_file("/")

default_cortex = white_matter

default_cortex.coupling_strength = numpy.array([2**-10])

default_cortex.local_connectivity = local_connectivity.LocalConnectivity.from_file()


#Initialise some Monitors with period in physical time

mon_tavg = monitors.TemporalAverage(period=2**-2)

mon_savg = monitors.SpatialAverage(period=2**-2)

# load the default region mapping

rm = region_mapping.RegionMapping.from_file('/sub-01_region_mapping.txt')

mon_eeg = monitors.EEG.from_file('/sub-01_EEG_Locations.txt')


#Bundle them

what_to_watch = (mon_tavg, mon_savg, mon_eeg)


#Initialise Simulator -- Model, Connectivity, Integrator, Monitors, and surface.

sim = simulator.Simulator(model = oscillator, connectivity = white_matter,

                          coupling = white_matter_coupling, 

                          integrator = heunint, monitors = what_to_watch,

                          surface = default_cortex)



However this lead to the following error:

TraitTypeError: Attribute can't be set to an instance of <class 'tvb.datatypes.connectivity.Connectivity'>

  attribute tvb.simulator.simulator.Simulator.surface = Attr(field_type=<class 'tvb.datatypes.cortex.Cortex'>, default=None, required=False)

This looks generated by the use of the class "surfaces.CorticalSurface".

I would be grateful if anybody could suggest a possible fix.

Thank you very much

Lia Domide

Sep 19, 2023, 1:41:34 AM9/19/23
to TVB Users

tutorial_s2_surface_simulation.ipynb is not supposed to have similar changes as in the other 2 demos. 
In this case the class CorticalSurface needs to remain in use.
We are expected to compute the LocalConnectivity on this class for obtaining all the data needed for surface level simulations.


Reply all
Reply to author
0 new messages