larmor.surfaces#

Operations on surfaces.

concatenate_surfaces

Joins surfaces into one mesh, such as lh and rh.

keep_vertices

Keeps only the vertices where mask is True, such as the cortex of a label.

vertex_normals

Computes the unit normal of every vertex, pointing out of the surface.

larmor.surfaces.concatenate_surfaces(surfaces)#

Joins surfaces into one mesh, such as lh and rh.

Only the value names every surface has are kept, and the reference only when all the surfaces have matching grids.

Parameters:

surfaces (Sequence[Surface]) – The surfaces to join. Their faces are renumbered, in the order given.

Returns:

Surface – The joined surface.

Raises:

ValueError – If surfaces is empty.

Return type:

Surface

larmor.surfaces.keep_vertices(surface, mask)#

Keeps only the vertices where mask is True, such as the cortex of a label.

Faces that touch a removed vertex are removed, the kept faces are renumbered, and vertex_data is sliced to match; the reference is kept. Removing the medial wall:

mask = np.zeros(white.num_vertices, dtype=bool) mask[read_freesurfer_label(“lh.cortex.label”)] = True cortex = keep_vertices(white, mask)

Parameters:
  • surface (Surface) – The surface to cut.

  • mask (ndarray) – (V,) bool, True for the vertices to keep.

Returns:

Surface – The kept part. Its vertex numbering differs from surface’s.

Raises:

ValueError – If mask is not a boolean array with one entry per vertex.

Return type:

Surface

larmor.surfaces.vertex_normals(surface)#

Computes the unit normal of every vertex, pointing out of the surface.

Parameters:

surface (Surface) – The surface, with V vertices.

Returns:

The normals, shape (V, 3), float32. A vertex that is in no face has a normal of zeros.

Return type:

ndarray