Biotuner MNE

Contents

Biotuner MNE#

MNE integration for biotuner.

Module type: Functions

Provides biotuner_mne(), which computes biotuner metrics for every trial × electrode combination in an MNE Epochs object and returns a pandas DataFrame (optionally saved to CSV).

biotuner_mne(epochs, bt_dict, savefile=False, savename=None)[source]#

Compute biotuner metrics for all trials and electrodes in MNE Epochs.

Iterates over every trial × electrode combination, runs fit_biotuner() with the given parameter dictionary, and collects the results into a pandas.DataFrame. Original epoch metadata (if present) is merged into the output.

Parameters:
  • epochs (mne.Epochs) – MNE Epochs object. Data is accessed via epochs.get_data(), which returns an array of shape (n_trials, n_electrodes, n_samples).

  • bt_dict (dict) – Parameter dictionary for fit_biotuner(). Keys are metric names; values are the corresponding parameter values.

  • savefile (bool, default=False) – If True, write the results DataFrame to CSV.

  • savename (str, optional) – Base filename for the CSV (without extension). If None, derived from epochs.filename by stripping the extension and appending '_biotuner'.

Returns:

df (pd.DataFrame) – One row per trial × electrode combination. Columns include all keys in bt_dict plus 'trial', 'electrode', and any metadata columns attached to the Epochs object.

Examples

>>> import mne
>>> from biotuner.biotuner_mne import biotuner_mne
>>>
>>> epochs = mne.read_epochs('my_epochs-epo.fif')
>>> bt_params = {'peaks_function': 'EMD', 'precision': 0.5, 'n_harm': 10}
>>> df = biotuner_mne(epochs, bt_params, savefile=True)
>>> df.head()