Can get_peak function specify the maximum or minimum value?

I would like to ask whether the get_peak function can specify the maximum or minimum value?

I want to request the peak value in the erp data, but there are some I want to find the maximum value, and some want to find the minimum value. I want to ask whether the get_peak function can specify the maximum or minimum value.

I don’t understand what this means in the tutorial.This means that if I choose pos or neg, it means that only data with positive or negative values ​​is considered?
mode: {‘pos’,‘neg’,‘abs’}
How to deal with the sign of the data. If ‘pos’ only positive values ​​will be considered. If ‘neg’ only negative values ​​will be considered. If ‘abs’ absolute values ​​will be considered. Defaults to ‘abs’.

And it seems to say The amplitude of the maximum response.

Does this mean that I can only find the peak of the maximum? Can’t find the peak of the minimum?
https://mne.tools/stable/generated/mne.EvokedArray.html?highlight=get_peak#mne.EvokedArray.get_peak

I also tried the mne.preprocessing.peak_finder function, but this function does not support evoke data and I need to convert it to a 1d array. It will return multiple peaks, and it seems that it will not return the latency directly, but will return the index I need to convert it to the latency by myself.

I want to ask if there is a good way to specify the maximum peak or minimum peak?
https://mne.tools/stable/generated/mne.preprocessing.peak_finder.html?highlight=peak%20finder#mne.preprocessing.peak_finder

Very grateful for your help!
Looking forward to your reply!

Evoked.get_peak() can search for peaks in the following ways:

  1. take the absolute value of the data (i.e., turn everything into non-negative values), and find the largest value of that (that’s the default, mode='abs')

  2. only consider positive values (i.e., >0), and find the highest value (mode='pos')

  3. only consider negative values (i.e., <0), and find the smallest value (mode='neg')

There is currently no way to use get_peak() to find the smallest value of a signal that’s always positive; or the largest value of a signal that’s exclusively negative.

I would like to ask what is the better way to find the smallest value of a signal that’s always positive; or the largest value of a signal that’s exclusively negative?

You can use np.argmin(evoked.data, axis=1) and np.argmax(evoked.data, axis=1) to get the indices of the minimum and maximum values, respectively, and use the result to retrieve the respective time points:

idx_min = np.argmin(evoked.data, axis=1)  # min for each channel
idx_max = np.argmax(evoked.data, axis=1)  # max for each channel

t_signal_min = evoked.times[idx_min]
t_signal_max = evoked.times[idx_max]

Thank you very much for your help and your reply.
I understand how to do it.
Thank you very much!

1 Like