Skip to main content

FsAnnotation

Namespace: FSLIB  ·  Library: FreeSurfer Library

Python equivalent

mne.read_annot in MNE-Python.

#include <fs/fs_annotation.h>

class FSLIB::FsAnnotation

Single-hemisphere FreeSurfer parcellation: vertex → region label plus embedded colortable.

Holds the parsed contents of one .annot file: the dense per-vertex label assignment, the explicit vertex index list it was authored against, and the FsColortable describing the colour and name of every region. Indexing is aligned with the matching FsSurface for the same subject + hemisphere, so label[v] is the region of surface vertex v.

src/examples/ex_fs/main.cpp
FsAnnotation aparc("sample", 0, "aparc", subjectsDir);
FsColortable& colors = aparc.getColortable();
QList<FsLabel> regions;
QList<RowVector4i> regionColors;
aparc.toLabels(white, regions, regionColors);

Public Methods​

FsAnnotation()​

Default constructor.


FsAnnotation(p_sFileName)​

Construts the annotation by reading it of the given file.

Parameters:


FsAnnotation(subject_id, hemi, surf, subjects_dir)​

Construts the annotation by reading it of the given file.

Parameters:

  • subject_id : const QString & Name of subject.

  • hemi : qint32 Which hemisphere to load {0 -> lh, 1 -> rh}.

  • surf : const QString & Name of the atlas to load (eg. aparc.a2009s, aparc, aparc.DKTatlas40, BA, BA.thresh, ...).

  • subjects_dir : const QString & Subjects directory.


FsAnnotation(path, hemi, surf)​

Construts the annotation by reading it of the given file.

Parameters:

  • path : const QString & path to surface directory.

  • hemi : qint32 Which hemisphere to load {0 -> lh, 1 -> rh}.

  • surf : const QString & Name of the atlas to load (eg. aparc.a2009s, aparc, aparc.DKTatlas40, BA, BA.thresh, ...).


~FsAnnotation()​

Destroys the annotation.


clear()​

Initializes the FsAnnotation.


isEmpty()​

Returns whether FsAnnotation is empty.

Returns:

  • bool — true if is empty, false otherwise.

hemi()​

Returns the hemisphere id (0 = lh; 1 = rh).

Returns:

  • qint32 — hemisphere id.

getVertices()​

Returns the vertix indeces.

Returns:

  • Eigen::VectorXi & — vertix indeces.

getVertices()​

Returns the vertix indeces.

Returns:

  • const Eigen::VectorXi — vertix indeces.

getLabelIds()​

Returns the vertix labels.

Returns:

  • Eigen::VectorXi & — vertix labels.

getLabelIds()​

Returns the vertix labels.

Returns:

  • const Eigen::VectorXi — vertix labels.

getColortable()​

Returns the coloratable containing the label based nomenclature.

Returns:


getColortable()​

Returns the coloratable containing the label based nomenclature.

Returns:


toLabels(p_surf, p_qListLabels, p_qListLabelRGBAs, lLabelPicks)​

python labels_from_parc

Converts annotation to a label list and colortable, like mne.read_labels_from_annot: one label per region with vertices, named "<region>-lh|rh", values 1, sorted by name.

Parameters:

  • p_surf : const FsSurface & the surface to read the vertex positions from.

  • p_qListLabels : QList< FsLabel > & the converted labels are appended to a given list. Stored data are not affected.

  • p_qListLabelRGBAs : QList< Eigen::RowVector4i > & the converted label RGBAs are appended to a given list. Stored data are not affected.

  • lLabelPicks : const QStringList & the label names which should be picked.

Returns:

  • bool — true if successful, false otherwise.

filePath()​

annotation file path

Returns:

  • QString — the surf file path.

fileName()​

annotation file name

Returns:

  • QString — the surf file name.

Static Methods​

read(subject_id, hemi, atlas, subjects_dir, p_Annotation)​

Reads a FreeSurfer annotation file.

Parameters:

  • subject_id : const QString & Name of subject.

  • hemi : qint32 Which hemisphere to load {0 -> lh, 1 -> rh}.

  • atlas : const QString & Name of the atlas to load (eg. aparc.a2009s, aparc, aparc.DKTatlas40, BA, BA.thresh, ...).

  • subjects_dir : const QString & Subjects directory.

  • p_Annotation : FsAnnotation & The read annotation.

Returns:

  • bool — true if read sucessful, false otherwise.

read(path, hemi, atlas, p_Annotation)​

Reads a FreeSurfer annotation file.

Parameters:

  • path : const QString & path to label directory.

  • hemi : qint32 Which hemisphere to load {0 -> lh, 1 -> rh}.

  • atlas : const QString & Name of the atlas to load (eg. aparc.a2009s, aparc, aparc.DKTatlas40, BA, BA.thresh, ...).

  • p_Annotation : FsAnnotation & The read annotation.

Returns:

  • bool — true if read sucessful, false otherwise.

read(p_sFileName, p_Annotation)​

Reads an annotation of a file.

Parameters:

Returns:

  • bool — true if successful, false otherwise.

Example​

Used in examples​

ex_clustered_inverse_mne​

Example of a Clustered Inverse Minimum Norm Estimation application.

src/examples/ex_clustered_inverse_mne/main.cpp, line 90
QCommandLineOption invFileOption("invOut", "Path to inverse <file>, which is to be written.", "file", "");
QCommandLineOption stcFileOption("stcOut", "Path to stc <file>, which is to be written.", "file", "");
QCommandLineOption surfOption("surfType", "FsSurface type <type>.", "type", "orig");
QCommandLineOption annotOption("annotType", "FsAnnotation type <type>.", "type", "aparc.a2009s");
QCommandLineOption hemiOption("hemi", "Selected hemisphere <hemi>.", "hemi", "2");
QCommandLineOption subjectOption("subject", "Selected subject <subject>.", "subject", "sample");
QCommandLineOption subjectPathOption("subjectPath", "Selected subject path <subjectPath>.", "subjectPath", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/subjects");

ex_clustered_inverse_mne_raw​

Example of the computation of a clustered inverse mne raw.

src/examples/ex_clustered_inverse_mne_raw/main.cpp, line 95
QCommandLineOption inputOption("fileIn", "The input file <in>.", "in", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif");
QCommandLineOption surfOption("surfType", "FsSurface type <type>.", "type", "inflated");
QCommandLineOption annotOption("annotType", "FsAnnotation type <type>.", "type", "aparc.a2009s");
QCommandLineOption subjectOption("subject", "Selected subject <subject>.", "subject", "sample");
QCommandLineOption subjectPathOption("subjectPath", "Selected subject path <subjectPath>.", "subjectPath", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/subjects");
QCommandLineOption fwdOption("fwd", "Path to forwad solution <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif");
QCommandLineOption covFileOption("cov", "Path to the covariance <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis-cov.fif");
QCommandLineOption evokedIndexOption("aveIdx", "The average <index> to choose from the average file.", "index", "1");
QCommandLineOption eventsFileOption("eve", "Path to the event <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis_raw-eve.fif");
QCommandLineOption hemiOption("hemi", "Selected hemisphere <hemi>.", "hemi", "2");
QCommandLineOption methodOption("method", "Inverse estimation <method>, i.e., 'MNE', 'dSPM' or 'sLORETA'.", "method", "dSPM"); //"MNE" | "dSPM" | "sLORETA"
QCommandLineOption snrOption("snr", "The SNR value used for computation <snr>.", "snr", "1.0"); //3.0;//0.1;//3.0;
QCommandLineOption invFileOutOption("invOut", "Path to inverse <file>, which is to be written.", "file", "");
QCommandLineOption stcFileOutOption("stcOut", "Path to stc <file>, which is to be written.", "file", "");

ex_clustered_inverse_pwl_rap_music_raw​

Example of the computation of a raw clustered inverse Powell RAP-MUSIC.

src/examples/ex_clustered_inverse_pwl_rap_music_raw/main.cpp, line 94
QCommandLineOption eventsFileOption("eve", "Path to the event <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis_raw-eve.fif");
QCommandLineOption fwdOption("fwd", "Path to forwad solution <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif");
QCommandLineOption surfOption("surfType", "FsSurface type <type>.", "type", "orig");
QCommandLineOption annotOption("annotType", "FsAnnotation type <type>.", "type", "aparc.a2009s");
QCommandLineOption subjectOption("subject", "Selected subject <subject>.", "subject", "sample");
QCommandLineOption subjectPathOption("subjectPath", "Selected subject path <subjectPath>.", "subjectPath", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/subjects");
QCommandLineOption stcFileOption("stcOut", "Path to stc <file>, which is to be written.", "file", "");
QCommandLineOption numDipolePairsOption("numDip", "<number> of dipole pairs to localize.", "number", "7");
QCommandLineOption evokedIdxOption("aveIdx", "The average <index> to choose from the average file.", "index", "1");
QCommandLineOption hemiOption("hemi", "Selected hemisphere <hemi>.", "hemi", "2");
QCommandLineOption doMovieOption("doMovie", "Create overlapping movie.", "doMovie", "false");
QCommandLineOption keepCompOption("keepComp", "Keep compensators.", "keepComp", "false");
QCommandLineOption pickAllOption("pickAll", "Pick all channels.", "pickAll", "true");
QCommandLineOption destCompsOption("destComps", "<Destination> of the compensator which is to be calculated.", "destination", "0");

Also used in ex_clustered_inverse_rap_music_raw, ex_connectivity, ex_connectivity_comparison, ex_disp_3D, ex_fs, ex_inverse_mne_raw, ex_inverse_pwl_rap_music, ex_inverse_rap_music, ex_read_fwd, ex_read_fwd_disp_3D, ex_roi_clustered_inverse_pwl_rap_music, ex_st_clustered_inverse_pwl_rap_music.

Authors of this file​