FSnormals.py: Difference between revisions

From MEG Core
Jump to navigation Jump to search
Content added Content deleted
No edit summary
No edit summary
Line 3: Line 3:
==Description==
==Description==


The FSnormals.py program will take a FreeSurfer surface, and output a list of all the vertices and their surface normals. Crucially, given an image in ortho/MEG space, as produced by AFNI's 3dTagAlign or [[orthohull.py|orthohull.py]], FSnormals.py will rotate the surface normals to MEG space. This program is required for use before sam_coreg can be run. Python must be installed. In addition, you must set the FREESURFER_HOME directory and, optionally, the SUBJECTS_DIR. Note that the default SUBJECTS_DIR is $FREESURFER_HOME/subjects, which is probably not where your images are. In addition to producing the surface normals, FSnormals.py will also preserve the annotation from freesurfer which gives the cortical parcel that any given vertice belongs to.
The FSnormals.py program will take a FreeSurfer surface, and output a list of all the vertices and their surface normals. Crucially, given an image in ortho/MEG space, as produced by AFNI's 3dTagAlign or [[orthohull.py|orthohull.py]], FSnormals.py will rotate the surface normals to MEG space. This program is required for use before sam_coreg can be run. Python must be installed. In addition, you must set the FREESURFER_HOME directory and, optionally, the SUBJECTS_DIR. Note that the default SUBJECTS_DIR is $FREESURFER_HOME/subjects, which is probably not where your images are. In addition to producing the surface normals, FSnormals.py will also preserve the annotation from freesurfer which gives the cortical parcel that any given vertex belongs to.


==Usage==
==Usage==
Line 9: Line 9:
FSnormals.py subject [surface]
FSnormals.py subject [surface]


The subject argument corresponds to the FreeSurfer subject designation, and denotes a directory under $SUBJECTS_DIR. The surface argument denotes the surface to use: pial, white, or smoothwm.
Other options:
Other options:
{|
{|
Line 14: Line 15:
| style="width: 10em" | -q || Operate quietly, default is verbose
| style="width: 10em" | -q || Operate quietly, default is verbose
|- valign="top"
|- valign="top"
| -a annotation || Restrict the output to a single annotation region, denoted by its number (see the corresponding ctab for a list of numbers and regions in the label/ directory of each subject's FreeSurfer directory). To select multiple regions, repeat this command.
| -a annotation || Restrict the output to a single annotation region, denoted by its number (see the corresponding ctab for a list of numbers and regions in the label/ directory of each subject's FreeSurfer directory). To select multiple regions, repeat this command. Note that positive numbers denote the left hemisphere, and negative numbers denote the right.
|- valign="top"
|- valign="top"
|-p parcfile|| Specify the parcellation file to use. The default is aparc.a2009s, which is the Destrieux atlas. Other options include aparc (the Desikan-Killiany atlas) and aparc.DKTatlas (the Desikan-Killiany-Tourville atlas).
|-p parcfile|| Specify the parcellation file to use. The default is aparc.a2009s, which is the Destrieux atlas. Other options include aparc (the Desikan-Killiany atlas) and aparc.DKTatlas (the Desikan-Killiany-Tourville atlas).
Line 28: Line 29:
| -o outputfule || Specify an output prefix to use. Otherwise, the output defaults to aparc.a2009s.norm, or whatever parcellation is specified by -p.
| -o outputfule || Specify an output prefix to use. Otherwise, the output defaults to aparc.a2009s.norm, or whatever parcellation is specified by -p.
|}
|}

==Output Files==

The output of FSnormals.py is a single text file, stored in the label subdirectory of the subject's FreeSurfer directory. Each line of the file is a single vertex, and contains seven columns: vx, vy, vz, nx, ny, nz, annot. v x, y, and z are the coordinates in meters. nx, ny, and nz denote the normal vectors. The last number is the annotation or region number, negative for left hemisphere and positive for right.

Revision as of 09:33, 19 March 2019

Return to Source Localization - SAM

Description

The FSnormals.py program will take a FreeSurfer surface, and output a list of all the vertices and their surface normals. Crucially, given an image in ortho/MEG space, as produced by AFNI's 3dTagAlign or orthohull.py, FSnormals.py will rotate the surface normals to MEG space. This program is required for use before sam_coreg can be run. Python must be installed. In addition, you must set the FREESURFER_HOME directory and, optionally, the SUBJECTS_DIR. Note that the default SUBJECTS_DIR is $FREESURFER_HOME/subjects, which is probably not where your images are. In addition to producing the surface normals, FSnormals.py will also preserve the annotation from freesurfer which gives the cortical parcel that any given vertex belongs to.

Usage

FSnormals.py subject [surface]

The subject argument corresponds to the FreeSurfer subject designation, and denotes a directory under $SUBJECTS_DIR. The surface argument denotes the surface to use: pial, white, or smoothwm. Other options:

-q Operate quietly, default is verbose
-a annotation Restrict the output to a single annotation region, denoted by its number (see the corresponding ctab for a list of numbers and regions in the label/ directory of each subject's FreeSurfer directory). To select multiple regions, repeat this command. Note that positive numbers denote the left hemisphere, and negative numbers denote the right.
-t ortho+orig Rotate the output vertices and surface normals into the space defined by the ortho+orig space, in order to use this, ortho+orig must have been generated using the 3dTagAlign command.
-i fac Inflate each vertex according to v' = v + fac * n (-I .001 is 1mm)
-r thresh Use this option to filter out vertices which have near radial normals. The threshold is the absolute value of the dot product of the vertex's position vector (relative to the centroid) with the normal vector, so it ranges from 0 to 1. Large values allow more radial normals, small values (e.g. -r 0.2) pass only more tangential normals.
-L, -R, -B -L or -R means just output the left or right hemisphere, respectively. The default is -B, which will output both.
-o outputfule Specify an output prefix to use. Otherwise, the output defaults to aparc.a2009s.norm, or whatever parcellation is specified by -p.

Output Files

The output of FSnormals.py is a single text file, stored in the label subdirectory of the subject's FreeSurfer directory. Each line of the file is a single vertex, and contains seven columns: vx, vy, vz, nx, ny, nz, annot. v x, y, and z are the coordinates in meters. nx, ny, and nz denote the normal vectors. The last number is the annotation or region number, negative for left hemisphere and positive for right.