Extrem differences in amplitude size (microVolt) between python and matlab

Hello everyone,

I need to reanalyse my matlab ERP analysis in python. I managed somehow to code it and the wave form (in my knowledge) looks reasonable I guess. But, there is a huuuge difference in the amplitude size. Matlab gives me values up to about 5 mV whereas python give me hardly values higher then 1 mV.


Would you think this is a analysis mistake like e.g. baseline; or would you think it is only a display error?

Thank you very much!!


Hello @FranziMNE,

from the figures it seems that the unit you get is uV, not mV, which is already a good sign as the signal seems to be within a reasonable range :sweat_smile:

As for your actual question, it’s basically impossible to tell without seeing the code you used in both Matlab and MNE-Python, so I’m afraid I cannot provide any helpful guess here, sorry. All I can say is that the data seems to have been baseline-corrected in MNE, so at least you’ve go that going for you already :+1:

Best wishes,

that’s a bit unexpected. It’s just an ERP ie plain averaging?


Juhey :grin: thank you! I tried to be very careful in regard to same filtering, baseline range etc. when transfering into python but I guess there is still something wrong

In python, I load in preprocessed data and ran ERP analysis with the following code:
Load in data_CSplus_Forgotten, averaged the data, did a grand average then doing the same for
data_CSplus_Remembered and the compare the both grand averages with each other in one plot

    data_CSplus_Forgotten.apply_baseline(baseline=(-0.2, 0)).crop(-0.2,1.0)

grand_avg_CSplus_forg = mne.grand_average(data_CSplus_Forgotten_avg)

mne.viz.plot_compare_evokeds([grand_avg_CSplus_rem,grand_avg_CSplus_forg], combine='mean', picks=['Fz'], title="CSp memory comparison")


Let’s reduce complexity here and only look at a single participant first. Are the difference visible there as well?

Will check on that! Thank you :slight_smile:

To me it looks like you are using two different references.

1 Like

I’ll check on that, thank you! :slight_smile: Would you think, that a difference in references would explain the differences in uV?

Yes, this seems like a very plausible explanation indeed.

1 Like

This is the comparison from matlab (left) and python (right) for one subject

Indeed, the matlab code used mastoid, I used average reference in python.
Still I am worried about the baseline values being far below zero, especially in this plot

This simply implies that you didn’t apply baseline correction after setting the reference.

You mean even before running all the preprocessing on the data? Because in the ERP code I did baseline correction before averaging

But you said you initially used the wrong reference, no? So I assumed you now applied the correct reference post-hoc, i.e. after applying baseline correction. Is that not the case?

In any case you can just try to apply baseline correction again and see if that fixes the issue; it’s a “non-destructive” operation and can be done repeatedly if desired. You can apply it directly on the ERPs, i.e. you don’t even have to go back to the level of epochs.

Yes but independed off if I reference to average or mastoid, there shouldnt be such negative baseline value, or am I wrong about that?
I do baseline correction before averaging, but it doesnt help

for subject in participant_list:
    data_CSplus_Remembered=data['Stimulus/S 28','Stimulus/S 29']
    data_CSplus_Remembered.apply_baseline(baseline=(-0.2, 0)).crop(-0.2,1.0)
        data_CSplus_Remembered['Stimulus/S 28','Stimulus/S 29'].average()
grand_avg_CSplus_rem = mne.grand_average(data_CSplus_Remembered_avg)  

Left with baseline correction (-200 to 0) and Right without

Left looks alright to me, what exactly is your issue with that? What baseline correction does is that it makes it such that the average signal during the baseline period is zero in each channel. It seems very much to me like that is the case in the left figure.

Since there’s quite some activity during the baseline period, one could argue that some task-dependent activity is included in your baseline period. But it’s not an issue with MNE; if anything, it either indicates a problem with your experimental design or the choice of your baseline period.

Best wishes,

Also the signal amplitude of the peak around 0.3 sec is much smaller in MNE than in Matlab. So something is still wrong with the referencing here, I believe.

Ok thanks for your opinion on that :blush:
I go check on that!

Thank you for giving me good hints where to further dig ! That helped me a lot!

a confused PhD student without supervision :sweat_smile:

1 Like