Working with ROIs (Freesurfer): Difference between revisions
Line 17: | Line 17: | ||
=Preparation of .label Files= | =Preparation of .label Files= | ||
The steps described below do not work on .annot files because they are not plaintext and easily manipulated. However, [https://surfer.nmr.mgh.harvard.edu/fswiki/mri_annotation2label mri_annotation2label] will convert a .annot file to a series of .label files. | The steps described below do not work on .annot files because they are not plaintext and easily manipulated. However, [https://surfer.nmr.mgh.harvard.edu/fswiki/mri_annotation2label mri_annotation2label] will convert a .annot file to a series of .label files. | ||
e.g. mri_annotation2label --annotation cache.th13.abs.sig.ocn --hemi rh --subject fsaverage --surf pial --labelbase rh.T1 | |||
=Set Operations on .label Files= | =Set Operations on .label Files= |
Revision as of 14:33, 13 July 2017
The .label files created during autorecon3, or by saving an overlay are plaintext lists of vertices. It should be straightforward to find the intersection or union of the vertices in two or more .label files using common Unix shell commands.
.label Syntax
Below is the first few lines of the lh.banksts.label file for a participant. This file was produced during the Lausanne parcellation procedure.
#!ascii label , from subject FS_0043 vox2ras=TkReg 1457 32992 -47.867 -62.891 33.007 0.0000000000 32993 -48.881 -62.907 32.963 0.0000000000 34014 -47.298 -61.696 33.538 0.0000000000 34015 -47.972 -61.259 33.648 0.0000000000 34024 -47.634 -62.264 33.251 0.0000000000 34025 -48.286 -61.775 33.303 0.0000000000 ...etc
The first line is a header line. The second line indicates the number of vertices in the label file. The remaining lines indicate the vertex number, x,y,z coordinates of the vertex, and I have no idea what that last column indicates but it's not terribly important for our purposes.
Preparation of .label Files
The steps described below do not work on .annot files because they are not plaintext and easily manipulated. However, mri_annotation2label will convert a .annot file to a series of .label files.
e.g. mri_annotation2label --annotation cache.th13.abs.sig.ocn --hemi rh --subject fsaverage --surf pial --labelbase rh.T1
Set Operations on .label Files
Intersecting .label Files (Intersection)
Given what we know about the contents of a label file, the unix comm
command should suffice to find the common entries between two label files, which is the set intersection of vertices appearing in each.
https://mail.nmr.mgh.harvard.edu/pipermail//freesurfer/2009-August/011743.html
Merging .label Files (Union)
A union operation will find all vertices appearing in either .label file. You will want to make sure that only unique values are retained (i.e., you don't want to list the same vertex multiple times in the output .label file).