Hi everyone,
I need to create the vector normal to the surface at each "white" vertex. I would like to end up with 7 fields in each entry:
1 Vertex number 2-4 RAS coordinates 5-7 RAS components of the normal vector pointed from ctx --> wm
mri_annotation2label gets me the first 4. I just don't want to reinvent the wheel getting the normal. If there's a way to get freesurfer to kick out the normals, that would be best. Here are naïve questions that arise out of this problem:
1. Is there a simple way to identify which vertices are "nearest neighbors" other than measuring and sorting the distances between each and all the others i.e. which ones form a triangle? I understand to use the normalized average of the 6 triangles which include the vertex.
2. Is there a simple way to identify the order of the sides of each triangle so that their cross product is ordered correctly to produce ctx --> wm?
Thanks for your help with this.
Don
Hi Don
mris_convert -n lh.white lh.white.normals.asc
should do the trick. And this is the way that the area is computed (from mrisurf.c):
static float mrisTriangleArea(MRIS *mris, int fac, int n) { int n0,n1; face_type *f; float v0[3],v1[3],d1,d2,d3;
n0 = (n == 0) ? VERTICES_PER_FACE-1 : n-1; n1 = (n == VERTICES_PER_FACE-1) ? 0 : n+1; f = &mris->faces[fac]; v0[0] = mris->vertices[f->v[n]].x - mris->vertices[f->v[n0]].x; v0[1] = mris->vertices[f->v[n]].y - mris->vertices[f->v[n0]].y; v0[2] = mris->vertices[f->v[n]].z - mris->vertices[f->v[n0]].z; v1[0] = mris->vertices[f->v[n1]].x - mris->vertices[f->v[n]].x; v1[1] = mris->vertices[f->v[n1]].y - mris->vertices[f->v[n]].y; v1[2] = mris->vertices[f->v[n1]].z - mris->vertices[f->v[n]].z; d1 = -v1[1]*v0[2] + v0[1]*v1[2]; d2 = v1[0]*v0[2] - v0[0]*v1[2]; d3 = -v1[0]*v0[1] + v0[0]*v1[1]; return sqrt(d1*d1+d2*d2+d3*d3)/2; }
cheers Bruce
On Tue, 13 Oct 2015, Krieger, Donald N. wrote:
Hi everyone,
I need to create the vector normal to the surface at each “white” vertex.
I would like to end up with 7 fields in each entry:
1 Vertex number
2-4 RAS coordinates
5-7 RAS components of the normal vector pointed from ctx à wm
mri_annotation2label gets me the first 4.
I just don’t want to reinvent the wheel getting the normal.
If there’s a way to get freesurfer to kick out the normals, that would be best.
Here are naïve questions that arise out of this problem:
1. Is there a simple way to identify which vertices are “nearest neighbors” other than measuring and sorting the distances between each and all the others i.e. which ones form a triangle? I understand to use the normalized average of the 6 triangles which include the vertex.
2. Is there a simple way to identify the order of the sides of each triangle so that their cross product is ordered correctly to produce ctx à wm?
Thanks for your help with this.
Don
Thanks very much, Bruce. That saves me a ton of effort.
Let me confirm a few key details. The command with -n kicks out a file with 2 header lines, a list of normals, and a list of triangles for which each is defined by its 3 vertex numbers. I see the format for a "Triangle Surface File - ASCII version" on Graham Wideman's web pages created many moons ago: http://www.grahamwideman.com/gw/brain/fs/surfacefileformats.htm#TriangleASCI...
Can you point me to more up-to-date and detailed info, perhaps on the wiki? (1) Are the normals in TkRAS coordinates? I can check this pretty easily. Please pardon my laziness in asking. (2) The list of normals I presume are in order beginning at vertex number zero?? I would like to make sure I identify the correct vertex number for each normal. How? (3) Are the normals consistently pointing one way, e.g. ctx --> wm? (4) Is the order of the vertex numbers for each triangle consistent to provide reliable ctx --> wm directionality. If so is it (v1-v2)X(v2-v3) or vica versa?
Best regards, Don
-----Original Message----- From: freesurfer-bounces@nmr.mgh.harvard.edu [mailto:freesurfer- bounces@nmr.mgh.harvard.edu] On Behalf Of Bruce Fischl Sent: Tuesday, October 13, 2015 8:45 AM To: Freesurfer support list Subject: Re: [Freesurfer] list of normals to triangle vertices
Hi Don
mris_convert -n lh.white lh.white.normals.asc
should do the trick. And this is the way that the area is computed (from mrisurf.c):
static float mrisTriangleArea(MRIS *mris, int fac, int n) { int n0,n1; face_type *f; float v0[3],v1[3],d1,d2,d3;
n0 = (n == 0) ? VERTICES_PER_FACE-1 : n-1; n1 = (n == VERTICES_PER_FACE-1) ? 0 : n+1; f = &mris->faces[fac]; v0[0] = mris->vertices[f->v[n]].x - mris->vertices[f->v[n0]].x; v0[1] = mris->vertices[f->v[n]].y - mris->vertices[f->v[n0]].y; v0[2] = mris->vertices[f->v[n]].z - mris->vertices[f->v[n0]].z; v1[0] = mris->vertices[f->v[n1]].x - mris->vertices[f->v[n]].x; v1[1] = mris->vertices[f->v[n1]].y - mris->vertices[f->v[n]].y; v1[2] = mris->vertices[f->v[n1]].z - mris->vertices[f->v[n]].z; d1 = -v1[1]*v0[2] + v0[1]*v1[2]; d2 = v1[0]*v0[2] - v0[0]*v1[2]; d3 = -v1[0]*v0[1] + v0[0]*v1[1]; return sqrt(d1*d1+d2*d2+d3*d3)/2; }
cheers Bruce
On Tue, 13 Oct 2015, Krieger, Donald N. wrote:
Hi everyone,
I need to create the vector normal to the surface at each “white” vertex.
I would like to end up with 7 fields in each entry:
1 Vertex number
2-4 RAS coordinates
5-7 RAS components of the normal vector pointed from ctx à wm
mri_annotation2label gets me the first 4.
I just don’t want to reinvent the wheel getting the normal.
If there’s a way to get freesurfer to kick out the normals, that would be best.
Here are naïve questions that arise out of this problem:
1. Is there a simple way to identify which vertices are “nearest neighbors” other than measuring and sorting the distances between each and all the others i.e. which ones form a triangle? I understand to use the normalized average of the 6 triangles which include the vertex.
2. Is there a simple way to identify the order of the sides of each triangle so that their cross product is ordered correctly to produce ctx à wm?
Thanks for your help with this.
Don
Hi Don
1. I think so, yes. 2. Yes. 3. The convention is that they point outwards from wm->ctx 4. Yes.
On Tue, 13 Oct 2015, Krieger, Donald N. wrote:
Thanks very much, Bruce. That saves me a ton of effort.
Let me confirm a few key details. The command with -n kicks out a file with 2 header lines, a list of normals, and a list of triangles for which each is defined by its 3 vertex numbers. I see the format for a "Triangle Surface File - ASCII version" on Graham Wideman's web pages created many moons ago: http://www.grahamwideman.com/gw/brain/fs/surfacefileformats.htm#TriangleASCI...
Can you point me to more up-to-date and detailed info, perhaps on the wiki? (1) Are the normals in TkRAS coordinates? I can check this pretty easily. Please pardon my laziness in asking. (2) The list of normals I presume are in order beginning at vertex number zero?? I would like to make sure I identify the correct vertex number for each normal. How? (3) Are the normals consistently pointing one way, e.g. ctx --> wm? (4) Is the order of the vertex numbers for each triangle consistent to provide reliable ctx --> wm directionality. If so is it (v1-v2)X(v2-v3) or vica versa?
Best regards, Don
-----Original Message----- From: freesurfer-bounces@nmr.mgh.harvard.edu [mailto:freesurfer- bounces@nmr.mgh.harvard.edu] On Behalf Of Bruce Fischl Sent: Tuesday, October 13, 2015 8:45 AM To: Freesurfer support list Subject: Re: [Freesurfer] list of normals to triangle vertices
Hi Don
mris_convert -n lh.white lh.white.normals.asc
should do the trick. And this is the way that the area is computed (from mrisurf.c):
static float mrisTriangleArea(MRIS *mris, int fac, int n) { int n0,n1; face_type *f; float v0[3],v1[3],d1,d2,d3;
n0 = (n == 0) ? VERTICES_PER_FACE-1 : n-1; n1 = (n == VERTICES_PER_FACE-1) ? 0 : n+1; f = &mris->faces[fac]; v0[0] = mris->vertices[f->v[n]].x - mris->vertices[f->v[n0]].x; v0[1] = mris->vertices[f->v[n]].y - mris->vertices[f->v[n0]].y; v0[2] = mris->vertices[f->v[n]].z - mris->vertices[f->v[n0]].z; v1[0] = mris->vertices[f->v[n1]].x - mris->vertices[f->v[n]].x; v1[1] = mris->vertices[f->v[n1]].y - mris->vertices[f->v[n]].y; v1[2] = mris->vertices[f->v[n1]].z - mris->vertices[f->v[n]].z; d1 = -v1[1]*v0[2] + v0[1]*v1[2]; d2 = v1[0]*v0[2] - v0[0]*v1[2]; d3 = -v1[0]*v0[1] + v0[0]*v1[1]; return sqrt(d1*d1+d2*d2+d3*d3)/2; }
cheers Bruce
On Tue, 13 Oct 2015, Krieger, Donald N. wrote:
Hi everyone,
I need to create the vector normal to the surface at each “white” vertex.
I would like to end up with 7 fields in each entry:
1 Vertex number
2-4 RAS coordinates
5-7 RAS components of the normal vector pointed from ctx à wm
mri_annotation2label gets me the first 4.
I just don’t want to reinvent the wheel getting the normal.
If there’s a way to get freesurfer to kick out the normals, that would be best.
Here are naïve questions that arise out of this problem:
1. Is there a simple way to identify which vertices are “nearest neighbors” other than measuring and sorting the distances between each and all the others i.e. which ones form a triangle? I understand to use the normalized average of the 6 triangles which include the vertex.
2. Is there a simple way to identify the order of the sides of each triangle so that their cross product is ordered correctly to produce ctx à wm?
Thanks for your help with this.
Don
Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
Thank you very much.
Best regards, Don
-----Original Message----- From: freesurfer-bounces@nmr.mgh.harvard.edu [mailto:freesurfer- bounces@nmr.mgh.harvard.edu] On Behalf Of Bruce Fischl Sent: Tuesday, October 13, 2015 10:51 AM To: Freesurfer support list Subject: Re: [Freesurfer] list of normals to triangle vertices
Hi Don
- I think so, yes.
- Yes.
- The convention is that they point outwards from wm->ctx 4. Yes.
On Tue, 13 Oct 2015, Krieger, Donald N. wrote:
Thanks very much, Bruce. That saves me a ton of effort.
Let me confirm a few key details. The command with -n kicks out a file with 2 header lines, a list of normals,
and a list of triangles for which each is defined by its 3 vertex numbers.
I see the format for a "Triangle Surface File - ASCII version" on Graham
Wideman's web pages created many moons ago:
http://www.grahamwideman.com/gw/brain/fs/surfacefileformats.htm#Triang leASCII
Can you point me to more up-to-date and detailed info, perhaps on the wiki? (1) Are the normals in TkRAS coordinates? I can check this pretty easily. Please pardon my laziness in asking. (2) The list of normals I presume are in order beginning at vertex number zero?? I would like to make sure I identify the correct vertex number for each normal. How? (3) Are the normals consistently pointing one way, e.g. ctx --> wm? (4) Is the order of the vertex numbers for each triangle consistent to provide reliable ctx --> wm directionality. If so is it (v1-v2)X(v2-v3) or vica versa?
Best regards,
Don
-----Original Message----- From: freesurfer-bounces@nmr.mgh.harvard.edu [mailto:freesurfer- bounces@nmr.mgh.harvard.edu] On Behalf Of Bruce Fischl Sent: Tuesday, October 13, 2015 8:45 AM To: Freesurfer support list Subject: Re: [Freesurfer] list of normals to triangle vertices
Hi Don
mris_convert -n lh.white lh.white.normals.asc
should do the trick. And this is the way that the area is computed (from mrisurf.c):
static float mrisTriangleArea(MRIS *mris, int fac, int n) { int n0,n1; face_type *f; float v0[3],v1[3],d1,d2,d3;
n0 = (n == 0) ? VERTICES_PER_FACE-1 : n-1; n1 = (n == VERTICES_PER_FACE-1) ? 0 : n+1; f = &mris->faces[fac]; v0[0] = mris->vertices[f->v[n]].x - mris->vertices[f->v[n0]].x; v0[1] = mris->vertices[f->v[n]].y - mris->vertices[f->v[n0]].y; v0[2] = mris->vertices[f->v[n]].z - mris->vertices[f->v[n0]].z; v1[0] = mris->vertices[f->v[n1]].x - mris->vertices[f->v[n]].x; v1[1] = mris->vertices[f->v[n1]].y - mris->vertices[f->v[n]].y; v1[2] = mris->vertices[f->v[n1]].z - mris->vertices[f->v[n]].z; d1 = -v1[1]*v0[2] + v0[1]*v1[2]; d2 = v1[0]*v0[2] - v0[0]*v1[2]; d3 = -v1[0]*v0[1] + v0[0]*v1[1]; return sqrt(d1*d1+d2*d2+d3*d3)/2; }
cheers Bruce
On Tue, 13 Oct 2015, Krieger, Donald N. wrote:
Hi everyone,
I need to create the vector normal to the surface at each “white” vertex.
I would like to end up with 7 fields in each entry:
1 Vertex number
2-4 RAS coordinates
5-7 RAS components of the normal vector pointed from ctx à wm
mri_annotation2label gets me the first 4.
I just don’t want to reinvent the wheel getting the normal.
If there’s a way to get freesurfer to kick out the normals, that would be best.
Here are naïve questions that arise out of this problem:
1. Is there a simple way to identify which vertices are “nearest neighbors” other than measuring and sorting the distances between each and all the others i.e. which ones form a triangle? I understand to use the normalized average of the 6 triangles which include
the vertex.
2. Is there a simple way to identify the order of the sides of each triangle so that their cross product is ordered correctly to produce ctx à wm?
Thanks for your help with this.
Don
Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
freesurfer@nmr.mgh.harvard.edu