# Attenuating peaks of a signal in a specific direction

Consider a segment of a time-domain signal shown in the following graph and the two marked peaks, the first one facing downwards (in red) and the second one facing upwards (in black).

I would like to attenuate the peak facing downwards only. Unfortunately, both peaks seem to have the same frequency, so a linear filter that attenuates that frequency will attenuate both peaks. Is there a kind of a filter (perhaps a non-linear filter) that can attenuate peaks that face downward and keep peaks that faces upward (or vice-versa)?

• "both peaks seem to have the same frequency" What frequency does a peak have? – endolith Aug 28 '17 at 21:15
• As I said, I have only presented a small segment of the signal. I meant that these peaks both repeat at a certain frequency, which is similar. Furthermore, the shape of the peak itself has certain frequencies that are dominant, for instance , read about the QRS complex of an ECG signal that in most papers is said to be around 10-25 Hz. – D.Cohen Sep 7 '17 at 6:46

Look at a fixed amount of $N$ samples around the current sample. If the current sample is significantly below that, modify the sample to be closer to a low-pass variant of the original signal.
You're signal's peaks seem to be very sharp so as another option you can calculate derivative of your signal and peaks($d[n] = x[n]-x[n-1]$). Set a negative threshold and wherever the derivative is less than that threshold, is most likely downward peak.