Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Put the updated vertex_label into .annotation #30

Open
tanjia123456 opened this issue Oct 13, 2020 · 3 comments
Open

Put the updated vertex_label into .annotation #30

tanjia123456 opened this issue Oct 13, 2020 · 3 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@tanjia123456
Copy link

tanjia123456 commented Oct 13, 2020

hello, After I updated the vertex_label of rh.aparc.a2009s.annot with an algorithm, now I want to replace the vertex_label in the .annot with the updated vertex_label, mainly to see the effect of the segmentation, do you know what to do ?

The procedure for extracting vertex_index, vertex_label is as follows:

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("rhlabels1.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))
@fphammerle
Copy link
Owner

Hi,

sorry, this library does not yet support creating / writing annotation files

Basically you need to invert this reader function: https://github.com/fphammerle/freesurfer-surface/blob/1.1.0/freesurfer_surface/__init__.py#L267

@fphammerle fphammerle added enhancement New feature or request question Further information is requested labels Oct 14, 2020
@tanjia123456
Copy link
Author

OK, I will have a try. Thank you very much!

@tanjia123456
Copy link
Author

@fphammerle https://rdrr.io/cran/freesurferformats/man/write.fs.annot.html This may be useful, if you know how to write it, please open source the code, thank you!

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants