MNE helpers
mne
- timeflux.helpers.mne.logger
- timeflux.helpers.mne.xarray_to_mne(data, meta, context_key, event_id, reporting='warn', ch_types='eeg', **kwargs)[source]
Convert DataArray and meta into mne Epochs object
- Parameters
data (DataArray) – Array of dimensions (‘epoch’, ‘time’, ‘space’)
meta (dict) – Dictionary with keys ‘epochs_context’, ‘rate’, ‘epochs_onset’
context_key (str|None) – key to select the context label.
string (If the context is a) –
None. (context_key should be set to) –
event_id (dict) – Associates context label to an event_id that should be an int. (eg. dict(auditory=1, visual=3))
reporting ('warn'|'error'| None) – How this function handles epochs with invalid context: - ‘error’ will raise a TimefluxException - ‘warn’ will print a warning with
warnings.warn()
and skip the corrupted epochs -None
will skip the corrupted epochs
- Returns
mne object with the converted data.
- Return type
epochs (mne.Epochs)
- timeflux.helpers.mne.mne_to_xarray(epochs, context_key, event_id, output='dataarray')[source]
Convert mne Epochs object into DataArray along with meta.
- Parameters
epochs (mne.Epochs) – mne object with the converted data.
context_key (str|None) – key to select the context label.
string (If the context is a) –
None. (context_key should be set to) –
event_id (dict) – Associates context label to an event_id that should be an int. (eg. dict(auditory=1, visual=3))
output (str) – type of the expected output (DataArray or Dataset)
- Returns
Array of dimensions (‘epoch’, ‘time’, ‘space’) meta (dict): Dictionary with keys ‘epochs_context’, ‘rate’, ‘epochs_onset’
- Return type
data (DataArray|Dataset)