44 #ifdef DEBUG_PEAK_PICKING
93 template <
typename InputPeakIterator>
95 InputPeakIterator end_input,
98 #ifdef DEBUG_PEAK_PICKING
99 std::cout <<
"ContinuousWaveletTransformNumIntegration::transform: start " << begin_input->getMZ() <<
" until " << (end_input - 1)->getMZ() << std::endl;
101 if (fabs(resolution - 1) < 0.0001)
104 SignedSize n = distance(begin_input, end_input);
111 #ifdef DEBUG_PEAK_PICKING
112 std::cout <<
"---------START TRANSFORM---------- \n";
114 InputPeakIterator help = begin_input;
115 for (
int i = 0; i < n; ++i)
117 signal_[i].setMZ(help->getMZ());
121 #ifdef DEBUG_PEAK_PICKING
122 std::cout <<
"---------END TRANSFORM----------" << std::endl;
125 begin_right_padding_ = n;
126 end_left_padding_ = -1;
131 double origin = begin_input->getMZ();
132 double spacing = ((end_input - 1)->getMZ() - origin) / (n - 1);
134 std::vector<double> processed_input(n);
138 InputPeakIterator it_help = begin_input;
139 processed_input[0] = it_help->getIntensity();
144 x = origin +
k * spacing;
146 while (((it_help + 1) < end_input) && ((it_help + 1)->getMZ() < x))
150 processed_input[
k] = getInterpolatedValue_(x, it_help);
154 for (
Int i = 0; i < n; ++i)
156 signal_[i].setMZ(origin + i * spacing);
160 begin_right_padding_ = n;
161 end_left_padding_ = -1;
175 void init(
double scale,
double spacing)
override;
180 template <
typename InputPeakIterator>
181 double integrate_(InputPeakIterator x, InputPeakIterator first, InputPeakIterator last)
183 #ifdef DEBUG_PEAK_PICKING
184 std::cout <<
"integrate_" << std::endl;
188 double middle_spacing = wavelet_.size() * spacing_;
190 double start_pos = ((x->getMZ() - middle_spacing) > first->getMZ()) ? (x->getMZ() - middle_spacing)
192 double end_pos = ((x->getMZ() + middle_spacing) < (last - 1)->getMZ()) ? (x->getMZ() + middle_spacing)
193 : (last - 1)->getMZ();
195 InputPeakIterator help = x;
197 #ifdef DEBUG_PEAK_PICKING
198 std::cout <<
"integrate from middle to start_pos " << help->getMZ() <<
" until " << start_pos << std::endl;
202 while ((help != first) && ((help - 1)->getMZ() > start_pos))
205 double distance = fabs(x->getMZ() - help->getMZ());
207 if (index_w_r >= wavelet_.size())
209 index_w_r = wavelet_.size() - 1;
211 double wavelet_right = wavelet_[index_w_r];
213 #ifdef DEBUG_PEAK_PICKING
214 std::cout <<
"distance x help " << distance << std::endl;
215 std::cout <<
"distance in wavelet_ " << index_w_r * spacing_ << std::endl;
216 std::cout <<
"wavelet_right " << wavelet_right << std::endl;
220 distance = fabs(x->getMZ() - (help - 1)->getMZ());
222 if (index_w_l >= wavelet_.size())
224 index_w_l = wavelet_.size() - 1;
226 double wavelet_left = wavelet_[index_w_l];
230 #ifdef DEBUG_PEAK_PICKING
231 std::cout <<
" help-1 " << (help - 1)->getMZ() <<
" distance x, help-1" << distance << std::endl;
232 std::cout <<
"distance in wavelet_ " << index_w_l * spacing_ << std::endl;
233 std::cout <<
"wavelet_ at left " << wavelet_left << std::endl;
235 std::cout <<
" intensity " << fabs((help - 1)->getMZ() - help->getMZ()) / 2. <<
" * " << (help - 1)->getIntensity() <<
" * " << wavelet_left <<
" + " << (help)->getIntensity() <<
"* " << wavelet_right
239 v += fabs((help - 1)->getMZ() - help->getMZ()) / 2. * ((help - 1)->getIntensity() * wavelet_left + help->getIntensity() * wavelet_right);
246 #ifdef DEBUG_PEAK_PICKING
247 std::cout <<
"integrate from middle to endpos " << (help)->getMZ() <<
" until " << end_pos << std::endl;
249 while ((help != (last - 1)) && ((help + 1)->getMZ() < end_pos))
252 double distance = fabs(x->getMZ() - help->getMZ());
254 if (index_w_l >= wavelet_.size())
256 index_w_l = wavelet_.size() - 1;
258 double wavelet_left = wavelet_[index_w_l];
260 #ifdef DEBUG_PEAK_PICKING
261 std::cout <<
" help " << (help)->getMZ() <<
" distance x, help" << distance << std::endl;
262 std::cout <<
"distance in wavelet_ " << index_w_l * spacing_ << std::endl;
263 std::cout <<
"wavelet_ at left " << wavelet_left << std::endl;
267 distance = fabs(x->getMZ() - (help + 1)->getMZ());
269 if (index_w_r >= wavelet_.size())
271 index_w_r = wavelet_.size() - 1;
273 double wavelet_right = wavelet_[index_w_r];
275 #ifdef DEBUG_PEAK_PICKING
276 std::cout <<
" help+1 " << (help + 1)->getMZ() <<
" distance x, help+1" << distance << std::endl;
277 std::cout <<
"distance in wavelet_ " << index_w_r * spacing_ << std::endl;
278 std::cout <<
"wavelet_ at right " << wavelet_right << std::endl;
281 v += fabs(help->getMZ() - (help + 1)->getMZ()) / 2. * (help->getIntensity() * wavelet_left + (help + 1)->getIntensity() * wavelet_right);
286 #ifdef DEBUG_PEAK_PICKING
287 std::cout <<
"return" << (v / sqrt(scale_)) << std::endl;
289 return v / sqrt(scale_);
293 double integrate_(
const std::vector<double> & processed_input,
double spacing_data,
int index);
296 inline double marr_(
const double x)
const
298 return (1 - x * x) * exp(-x * x / 2);
float IntensityType
Intensity type.
Definition: Peak1D.h:62
int Int
Signed integer type.
Definition: Types.h:102
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
T round(T x)
Rounds the value.
Definition: MathFunctions.h:210
const double k
Definition: Constants.h:158
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48