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.neighbors_rec(vertices, triangles, size=5, zoom=5)[source]ΒΆ

Build rectangular grid neighbors and weights.

This is the base function to build Rectangular Patch (RePa) kernels.

Parameters:

vertices : array (N, 3)

the icosahedron vertices.

triangles : array (N, 3)

the icosahedron triangles.

size : int, default 5

the rectangular grid size.

zoom : int, default 5

scale factor applied on the unit sphere to control the neighborhood density.

Returns:

neighs : array (N, size**2, 3)

grid samples neighbors for each vertex.

weights : array (N, size**2, 3)

grid samples weights with neighbors for each vertex.

grid_in_sphere : array (N, size**2, 3)

zoomed rectangular grid on the sphere vertices.

See also

neighbors

Examples

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

Follow us

© 2025, nidl developers