Skip to main content

FsLabel

Namespace: FSLIB  ·  Library: FreeSurfer Library

Python equivalent

mne.read_label in MNE-Python.

#include <fs/fs_label.h>

class FSLIB::FsLabel

A FreeSurfer/MNE surface label: per-vertex indices, Tk-RAS positions and scalar values for one hemisphere.

Wraps the parsed contents of a .label file or an in-memory label constructed programmatically (e.g. by thresholding a source estimate via FsLabelUtils::stcToLabel). Vertex indices reference the matching FsSurface for the same subject and hemisphere; positions are the Tk-surface RAS coordinates copied from that surface; values are the per-vertex scalar payload (statistic, time, weight). Hemisphere is encoded with the FreeSurfer convention {0 = lh, 1 = rh}.

src/examples/ex_fs/main.cpp
FsLabel v1;
FsLabel::read(subjectsDir + "/sample/label/lh.V1.label", v1);

Public Methods​

FsLabel()​

Default constructor.


FsLabel(p_vertices, p_pos, p_values, p_hemi, p_name, p_id)​

Constructs a label.

Parameters:

  • p_vertices : const Eigen::VectorXi & Vertices.

  • p_pos : const Eigen::MatrixX3f & Positions.

  • p_values : const Eigen::VectorXd & Values.

  • p_hemi : qint32 Hemisphere (lh = 0; rh = 1).

  • p_name : const QString & label names.

  • p_id : qint32 label id (optional, default = -1).


~FsLabel()​

Destroys the FsLabel class.


clear()​

Initializes the FsLabel.


isEmpty()​

True if FsLabel is empty.

Returns:

  • bool — true if FsLabel is empty, false otherwise.

selectTris(p_Surface)​

Select tris for this label from a given surface file.

Parameters:

  • p_Surface : const FsSurface & to generate the label tris from.

Returns:

  • Eigen::MatrixX3i — the generated tris.

selectTris(p_matTris)​

Select tris for this label from a given tri matrix.

Parameters:

  • p_matTris : const Eigen::MatrixX3i & tris from which the selection should be made.

Returns:

  • Eigen::MatrixX3i — the generated tris.

Static Methods​

read(p_sFileName, p_Label)​

mne_read_label_file

Reads a FsLabel from a FreeSurfer label file. This is based on the FreeSurfer read_label routine SUBJECTS_DIR environment variable is not consulted for the standard location

Parameters:

  • p_sFileName : const QString & label file name.

  • p_Label : FsLabel & read label.

Returns:

  • bool — true if successful, false otherwise.

Example​

Used in examples​

ex_fs​

FreeSurfer library: surfaces, curvature, parcellations, labels and an atlas volume.

src/examples/ex_fs/main.cpp, line 129
FsAnnotation aparc("sample", 0, "aparc", subjectsDir);
FsColortable& colors = aparc.getColortable();
QList<FsLabel> regions;
QList<RowVector4i> regionColors;
aparc.toLabels(white, regions, regionColors);
int precentral = -1;
for (int i = 0; i < regions.size(); ++i) {
if (regions[i].name == "precentral-lh") {
precentral = i;
}
}
// nibabel.freesurfer.read_annot: 36 table entries; mne.read_labels_from_annot: 34 labels, precentral-lh 9505 vertices
ok &= expect(colors.getNames().size() == 36 && regions.size() == 34 && precentral >= 0 && regions[precentral].vertices.size() == 9505,

ex_inv_api​

Inverse library: minimum-norm estimates, resolution matrices, label time courses, sparse solvers.

src/examples/ex_inv_api/main.cpp, line 112
FsLabel v1;
FsLabel::read(data + "/subjects/sample/label/lh.V1.label", v1);
QFile fwdFile(data + "/Result/ref-sample_audvis-meg-eeg-oct-6-fwd.fif");
const MNEForwardSolution fwd = MNEForwardSolution(fwdFile).pick_regions({v1}); // 70 sources x 3 orientations
QFile covFile(data + "/MEG/sample/sample_audvis-cov.fif");
const FiffCov noiseCov(covFile);
QFile aveFile(data + "/MEG/sample/sample_audvis-ave.fif");
const FiffEvoked evoked(aveFile, 0); // "Left Auditory"

ex_inv_beamformer​

Inverse library: LCMV and DICS beamformers and the RAP-MUSIC family of dipole scanners.

src/examples/ex_inv_beamformer/main.cpp, line 111
FsLabel v1;
FsLabel::read(data + "/subjects/sample/label/lh.V1.label", v1);
QFile fwdFile(data + "/Result/ref-sample_audvis-meg-eeg-oct-6-fwd.fif");
MNEForwardSolution fwd = MNEForwardSolution(fwdFile).pick_regions({v1}).pick_channels(good);
FiffEvoked evoked = sample.pick_channels(good);
const FiffInfo info = evoked.info;
QFile covFile(data + "/MEG/sample/sample_audvis-cov.fif");
const FiffCov noiseCov = FiffCov(covFile).pick_channels(good).prepare_noise_cov(info, good);

Also used in ex_roi_clustered_inverse_pwl_rap_music, ex_clustered_inverse_pwl_rap_music_raw.

Authors of this file​