MCPcopy
hub / github.com/mne-tools/mne-python / read_labels_from_annot

Function read_labels_from_annot

mne/label.py:2249–2374  ·  view source on GitHub ↗

Read labels from a FreeSurfer annotation file. Note: Only cortical labels will be returned. Parameters ---------- %(subject)s parc : str The parcellation to use, e.g., ``'aparc'`` or ``'aparc.a2009s'``. hemi : str The hemisphere from which to read the parcel

(
    subject,
    parc="aparc",
    hemi="both",
    surf_name="white",
    annot_fname=None,
    regexp=None,
    subjects_dir=None,
    sort=True,
    verbose=None,
)

Source from the content-addressed store, hash-verified

2247
2248@verbose
2249def read_labels_from_annot(
2250 subject,
2251 parc="aparc",
2252 hemi="both",
2253 surf_name="white",
2254 annot_fname=None,
2255 regexp=None,
2256 subjects_dir=None,
2257 sort=True,
2258 verbose=None,
2259):
2260 """Read labels from a FreeSurfer annotation file.
2261
2262 Note: Only cortical labels will be returned.
2263
2264 Parameters
2265 ----------
2266 %(subject)s
2267 parc : str
2268 The parcellation to use, e.g., ``'aparc'`` or ``'aparc.a2009s'``.
2269 hemi : str
2270 The hemisphere from which to read the parcellation, can be ``'lh'``,
2271 ``'rh'``, or ``'both'``.
2272 surf_name : str
2273 Surface used to obtain vertex locations, e.g., ``'white'``, ``'pial'``.
2274 annot_fname : path-like | None
2275 Filename of the ``.annot`` file. If not None, only this file is read
2276 and the arguments ``parc`` and ``hemi`` are ignored.
2277 regexp : str
2278 Regular expression or substring to select particular labels from the
2279 parcellation. E.g. ``'superior'`` will return all labels in which this
2280 substring is contained.
2281 %(subjects_dir)s
2282 sort : bool
2283 If true, labels will be sorted by name before being returned.
2284
2285 .. versionadded:: 0.21.0
2286 %(verbose)s
2287
2288 Returns
2289 -------
2290 labels : list of Label
2291 The labels, sorted by label name (ascending).
2292
2293 See Also
2294 --------
2295 write_labels_to_annot
2296 morph_labels
2297 """
2298 logger.info("Reading labels from parcellation...")
2299
2300 subjects_dir = get_subjects_dir(subjects_dir)
2301 if subjects_dir is not None:
2302 subjects_dir = str(subjects_dir)
2303
2304 # get the .annot filenames and hemispheres
2305 annot_fname, hemis = _get_annot_fname(
2306 annot_fname, subject, hemi, parc, subjects_dir

Callers 15

test_annot_ioFunction · 0.90
test_morph_labelsFunction · 0.90
test_labels_to_stcFunction · 0.90
test_split_labelFunction · 0.90
test_expandFunction · 0.90
test_stc_methodsFunction · 0.90

Calls 10

get_subjects_dirFunction · 0.85
_get_annot_fnameFunction · 0.85
setFunction · 0.85
_read_annotFunction · 0.85
_load_vert_posFunction · 0.85
LabelClass · 0.85
infoMethod · 0.80
compileMethod · 0.80
addMethod · 0.80
appendMethod · 0.45

Tested by 15

test_annot_ioFunction · 0.72
test_morph_labelsFunction · 0.72
test_labels_to_stcFunction · 0.72
test_split_labelFunction · 0.72
test_expandFunction · 0.72
test_stc_methodsFunction · 0.72