00001 #include "SimplePeakFinder.h" 00002 00003 SimplePeakFinder::SimplePeakFinder(double minValue, double minDifference): 00004 PeakFinder(), 00005 m_minValue(minValue), 00006 m_minDifference(minDifference) 00007 { 00008 00009 } 00010 00011 void SimplePeakFinder::findPeaks(const std::vector<double>& signal, std::vector<unsigned int>& indexes) const { 00012 indexes.clear(); 00013 for (unsigned int i = 1; i < signal.size() - 1; i++){ 00014 if(isPeak(signal, i)){ 00015 indexes.push_back(i); 00016 } 00017 } 00018 } 00019 00020 bool SimplePeakFinder::isPeak(const std::vector<double>& signal, unsigned int index) const { 00021 return signal[index] > m_minValue && 00022 signal[index] - signal[index - 1] > m_minDifference && 00023 signal[index] - signal[index + 1] > m_minDifference; 00024 } 00025 00026 void SimplePeakFinder::findPeaks(const std::vector< std::vector<double> >& signal, std::vector< std::vector<unsigned int> >& indexes) const{ 00027 indexes.resize(signal.size()); 00028 for (unsigned int i = 0; i < signal.size(); i++){ 00029 findPeaks(signal[i], indexes[i]); 00030 } 00031 } 00032 00033 bool SimplePeakFinder::isPeak(const std::vector< std::vector<double> >& signal, unsigned int index1, unsigned int index2) const{ 00034 return isPeak(signal[index1],index2); 00035 }