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)
| 539 | |
| 540 | |
| 541 | def _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 | |
| 578 | def _find_mri_paths(subject, skip_fiducials, subjects_dir): |
no test coverage detected