Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finding Centroids #21

Closed
neurolabusc opened this issue Nov 11, 2020 · 0 comments
Closed

Finding Centroids #21

neurolabusc opened this issue Nov 11, 2020 · 0 comments

Comments

@neurolabusc
Copy link
Owner

neurolabusc commented Nov 11, 2020

Braden Yang requested a method to find representative vertices for a mesh. This centroid must be an existing vertex (for a watertight cigar shape, we want a vertex on the surface of the object, not inside). The latest release (v1.0.20201102). The new atlas2node() function supports this operation, creating a text file in BrainNet Viewer Node format which Surfice can open with the Nodes menu.

Details regarding the motivation, implementation and corner cases are described here (see PDF) by Daniel Glen (@afni-dglen), Meghan Robinson, and Chris Rorden (@neurolabusc).

  1. For watertight meshes, the centroid vertex is the one closest to the center of gravity for all the nodes. Note for some objects like a sphere, the choice is arbitrary.
  2. For non-watertight meshes, the vertex that is the furthest from any edge (in Euclidean space) is selected. In the case of ties, the vertex closest to the center of gravity for all vertices is selected. The analogy here is to consider the mesh like an island, where the beach represents the edge of the mesh. The representative vertex is the one furthest away (as the crow flies) from any beach.

Here is a simple script to illustrate how this finds nice centroids for the included boggle atlas:

import gl
import os
gl.resetdefaults()
gl.meshload('lh.pial')
gl.overlayload('boggle.lh.annot')
fnm = os.path.expanduser("~")+os.path.sep+'myBoggle.node';
if os.path.exists(fnm):
    os.remove(fnm)
gl.atlas2node(fnm)

boggle

Here is a simple script to illustrate how this finds nice a reasonable centroids for the challenging dumbbell shape of the precuneus. It should be noted that Surfice will append nodes to existing files (allowing a script to iteratively combine lots of different regions). Therefore, in some cases it is worth deleting an existing file to restart acquiring nodes. In addition, note that by default Surfice will load BOTH the left and right hemisphere for mesh pairs with LH. and RH. filenames. Be aware that some tools (AFNI, FreeSurfer) will change the coordinates of a hemisphere as they are inflated (to the point where a spherical left hemisphere and right hemisphere have the same center origin: 0,0,0). The Surfice function meshloadbilateral can be used to enable and disable the loading of bilateral hemispheres. It might be worth disabling this feature when using the atlas2node() function.

import gl
import os
gl.resetdefaults()
#show only left hemisphere
gl.meshhemisphere(-1)
gl.meshload('lh.inflated.DK.precuneus.mz3')
fnm = os.path.expanduser("~")+os.path.sep+'myPrecuneus.node';
if os.path.exists(fnm):
    os.remove(fnm)
gl.atlas2node(fnm)

precuneus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant