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.find_neighbors(start_node, order, neighbors)[source]¶
Recursively find neighbors from a starting node up to a certain order.
- Parameters:
start_node : int
node index to start search from.
order : int
order up to which to look for neighbors.
neighbors : dict
neighbors for each node as generated by the ‘neighbors’ or ‘neighbors_rec’ functions.
- Returns:
indices : list of int
the n-ring neighbors indices.
See also
Examples
>>> from surfify.utils import icosahedron, neighbors_rec, find_neighbors >>> 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)[0] >>> neighs = neighs.reshape(len(neighs), -1) >>> neighs = neighbors(ico2_verts, ico2_tris, depth=1, direct_neighbor=True) >>> node = 0 >>> node_neighs = find_neighbors(node, order=3, neighbors=neighs) >>> 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[node] >>> for cnt, idx in enumerate(node_neighs): >>> point = ico2_verts[idx] >>> 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