void ElutionPeakDetection::smoothData(MassTrace& mt, int win_size) const { // alternative smoothing using SavitzkyGolay // looking at the unit test, this method gives better fits than lowess smoothing // reference paper uses lowess smoothing MSSpectrum<PeakType> spectrum; spectrum.insert(spectrum.begin(), mt.begin(), mt.end()); SavitzkyGolayFilter sg; Param param; param.setValue("polynomial_order", 2); param.setValue("frame_length", std::max(3, win_size)); // frame length must be at least polynomial_order+1, otherwise SG will fail sg.setParameters(param); sg.filter(spectrum); MSSpectrum<PeakType>::iterator iter = spectrum.begin(); std::vector<double> smoothed_intensities; for (; iter != spectrum.end(); ++iter) { smoothed_intensities.push_back(iter->getIntensity()); } mt.setSmoothedIntensities(smoothed_intensities); //alternative end // std::cout << "win_size elution: " << scan_time << " " << win_size << std::endl; // if there is no previous FWHM estimation... do it now // if (win_size == 0) // { // mt.estimateFWHM(false); // estimate FWHM // win_size = mt.getFWHMScansNum(); // } // use one global window size for all mass traces to smooth // std::vector<double> rts, ints; // // for (MassTrace::const_iterator c_it = mt.begin(); c_it != mt.end(); ++c_it) // { // rts.push_back(c_it->getRT()); // ints.push_back(c_it->getIntensity()); // } // LowessSmoothing lowess_smooth; // Param lowess_params; // lowess_params.setValue("window_size", win_size); // lowess_smooth.setParameters(lowess_params); // std::vector<double> smoothed_data; // lowess_smooth.smoothData(rts, ints, smoothed_data); // mt.setSmoothedIntensities(smoothed_data); }
START_SECTION([EXTRA](virtual void init(const PeakIterator& it_begin, const PeakIterator& it_end))) MSSpectrum raw_data; MSSpectrum::const_iterator it; DTAFile dta_file; dta_file.load(OPENMS_GET_TEST_DATA_PATH("SignalToNoiseEstimator_test.dta"), raw_data); SignalToNoiseEstimatorMedian< MSSpectrum > sne; Param p; p.setValue("win_len", 40.0); p.setValue("noise_for_empty_window", 2.0); p.setValue("min_required_elements", 10); sne.setParameters(p); sne.init(raw_data.begin(),raw_data.end()); MSSpectrum stn_data; dta_file.load(OPENMS_GET_TEST_DATA_PATH("SignalToNoiseEstimatorMedian_test.out"), stn_data); int i = 0; for (it=raw_data.begin();it!=raw_data.end(); ++it) { TEST_REAL_SIMILAR (stn_data[i].getIntensity(), sne.getSignalToNoise(it)); //Peak1D peak = (*it); //peak.setIntensity(sne.getSignalToNoise(it)); //stn_data.push_back(peak); ++i; }
START_SECTION(([EXTRA]PeakTypeEstimator())) ptr = new PeakTypeEstimator(); TEST_NOT_EQUAL(ptr, nullPointer) END_SECTION START_SECTION(([EXTRA] ~PeakTypeEstimator())) delete ptr; END_SECTION START_SECTION((template<typename PeakConstIterator> SpectrumSettings::SpectrumType estimateType(const PeakConstIterator& begin, const PeakConstIterator& end) const)) DTAFile file; MSSpectrum spec; // raw data (with zeros) file.load(OPENMS_GET_TEST_DATA_PATH("PeakTypeEstimator_raw.dta"), spec); TEST_EQUAL(PeakTypeEstimator::estimateType(spec.begin(), spec.end()), SpectrumSettings::PROFILE); // TOF raw data (without zeros) file.load(OPENMS_GET_TEST_DATA_PATH("PeakTypeEstimator_rawTOF.dta"), spec); TEST_EQUAL(PeakTypeEstimator::estimateType(spec.begin(), spec.end()), SpectrumSettings::PROFILE); // peak data file.load(OPENMS_GET_TEST_DATA_PATH("PeakTypeEstimator_peak.dta"), spec); TEST_EQUAL(PeakTypeEstimator::estimateType(spec.begin(), spec.end()), SpectrumSettings::CENTROID); // too few data points spec.resize(4); TEST_EQUAL(PeakTypeEstimator::estimateType(spec.begin(), spec.end()), SpectrumSettings::UNKNOWN); END_SECTION ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// END_TEST