BrainSpace provides basic functionality for working with surface meshes. This functionality is built on top of the Visualization Toolkit (VTK).

Read/Write functionality

read_surface(ipth[, itype, return_data, update]) Read surface data.
write_surface(ifilter, opth[, oformat, otype]) Write surface data.

Surface creation

build_polydata(points[, cells]) Build surface (PolyData) from points and cells.
to_lines(surf) Convert all cells in PolyData to lines.
to_vertex(surf) Convert all cells in PolyData to vertex cells.


get_cells(surf) Get surface cells.
get_points(surf[, mask]) Get surface points.
get_edges(surf[, mask]) Get surface edges.


get_cell2point_connectivity(surf[, mask, dtype]) Get cell to point connectivity.
get_point2cell_connectivity(surf[, mask, dtype]) Get point to cell connectivity.
get_cell_neighbors(surf[, include_self, …]) Get cell connectivity based on shared edges.
get_immediate_adjacency(surf[, …]) Get immediate adjacency matrix.
get_ring_adjacency(surf[, n_ring, …]) Get adjacency in the neighborhood of each point.
get_immediate_distance(surf[, metric, mask, …]) Get immediate distance matrix.
get_ring_distance(surf[, n_ring, metric, …]) Get distance matrix in the neighborhood of each point.

Operations on meshes

drop_cells(surf, array[, low, upp]) Remove surface cells whose values fall within the threshold.
mask_cells(surf, mask) Mask surface cells.
select_cells(surf, array[, low, upp]) Select surface cells whose values fall within the threshold.
drop_points(surf, array[, low, upp]) Remove surface points whose values fall within the threshold.
mask_points(surf, mask) Mask surface points.
select_points(surf, array[, low, upp]) Select surface points whose values fall within the threshold.
get_connected_components(surf[, labeling, …]) Get connected components.
downsample_with_parcellation(surf, labeling) Downsample surface according to labeling.

Operations on mesh data

compute_cell_area(surf[, append, key]) Compute cell area.
compute_cell_center(surf[, append, key]) Compute center of cells (parametric center).
get_n_adjacent_cells(surf[, append, key]) Compute number of adjacent cells for each point.
map_celldata_to_pointdata(surf, cell_data[, …]) Map cell data to point data.
map_pointdata_to_celldata(surf, point_data) Map point data to cell data.
compute_point_area(surf[, cell_area, …]) Compute point area from its adjacent cells.
get_labeling_border(surf, labeling[, …]) Get labeling borders.
get_parcellation_centroids(surf, labeling[, …]) Compute parcels centroids.
propagate_labeling(surf, labeling[, …]) Propagate labeling on surface points.

Mesh clustering

Clustering and sampling of surface vertices.

cluster_points(surf[, n_clusters, is_size, …]) Clustering of surface points.
sample_points_clustering(surf[, keep, mask, …]) Sample equidistant points from surface based on clustering.