mne_bids.get_entity_vals¶
-
mne_bids.
get_entity_vals
(root, entity_key, *, ignore_subjects='emptyroom', ignore_sessions=None, ignore_tasks=None, ignore_runs=None, ignore_processings=None, ignore_spaces=None, ignore_acquisitions=None, ignore_splits=None, ignore_modalities=None, ignore_datatypes=None, with_key=False)[source]¶ Get list of values associated with an entity_key in a BIDS dataset.
BIDS file names are organized by key-value pairs called “entities” [1]. With this function, you can get all values for an entity indexed by its key.
- Parameters
- rootstr | pathlib.Path
Path to the root of the BIDS directory.
- entity_keystr
The name of the entity key to search for.
- ignore_subjectsstr | iterable | None
Subject(s) to ignore. By default, entities from the
emptyroom
mock-subject are not returned. IfNone
, include all subjects.- ignore_sessionsstr | iterable | None
Session(s) to ignore. If
None
, include all sessions.- ignore_tasksstr | iterable | None
Task(s) to ignore. If
None
, include all tasks.- ignore_runsstr | iterable | None
Run(s) to ignore. If
None
, include all runs.- ignore_processingsstr | iterable | None
Processing(s) to ignore. If
None
, include all processings.- ignore_spacesstr | iterable | None
Space(s) to ignore. If
None
, include all spaces.- ignore_acquisitionsstr | iterable | None
Acquisition(s) to ignore. If
None
, include all acquisitions.- ignore_splitsstr | iterable | None
Split(s) to ignore. If
None
, include all splits.- ignore_modalitiesstr | iterable | None
Modalities(s) to ignore. If
None
, include all modalities.- ignore_datatypesstr | iterable | None
Datatype(s) to ignore. If
None
, include all datatypes (i.e.anat
,ieeg
,eeg
,meg
,func
, etc.)- with_keybool
If
True
, returns the full entity with the key and the value. This will for example look like['sub-001', 'sub-002']
. IfFalse
(default), just returns the entity values. This will for example look like['001', '002']
.
- Returns
- entity_valslist of str
List of the values associated with an entity_key in the BIDS dataset pointed to by root.
Notes
This function will scan the entire
root
, except for aderivatives
subfolder placed directly underroot
.References
- 1
https://bids-specification.rtfd.io/en/latest/02-common-principles.html#file-name-structure # noqa: E501
Examples
>>> root = os.path.expanduser('~/mne_data/eeg_matchingpennies') >>> entity_key = 'sub' >>> get_entity_vals(root, entity_key) ['05', '06', '07', '08', '09', '10', '11'] >>> get_entity_vals(root, entity_key, with_key=True) ['sub-05', 'sub-06', 'sub-07', 'sub-08', 'sub-09', 'sub-10', 'sub-11']