# cortex.polyutils.Surface¶

class cortex.polyutils.Surface(pts, polys)[source]

Represents a single cortical hemisphere surface. Can be the white matter surface, pial surface, fiducial (mid-cortical) surface, inflated surface, flattened surface, etc.

Implements some useful functions for dealing with functions across surfaces.

Parameters
pts2D ndarray, shape (total_verts, 3)

Location of each vertex in space (mm). Order is x, y, z.

polys2D ndarray, shape (total_polys, 3)

Indices of the vertices in each triangle in the surface.

Methods

 __init__(pts, polys) Initialize self. approx_geodesic_distance(verts[, m]) Computes approximate geodesic distance (in mm) from each vertex in the surface to any vertex in the collection verts. call_vtp_geodesic(vertex) Compute geodesic distance using VTP method create_biharmonic_solver(boundary_verts[, …]) Set up biharmonic equation with Dirichlet boundary conditions on the cortical mesh and precompute Cholesky factorization for solving it. create_subsurface([vertex_mask, polygon_mask]) Create subsurface for efficient operations on subset of Surface edge_collapse(p1, p2, target) Compute exact geodesic distance along surface extract_chunk([nfaces, seed, auxpts]) Extract a chunk of the surface using breadth first search, for testing purposes extract_geodesic_chunk(origin, radius) Extract a chunk of the surface that is within radius of the origin by geodesic distance. geodesic_distance(verts[, m, fem]) Minimum mesh geodesic distance (in mm) from each vertex in surface to any vertex in the collection verts. geodesic_path(a, b[, max_len, d]) Finds the shortest path between two points a and b. get_connected_vertices(vertex, mask[, …]) return vertices connected to vertex that satisfy mask get_euclidean_ball(xyz, radius) return vertices within some 3d euclidean distance of an xyz coordinate get_euclidean_patch(vertex, radius[, …]) return connected vertices within some 3d euclidean distance of a vertex get_geodesic_patch(vertex, radius[, …]) return vertices within some 2d geodesic distance of a vertex (or vertices) get_geodesic_patches(radius[, seeds, …]) create patches of cortex centered around each vertex seed get_geodesic_strip_patch(v0, v1, radius[, …]) return patch that includes v0, v1, their geodesic path, and all points within some radius get_strip_coordinates(v0, v1[, …]) get 2D coordinates of surface from v0 to v1 interp(verts, vals) Interpolates a function between N knot points verts with the values vals. lift_subsurface_data(data[, vertex_mask]) expand vertex dimension of data to original surface’s size Compute mean curvature of this surface using the Laplace-Beltrami operator. patches([auxpts, n]) plot_subsurface_rotating_gif(path[, …]) create a rotating gif of subsurface Iterates through the polyhedra that make up the closest volume to a certain vertex smooth(scalars[, factor, iterations]) Smooth vertex-wise function given by scalars across the surface using mean curvature flow method (see http://brickisland.net/cs177fa12/?p=302). surface_gradient(scalars[, at_verts]) Gradient of a function with values scalars at each vertex on the surface.

Attributes

 adj Sparse vertex adjacency matrix. avg_edge_length Average length of all edges in the surface. boundary_vertices return mask of boundary vertices connected Sparse matrix of vertex-face associations. cotangent_weights Cotangent of angle opposite each vertex in each face. edge_lengths return vector of edge lengths face_areas Area of each face. face_normals Normal vector for each face. furthest_border_points return pair of points on surface border that have largest pairwise geodesic distance graph NetworkX undirected graph representing this Surface. iter_surfedges iter_surfedges_weighted iterate through edges laplace_operator Laplace-Beltrami operator for this surface. ppts 3D matrix of points in each face: n faces x 3 points per face x 3 coords per point. subsurface_vertex_inverse vertex_normals Normal vector for each vertex (average of normals for neighboring faces). weighted_distance_graph