# Eliminating peaks too close

Posted 15 days ago
316 Views
|
10 Replies
|
1 Total Likes
|
 Hi I am working on a 1D (nice) data-set and trying to find its peaks. It picked 2 peaks (121th and 123th data points) due to obvious noises. I am only looking for a rough (not accurate, whichever of the two) location of the peak, but not like to get 2 peak locations. How could I: 1) Set the FindPeaks parameter so it will only find 1 peak? or 2) After get a list of peaks, how could I eliminate close ones among 5-10 peak resulted points?Raw data and curve images are attached.Many thanks.Xiaxing Xiong Attachments:
10 Replies
Sort By:
Posted 15 days ago
Posted 15 days ago
 Please post the code you used to generate the plot. There are no negative values in Example.txt but the plot in OSC-Signal.jpg has negative values.
Posted 15 days ago
 Hi RohitSorry the data is positive, and I am looking for the bottom position. So I multiply it with (-1) and looking for the peaks insteadThanks for looking into my problem.Xiaxing
Posted 15 days ago
 The following in my code: DATA1 = -DATA[[400 ;; 599, All]]; ListPlot[DATA1[[All, 3]], PlotRange -> {{100, 130}, {-0.0000024, -0.0000018 }}] FindPeaks[DATA1[[All, 3]], 5][[All, 1]] The data I attached before is the DATA1 I am looking for peaks of this data set. The result it gives is {121,123}. The peaks found were too close. I just need one of them, whichever one. Could I change the parameter of the FindPeaks so that it will give only one peak?ThanksXiaxing
Posted 14 days ago
 The data I attached before is the DATA1 Example.txt only has 2 columns so, it cannot be DATA1 because this would not work ListPlot[DATA1[[All, 3]], ... 
Posted 14 days ago
 Is there some underlying theoretical model? Or is the shape known but maybe not the coefficients such as a parabola? Or is it just data?If "just data", is there any idea of the measurement errors on each sample point?
Posted 14 days ago
 Without a better understanding of your requirements, I think something like this might work: data = {100, 3, 2, 103, 102, 5, 4, 2, 105, 104, 103, 3}; findPeaks[ data_List, tolerance_List] := Module[ { peaks = FindPeaks[data] , lastPeak = {-Infinity, -Infinity} , forward , reverse }, forward = Map[ With[ { retVal = If[ And[ First[#1] - First[lastPeak] <= tolerance[[1]], Last[#1] - Last[lastPeak] <= tolerance[[2]] ] , Nothing , #1 ] } , lastPeak = #1 ] & , peaks ]; reverse = Map[ With[ { retVal = If[ And[ First[#1] - First[lastPeak] <= tolerance[[1]], Last[#1] - Last[lastPeak] <= tolerance[[2]] ] , Nothing , #1 ] } , lastPeak = #1 ] & , Reverse[forward] ]; Reverse[reverse] ]; findPeaks[data, {3, 3}] 
Posted 14 days ago
 A simple peak finder findPeaks[list_] := (list // BlockMap[(#[[1]] < #[[2]] > #[[3]] &), #, 3, 1] & // Position[True]) + 1 On Mike's sample data peaks = findPeaks@data; values = Extract[data, peaks]; ListPlot[{data, Transpose[{Flatten@peaks, values}]}, PlotStyle -> {Automatic, Red}] 
 Dear Friends. Thank many of you for your help. After a night of think, I got myself the following code to solve some close bottom min data set and eliminated the near by repeat one. Still， Many thanks for you tips and inspirations!Xiaxing BOTTS NUMB = Dimensions[BOTTS][[1]] For[i = NUMB - 1, i > 0, i--, BOTTS = If[BOTTS[[i + 1]] - BOTTS[[i]] < 5, Drop[BOTTS, {i}], BOTTS];] BOTTS The BOTTS before the code gives {2, 262, 520, 522, 775, 1028, 1274, 1517, 1757, 1993, 2225, 2455, \ 2684, 2905, 3125, 3344, 3558, 3560, 3769, 3978} The BOTTS after the code gives {2, 262, 522, 775, 1028, 1274, 1517, 1757, 1993, 2225, 2455, 2684, \ 2905, 3125, 3344, 3560, 3769, 3978} The code eliminated of the the nearby peak@520，@3558