Difference in evoked response for same Filtering on EEG on MNE vs Brainstorm

Hi @agramfort,@richard, @mmagnuski

I have been stuck on this thing for a while now. I tried replicating the same process of getting evoked response on MNE as what I used to do with brainstorm. On brainstorm, I follow the process shown in the figure below:

image

On MNE I did,

raw.filter(l_freq=0.1,h_freq=None) %equivalent to dc offset

raw.filter(l_freq=1,h_freq=100) %equvalent to bandpass

picks=mne.pick_types(raw.info,meg=True,eeg=True,eog=False,stim=False,exclude='bads')
raw.notch_filter(np.arange(60,241,60),picks=picks,filter_length='auto',phase='zero') %equivalent to notch.

I removed the same number of channels. For simplicity purpose, I didn’t apply any SSP projections or removed bad segments to ease the comparision.

The raw file after the filtering nearly identical on both softwares. However, why does the evoked response look different, even when the baseline set is the same for both the softwares

For MNE
tmin=-0.2
tmax=0.5
baseline=(-0.2,-0.01)

epochs=mne.Epochs(raww,events=events,event_id=event_id,tmin=tmin,tmax=tmax,baseline=baseline,preload=True)

This is what I obtained after brainstorm

This the image of evoked response on MNE

As you can see, there is a component at around -10ms on MNE , which is missing on Brainstorm, there is also a clear peak at around 350 ms on brainstorm,which I cant see on MNE. There is more hair like diverging component on MNE at later time points(>300 ms) where as they converge on Brainstorm.

If all the process is similar until preprocessing, what is causing difference in the evoked response? The baseline period is also the same.

With Brainstorm:

Raw file preprocessed with MNE:

Why are the evoked response different, when the preprocessed raw file is same?

Hi @Subrat_Bastola,
if you want to have identical results you have to conduct identical, not similar, preprocessing steps:

  • I’m not sure if mne has a public function to remove dc offset but you can remove it by hand doing something like raw._data -= raw.copy().crop(tmin, tmax)._data.mean(axis=1, keepdims=True) (but I didn’t test it)
  • you have to make sure that the filter settings used by mne and brainstorm are the same. Filter edges a just part of the filter specification, there are also transition bandwidths for example - you can read the mne docs page “background information on filtering” (IIRC)

For ease of comparison, I would focus on one channel first and compare how they differ after each preprocessing step (you can also measure the difference using MSE for example).

Are you sure you’re using the same number of events / epochs in both cases?

1 Like

Yes, the number of events are 100 for both. I make comparisons with MEG and see the same results each time, but with EEG the results differ as shown. Any possible reason for that?

The choice of the EEG reference could be causing this. Which reference are you using?

I use average referencing on both. On MNE, I apply average referencing as projector

Is the projector actually applied or just created?

It’s really difficult to tell what’s going on without seeing your code and having access to the data.

Also, my understanding from the BS screenshot is that there, you have 300 events in total? (3 x 100)

BTW the raw preprocessed data you show for BS and MNE are visibly different, see for example channels E8 and E9.
If you want to rigorously figure out the discrepancies then I’d start with identical data and check for differences after each preprocessing step in mne vs brainstorm. You can save the brainstorm data after each preprocessing step to separate mat files and read them into python for comparison with mne results.

1 Like

Exactly, this is what made me believe a different reference was used…