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

Function morph_labels

mne/label.py:2396–2469  ·  view source on GitHub ↗

Morph a set of labels. This is useful when morphing a set of non-overlapping labels (such as those obtained with :func:`read_labels_from_annot`) from one subject to another. Parameters ---------- labels : list The labels to morph. subject_to : str The su

(
    labels,
    subject_to,
    subject_from=None,
    subjects_dir=None,
    surf_name="white",
    verbose=None,
)

Source from the content-addressed store, hash-verified

2394
2395@verbose
2396def morph_labels(
2397 labels,
2398 subject_to,
2399 subject_from=None,
2400 subjects_dir=None,
2401 surf_name="white",
2402 verbose=None,
2403):
2404 """Morph a set of labels.
2405
2406 This is useful when morphing a set of non-overlapping labels (such as those
2407 obtained with :func:`read_labels_from_annot`) from one subject to
2408 another.
2409
2410 Parameters
2411 ----------
2412 labels : list
2413 The labels to morph.
2414 subject_to : str
2415 The subject to morph labels to.
2416 subject_from : str | None
2417 The subject to morph labels from. Can be None if the labels
2418 have the ``.subject`` property defined.
2419 %(subjects_dir)s
2420 surf_name : str
2421 Surface used to obtain vertex locations, e.g., ``'white'``, ``'pial'``.
2422 %(verbose)s
2423
2424 Returns
2425 -------
2426 labels : list
2427 The morphed labels.
2428
2429 See Also
2430 --------
2431 read_labels_from_annot
2432 mne.Label.morph
2433
2434 Notes
2435 -----
2436 This does not use the same algorithm as Freesurfer, so the results
2437 morphing (e.g., from ``'fsaverage'`` to your subject) might not match
2438 what Freesurfer produces during ``recon-all``.
2439
2440 .. versionadded:: 0.18
2441 """
2442 subjects_dir = str(get_subjects_dir(subjects_dir, raise_error=True))
2443 subject_from = _check_labels_subject(labels, subject_from, "subject_from")
2444 mmaps = read_morph_map(subject_from, subject_to, subjects_dir)
2445 vert_poss = [
2446 _load_vert_pos(subject_to, subjects_dir, surf_name, hemi, mmap.shape[0])
2447 for hemi, mmap in zip(("lh", "rh"), mmaps)
2448 ]
2449 idxs = [mmap.argmax(axis=1) for mmap in mmaps]
2450 out_labels = list()
2451 values = filename = None
2452 for label in labels:
2453 li = dict(lh=0, rh=1)[label.hemi]

Callers 1

test_morph_labelsFunction · 0.90

Calls 6

get_subjects_dirFunction · 0.85
_check_labels_subjectFunction · 0.85
read_morph_mapFunction · 0.85
_load_vert_posFunction · 0.85
LabelClass · 0.85
appendMethod · 0.45

Tested by 1

test_morph_labelsFunction · 0.72