int PeakProcessor::DiscoverPeaks (std::vector<double> *vect_mz, std::vector<double> *vect_intensity, double start_mz, double stop_mz) { if(vect_intensity->size() < 1) return 0 ; mobj_peak_data->Clear() ; int num_data_pts = (int) (*vect_intensity).size() ; int ilow ; int ihigh ; Peak peak ; int start_index = mobj_pk_index.GetNearestBinary(*vect_mz, start_mz, 0, num_data_pts-1) ; int stop_index = mobj_pk_index.GetNearestBinary(*vect_mz, stop_mz, start_index, num_data_pts-1) ; if (start_index <= 0) start_index = 1 ; if (stop_index >= (int)vect_mz->size() -2) stop_index = (int)vect_mz->size() - 2 ; for (int index = start_index ; index <= stop_index ; index++) { double FWHM = -1 ; double current_intensity = (*vect_intensity)[index] ; double last_intensity = (*vect_intensity)[index-1] ; double next_intensity = (*vect_intensity)[index+1] ; double current_mz = (*vect_mz)[index] ; if (menm_profile_type == CENTROIDED) { if (current_intensity >= mdbl_peak_intensity_threshold) { double mass_ = (*vect_mz)[index] ; double SN = current_intensity / mdbl_peak_intensity_threshold ; double FWHM = 0.6 ; peak.Set(mass_, current_intensity, SN, mobj_peak_data->GetNumPeaks(), index, FWHM) ; mobj_peak_data->AddPeak(peak) ; } } else if (menm_profile_type == PROFILE) { if(current_intensity >= last_intensity && current_intensity >= next_intensity && current_intensity >= this->mdbl_peak_intensity_threshold) { //See if the peak meets the conditions. //The peak data will be found at _transformData->begin()+i+1. double SN = 0 ; if (!mbln_thresholded_data) SN = this->mobj_peak_statistician.FindSignalToNoise(current_intensity, (*vect_intensity), index); else SN = current_intensity / mdbl_background_intensity ; // Run Full-Width Half-Max algorithm to try and squeak out a higher SN if(SN < this->mdbl_signal_2_noise_threshold) { double mass_ = (*vect_mz)[index] ; FWHM = this->mobj_peak_statistician.FindFWHM((*vect_mz), (*vect_intensity), index, SN); if(FWHM > 0 && FWHM < 0.5) { ilow = mobj_pk_index.GetNearestBinary((*vect_mz), current_mz - FWHM, 0, index); ihigh = mobj_pk_index.GetNearestBinary((*vect_mz), current_mz + FWHM, index, stop_index); double low_intensity = (*vect_intensity)[ilow] ; double high_intensity = (*vect_intensity)[ihigh] ; double sum_intensity = low_intensity + high_intensity ; if(sum_intensity) SN = (2.0 * current_intensity) / sum_intensity ; else SN = 10; } } // Found a peak, make sure it is in the attention list, if there is one. if(SN >= this->mdbl_signal_2_noise_threshold && ( !this->mbln_chk_attention_list || this->IsInAttentionList(current_mz))) { // Find a more accurate m/z location of the peak. double fittedPeak = mobj_peak_fit.Fit(index, (*vect_mz), (*vect_intensity)); if (FWHM == -1) { FWHM = this->mobj_peak_statistician.FindFWHM((*vect_mz), (*vect_intensity), index, SN); } if (FWHM > 0) { peak.Set(fittedPeak, current_intensity, SN, mobj_peak_data->GetNumPeaks(), index, FWHM) ; mobj_peak_data->AddPeak(peak) ; } // move beyond peaks have the same intensity. bool incremented = false ; while( index < num_data_pts && (*vect_intensity)[index] == current_intensity) { incremented = true ; index++ ; } if(index > 0 && index < num_data_pts && incremented) index-- ; } } } } mobj_peak_data->mptr_vect_mzs = vect_mz ; mobj_peak_data->mptr_vect_intensities = vect_intensity ; return mobj_peak_data->GetNumPeaks() ; }