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

Function _find_label_paths

mne/coreg.py:541–575  ·  view source on GitHub ↗

Find paths to label files in a subject's label directory. Parameters ---------- subject : str Name of the mri subject. pattern : str | None Pattern for finding the labels relative to the label directory in the MRI subject directory (e.g., "aparc/*.label" will

(subject="fsaverage", pattern=None, subjects_dir=None)

Source from the content-addressed store, hash-verified

539
540
541def _find_label_paths(subject="fsaverage", pattern=None, subjects_dir=None):
542 """Find paths to label files in a subject's label directory.
543
544 Parameters
545 ----------
546 subject : str
547 Name of the mri subject.
548 pattern : str | None
549 Pattern for finding the labels relative to the label directory in the
550 MRI subject directory (e.g., "aparc/*.label" will find all labels
551 in the "subject/label/aparc" directory). With None, find all labels.
552 subjects_dir : None | path-like
553 Override the SUBJECTS_DIR environment variable
554 (sys.environ['SUBJECTS_DIR'])
555
556 Returns
557 -------
558 paths : list
559 List of paths relative to the subject's label directory
560 """
561 subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
562 subject_dir = subjects_dir / subject
563 lbl_dir = subject_dir / "label"
564
565 if pattern is None:
566 paths = []
567 for dirpath, _, filenames in os.walk(lbl_dir):
568 rel_dir = os.path.relpath(dirpath, lbl_dir)
569 for filename in fnmatch.filter(filenames, "*.label"):
570 path = os.path.join(rel_dir, filename)
571 paths.append(path)
572 else:
573 paths = [os.path.relpath(path, lbl_dir) for path in iglob(pattern)]
574
575 return paths
576
577
578def _find_mri_paths(subject, skip_fiducials, subjects_dir):

Callers 1

scale_labelsFunction · 0.85

Calls 4

get_subjects_dirFunction · 0.85
walkMethod · 0.80
filterMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected