get_peak mode 'pos' also gives negative values

Hi all.
I am performing a ERP study and am extracting my amplitude values. Although I have set mode to positive in the get_peak function, I still get negative values (14% for P1, 40% for N1, 17% for P2). Is this a bug? Or do my peaks just not fall into my time window? This is my code:

channel_p1, latency_p1, value_p1 = image_averaged_per_electrode.get_peak(return_amplitude=True, tmin = 0.080 , tmax = 0.130, mode = 'pos')
            value_p1_microv = int(round(value_p1 * 1e6))  #convert microV       
            latency_p1_milisec = int(round(latency_p1 * 1e3))  # convert to milliseconds
            

Hello,

what do you mean by these percentages…?

Looking at the MNE code, getting negative values when passing mode='pos' should be impossible, but maybe there’s a bug somewhere … can you share a minimal working example that reproduces the problem?

Thanks,
Richard

@richard
The percentage means; the amount of data that is negative while I set mode to pos. e.g. in my selected P1 timewindow, my selected amplitudes are in 17% of all evoked data negative.
I did a convert density source conversion, maybe this causes this issue?

Thanks for the clarification! It would be helpful if you could share a minimal reproducible example that demonstrated the issue, otherwise we’re tapping a bit in the dark here :slight_smile:

Best wishes,
Richard

@richard Do you have a mail adress for me? I rather not upload any data here.

Yes, richard.hoechenberger@gmail.com

Hello @Evelyne_Fraats, this is a bug and we’re working on a fix here:

As a workaround, what you can do for now is explicitly crop the data to the desired time period before running get_peak(), e.g. by doing something like:

evoked.crop(tmin=0.080, tmax=0.130, include_tmax=False)
evoked.get_peak(return_amplitude=True, mode='pos')

This will work around the problem.

Please mind the include_tmax=False parameter; without it, tmax will be included in the evoked data, while when passing tmax to get_peak() as you did before, tmax may not be included!

Maybe this is another reason to crop before running get_peak() :slight_smile:

Best wishes,
Richard

2 Likes