Nice work. It save a lot of my time.
1) Would like to see you add a threshold value so that it only find min and max that are below or above the threshold. I made a simple modification to the lmax and lmin to include that
2) Would also like to see adding the filtered curve to plot with the graph. I see the same problem with Claudio P. that in a high noise situation, the maxima are different for low and values of filt. Adding the smoothed curve will help me to determine which filt value to use