Menu

Deep learning for NeuroImaging in Python.

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the gallery for the big picture.

surfify.utils.sampling.downsample(vertices, target_vertices)[source]ΒΆ

Downsample icosahedron vertices by finding nearest neighbors.

Parameters:

vertices : array (n_samples, n_dim)

points of data set.

target_vertices : array (n_query, n_dim)

points to find nearest neighbors for.

Returns:

nearest_idx : array (n_query, )

index of nearest neighbor in target_vertices for every point in vertices.

Examples

>>> from surfify.utils import icosahedron, downsample
>>> import matplotlib.pyplot as plt
>>> from surfify.plotting import plot_trisurf
>>> ico2_verts, ico2_tris = icosahedron(order=2)
>>> ico3_verts, ico3_tris = icosahedron(order=3)
>>> down3to2 = downsample(ico3_verts, ico2_verts)
>>> ico3_down_vertices = ico3_verts[down3to2]
>>> fig, ax = plt.subplots(1, 1, subplot_kw={
        "projection": "3d", "aspect": "auto"}, figsize=(10, 10))
>>> plot_trisurf(ico3_verts, triangles=ico3_tris, colorbar=False, fig=fig,
                 ax=ax)
>>> for cnt, point in enumerate(ico3_down_vertices):
>>>     ax.scatter(point[0], point[1], point[2], marker="o", c="red",
                   s=100)
>>> plt.show()

Follow us

© 2025, nidl developers