muschellij2 / freesurfer

Freesurfer Port to R
10 stars 5 forks source link

read_annotation ? #5

Closed dorianps closed 7 years ago

dorianps commented 7 years ago

Hi @muschellij2

Is there a way to read annotation files with this package? There is a function in Matlab called read_annotation but can't find its corresponding in R.

Thank you.

muschellij2 commented 7 years ago

There is no function.

The method right now is use mris_convert_annot

bert_dir = file.path(fs_subj_dir(), "bert")
gii_file = mris_convert_annot(
 infile = file.path(bert_dir, "surf", "lh.white"),
 annot = file.path(bert_dir, "label", "lh.aparc.annot"),
 ext = ".gii" )

The result is simply an XML file, so you can use xml2:

library(xml2)
doc = read_xml(gii_file)

But you have to do some fun parsing on that.

I have a gifti package that is under development still:

devtools::install_github("muschellij2/gifti")
library(gifti)
res = readgii(gii_file)

I stopped because I didn't have the time to maintain it and the format was changing and didn't seem to be as consistent as the spec indicated.

muschellij2 commented 7 years ago

Closing this