MNE P3 and ICA Analysis

  • MNE-Python version: 0.22.0
  • operating system: Windows

I’m using MNE for ERP analysis using Quick20 EEG device (vhdr file). I would like to implement full process as MATLAB ERP Core (Kappenman et al., 2020) by using MNE.

First, I would like to ask if it is possible to process full process and get same output as MATLAB (EEGLAB) including preprocessing, ICA etc.

Second, I run ICA with the example provided below. The ICA output shows same result, but the bipolar is reversed (red is blue and blue is red in my output). It also happens even with my own eeg data. How can I fix this??

Lastly, during ICA with my own data, I got “ValueError: All picks must be < n_channels (30), got 30” error… Can I get help with this too??

#Read raw data with MNE
raw ='./Raw_data/EEG/1/1.vhdr', preload=False)
picks = raw.pick_types(meg=False, eeg=True, eog=False).load_data()
reject = dict(eeg=180e-6)
raw.drop_channels(['ExG 1','ExG 2'])  # remove ExG Channel

#Get event code from annotations(vmrk)
events, events_id = mne.events_from_annotations(raw,event_id='auto')

#raw.resample(100, npad="auto")
raw.filter(0.1, 50., fir_design='firwin')  # band-pass filtering in the range 0.1 Hz - 50 Hz

reject = dict(eeg=180e-6)
event_id, tmin, tmax = {'Stimulus/11':10001}, -0.2, 0.5
epochs_params = dict(events=events, event_id=event_id, tmin=tmin, tmax=tmax, reject=reject)
evoked_no_ref = mne.Epochs(raw, **epochs_params).average()

def run_ica(method, fit_params=None):
    ica = ICA(n_components=30, method=method, fit_params=fit_params, random_state=0)
    t0 = time(), picks=picks, reject=reject)
    fit_time = time() - t0
    title = ('ICA decomposition using %s (took %.1fs)' % (method, fit_time))


Sorry for asking lots of questions… but it’s hard to get help from google about MNE yet. I wish I could provide help to others when I get familiar with this later!!

Hello and welcome!

Yes, in principle this is possible, however there will most certainly be minor numerical differences. The effects you will observe, however, will be the same.

The signs of the ICs can randomly flip from ICA run to ICA run. This is nothing to worry about: it’s encoding the exact same information.

Can you post the entire traceback, please?

You do:

and later, in run_ica():

That doesn’t make sense: your picks variable here contains a copy of the raw data with only EEG channels (raw.pick_types() works in-place, i.e. modifies raw)

So most likely what you will want to do is simply remove the picks argument from your call to, reject=reject)