External Email - Use Caution
hello, Previously, rh.white and rh.aparc.2009s.annot were used to generate vertex_id and vertex_label, ' from freesurfer_surface import Surface from freesurfer_surface import Label from freesurfer_surface import Annotation
surface = Surface.read_triangular('rh.white') surface.load_annotation_file('rh.aparc.a2009s.annot') with open("rhlabels.txt","w") as f: for vertex_index, vertex in enumerate(surface.vertices): vertex_label_index = surface.annotation.vertex_label_index[vertex_index] vertex_label = surface.annotation.labels[vertex_label_index] #print(vertex_index, vertex, vertex_label) #f.write("vertex_index:{} vertexlabel:{} \n".format(vertex_index, vertex_label)) f.write("vertex_index:{} vertex_label:{}\n".format(vertex_index, vertex_label)) ' the output:vertex_index:0 vertexlabel:Label(name=S_precentral-sup-part, index=70, color=#1514c8) and the label_index obtained after a certain algorithm was updated to replace the vertex_labe_index in rh.aparc.2009s.annot, and then load the result with freeview. But I don't know how to replace the vertex_label_index value in .annot?
Your best bet is using the FS matlab library to script annotation edits (see read_annotation.m and write_annotation.m). Otherwise, if you’re using freesurfer 6, you can use tksurfer to manually edit labels/annotations through the GUI (https://surfer.nmr.mgh.harvard.edu/fswiki/tksurfer_labeledit). Andrew
From: freesurfer-bounces@nmr.mgh.harvard.edu on behalf of 1248742467 1248742467@qq.com Reply-To: FS Help freesurfer@nmr.mgh.harvard.edu Date: Monday, October 19, 2020 at 10:20 PM To: FS Help freesurfer@nmr.mgh.harvard.edu Subject: [Freesurfer] replace the vertex_label_index in .annot file
External Email - Use Caution hello, Previously, rh.white and rh.aparc.2009s.annot were used to generate vertex_id and vertex_label, '
from freesurfer_surface import Surface from freesurfer_surface import Label from freesurfer_surface import Annotation
surface = Surface.read_triangular('rh.white') surface.load_annotation_file('rh.aparc.a2009s.annot') with open("rhlabels.txt","w") as f: for vertex_index, vertex in enumerate(surface.vertices): vertex_label_index = surface.annotation.vertex_label_index[vertex_index] vertex_label = surface.annotation.labels[vertex_label_index] #print(vertex_index, vertex, vertex_label) #f.write("vertex_index:{} vertexlabel:{} \n".format(vertex_index, vertex_label)) f.write("vertex_index:{} vertex_label:{}\n".format(vertex_index, vertex_label)) ' the output:vertex_index:0 vertexlabel:Label(name=S_precentral-sup-part, index=70, color=#1514c8) and the label_index obtained after a certain algorithm was updated to replace the vertex_labe_index in rh.aparc.2009s.annot, and then load the result with freeview. But I don't know how to replace the vertex_label_index value in .annot?
freesurfer@nmr.mgh.harvard.edu