Exploring a surface mesh

In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
from tvb.simulator.lab import *

Surface level simulations in TVB use a triangular mesh surface to represent the folded cortical surface, similar triangular mesh surfaces are used to represent the boundaries between brain and skull, skull and skin, and skin and air, that are used in the calculation of EEG and MEG forward solutions. This tutorial covers a few basic ways of looking at the properties of these surfaces.

One of the things we'll be looking for is how well regularised the mesh is -- a well regularised a mesh has a narrow distribution of edge lengths and triangle areas. For most uses in TVB, it is important to have a well regularised mesh.

In [3]:
ctx = surfaces.CorticalSurface.from_file()
ctx.configure()
ctx
Out[3]:

CorticalSurface

Cortical or pial surface.

value
Edge lengths, longest (mm)
7.756718245437372
Edge lengths, mean (mm)
3.9760529287149735
Edge lengths, shortest (mm)
0.6638077082371072
Has two hemispheres
False
Number of edges
49140
Number of triangles
32760
Number of vertices
16384
Surface type
CorticalSurface
Valid for simulations
True

We can see a number of basic properties of the mesh here, such as the number of vertices, edges and triangles making up the surface. A summary of the edge lengths is also included, this is useful to know what scale of features, eg LocalConnectivity, we can expect to be able to represent on this surface. As a Cortex also has a large-scale Connectivity associated with it we see some "Region" information as well, here it is TVB's default 76 region connectivity matrix. As we can see, this Connectivity parcellates the cortex into regions with a fairly broad range of sizes.

Looking in more detail, we can plot the distributions of things like edge lengths and triangle areas to see in more detail whether the mesh is well regularised...

In [4]:
plt.figure(figsize=(10, 5))
plt.subplot(121)
plt.hist(ctx.edge_lengths, bins=100)
plt.title("Distribution of Edge Lengths")
plt.xlabel("mm")

plt.subplot(122)
plt.hist(ctx.triangle_areas, bins=100)
plt.title("Distribution of Triangle Areas")
plt.xlabel("mm$^2$")
Out[4]:
Text(0.5, 0, 'mm$^2$')
In [5]:
from tvb.simulator.plot.head_plotter_3d import HeadPlotter3D
HeadPlotter3D.display_surface(ctx)
In [ ]: