mne_bids.get_entities_from_fname

mne_bids.get_entities_from_fname(fname, on_error='raise')[source]

Retrieve a dictionary of BIDS entities from a filename.

Entities not present in fname will be assigned the value of None.

Parameters
fnameBIDSPath | str

The path to parse.

on_error‘raise’ | ‘warn’ | ‘ignore’

If any unsupported labels in the filename are found and this is set to 'raise', raise a RuntimeError. If 'warn', emit a warning and continue, and if 'ignore', neither raise an exception nor a warning, and return all entities found. For example, currently MNE-BIDS does not support derivatives yet, but the desc entity label is used to differentiate different derivatives and will work with this function if on_error='ignore'.

Returns
paramsdict

A dictionary with the keys corresponding to the BIDS entity names, and the values to the entity values encoded in the filename.

Examples

>>> fname = 'sub-01_ses-exp_run-02_meg.fif'
>>> get_entities_from_fname(fname)
{'subject': '01',
'session': 'exp',
'task': None,
'acquisition': None,
'run': '02',
'processing': None,
'space': None,
'recording': None,
'split': None,
'suffix': 'meg'}

Examples using mne_bids.get_entities_from_fname