NeuroTechX / moabb

Mother of All BCI Benchmarks
https://neurotechx.github.io/moabb/
BSD 3-Clause "New" or "Revised" License
683 stars 177 forks source link

Possibility to obtain raw / epochs from paradigm #84

Closed jsosulski closed 4 years ago

jsosulski commented 4 years ago

Currently, when I want to analyze my own / MOABB datasets, I need to have one script for the classification benchmark, and one script that copies basically the same preprocessing steps for plain ERP/EEG analysis. For simplicity, I would be interested in (and willing to implement) a way to obtain the epochs / raws / evokeds using the paradigm and dataset structures in MOABB. This has the advantage that visualizations use exactly the same processing as is used for classification purposes.

In my own fork I am currently simply passing a flag return_epochs=True to the paradigm.get_data() method. If this flag is True, the X array is populated with epochs instead of only containing the underlying data numpy array. Example code how I use this:

paradigm = P300(resample=cfg_prepro['sampling_rate'],
                fmin=cfg_prepro['fmin'], fmax=cfg_prepro['fmax'],
                reject_uv=cfg_prepro['reject_uv'])
dataset = SpotPilotData()
moabb_data = paradigm.get_data(dataset, [1], return_epochs=True)
mne.concatenate_epochs(moabb_data[0])['Target'].average().plot()
alexandrebarachant commented 4 years ago

yes, i think that can be useful. we could return the epoch object instead of the X data here https://github.com/NeuroTechX/moabb/blob/master/moabb/paradigms/p300.py#L141

jsosulski commented 4 years ago

That's where I currently do it. I will send a PR probably next week.