brain_pipe.preprocessing.stimulus.load.LoadStimuli¶
- class LoadStimuli(load_from={'stimulus_path': 'stimulus', 'trigger_path': 'trigger'}, load_fn=None, separator='_', **kwargs)¶
Bases:
PipelineStep
Load stimuli from paths.
Attributes
DEFAULT_LOAD_FNS
- __init__(load_from={'stimulus_path': 'stimulus', 'trigger_path': 'trigger'}, load_fn=None, separator='_', **kwargs)¶
Create a LoadStimuli step.
- Parameters:
load_from (Dict[str, str]) – Dictionary mapping the key in the data dictionary to a key prefix where the loaded data will be stored.
load_fn (Union[Callable[[str], Dict[str, Any]], Dict[str, Callable[[str], Dict[str, Any]]]] # noqa: E501) – Function that can load the stimulus. If a callable, it should take a path as input and return a dictionary with the loaded data as key-value pairs. If a dictionary is passed, the keys should be the extensions of the files and the values should be the load functions (see the previous point). If None, the default load functions (see DEFAULT_LOAD_FNS) will be used.
separator (str) – Separator to use between the key prefix (see load_from) and the key of the loaded data.
kwargs (Dict[str, Any]) – Additional keyword arguments to pass to the PreprocessingStep constructor.
Methods
__init__
([load_from, load_fn, separator])Create a LoadStimuli step.
parse_dict_keys
(key[, name, ...])Parse a key or a sequence of keys.
- parse_dict_keys(key: str | Sequence[str] | Mapping[str, str], name='key', require_ordered_dict=False) OrderedDict[str, str] ¶
Parse a key or a sequence of keys.
- Parameters:
- Returns:
A mapping of input keys to output keys.
- Return type:
- Raises:
TypeError – If the key is not a string, a sequence of strings or a mapping of strings. If the key is a mapping but require_ordered_dict is True and the mapping is not an OrderedDict.