18 #ifdef DEBUG_PEAK_PICKING
67 template <
typename InputPeakIterator>
69 InputPeakIterator end_input,
72 #ifdef DEBUG_PEAK_PICKING
73 std::cout <<
"ContinuousWaveletTransformNumIntegration::transform: start " << begin_input->getMZ() <<
" until " << (end_input - 1)->getMZ() << std::endl;
75 if (fabs(resolution - 1) < 0.0001)
78 SignedSize n = distance(begin_input, end_input);
85 #ifdef DEBUG_PEAK_PICKING
86 std::cout <<
"---------START TRANSFORM---------- \n";
88 InputPeakIterator help = begin_input;
89 for (
int i = 0; i < n; ++i)
91 signal_[i].setMZ(help->getMZ());
95 #ifdef DEBUG_PEAK_PICKING
96 std::cout <<
"---------END TRANSFORM----------" << std::endl;
99 begin_right_padding_ = n;
100 end_left_padding_ = -1;
105 double origin = begin_input->getMZ();
106 double spacing = ((end_input - 1)->getMZ() - origin) / (n - 1);
108 std::vector<double> processed_input(n);
112 InputPeakIterator it_help = begin_input;
113 processed_input[0] = it_help->getIntensity();
118 x = origin +
k * spacing;
120 while (((it_help + 1) < end_input) && ((it_help + 1)->getMZ() < x))
124 processed_input[
k] = getInterpolatedValue_(x, it_help);
128 for (
Int i = 0; i < n; ++i)
130 signal_[i].setMZ(origin + i * spacing);
134 begin_right_padding_ = n;
135 end_left_padding_ = -1;
149 void init(
double scale,
double spacing)
override;
154 template <
typename InputPeakIterator>
155 double integrate_(InputPeakIterator x, InputPeakIterator first, InputPeakIterator last)
157 #ifdef DEBUG_PEAK_PICKING
158 std::cout <<
"integrate_" << std::endl;
162 double middle_spacing = wavelet_.size() * spacing_;
164 double start_pos = ((x->getMZ() - middle_spacing) > first->getMZ()) ? (x->getMZ() - middle_spacing)
166 double end_pos = ((x->getMZ() + middle_spacing) < (last - 1)->getMZ()) ? (x->getMZ() + middle_spacing)
167 : (last - 1)->getMZ();
169 InputPeakIterator help = x;
171 #ifdef DEBUG_PEAK_PICKING
172 std::cout <<
"integrate from middle to start_pos " << help->getMZ() <<
" until " << start_pos << std::endl;
176 while ((help != first) && ((help - 1)->getMZ() > start_pos))
179 double distance = fabs(x->getMZ() - help->getMZ());
181 if (index_w_r >= wavelet_.size())
183 index_w_r = wavelet_.size() - 1;
185 double wavelet_right = wavelet_[index_w_r];
187 #ifdef DEBUG_PEAK_PICKING
188 std::cout <<
"distance x help " << distance << std::endl;
189 std::cout <<
"distance in wavelet_ " << index_w_r * spacing_ << std::endl;
190 std::cout <<
"wavelet_right " << wavelet_right << std::endl;
194 distance = fabs(x->getMZ() - (help - 1)->getMZ());
196 if (index_w_l >= wavelet_.size())
198 index_w_l = wavelet_.size() - 1;
200 double wavelet_left = wavelet_[index_w_l];
204 #ifdef DEBUG_PEAK_PICKING
205 std::cout <<
" help-1 " << (help - 1)->getMZ() <<
" distance x, help-1" << distance << std::endl;
206 std::cout <<
"distance in wavelet_ " << index_w_l * spacing_ << std::endl;
207 std::cout <<
"wavelet_ at left " << wavelet_left << std::endl;
209 std::cout <<
" intensity " << fabs((help - 1)->getMZ() - help->getMZ()) / 2. <<
" * " << (help - 1)->getIntensity() <<
" * " << wavelet_left <<
" + " << (help)->getIntensity() <<
"* " << wavelet_right
213 v += fabs((help - 1)->getMZ() - help->getMZ()) / 2. * ((help - 1)->getIntensity() * wavelet_left + help->getIntensity() * wavelet_right);
220 #ifdef DEBUG_PEAK_PICKING
221 std::cout <<
"integrate from middle to endpos " << (help)->getMZ() <<
" until " << end_pos << std::endl;
223 while ((help != (last - 1)) && ((help + 1)->getMZ() < end_pos))
226 double distance = fabs(x->getMZ() - help->getMZ());
228 if (index_w_l >= wavelet_.size())
230 index_w_l = wavelet_.size() - 1;
232 double wavelet_left = wavelet_[index_w_l];
234 #ifdef DEBUG_PEAK_PICKING
235 std::cout <<
" help " << (help)->getMZ() <<
" distance x, help" << distance << std::endl;
236 std::cout <<
"distance in wavelet_ " << index_w_l * spacing_ << std::endl;
237 std::cout <<
"wavelet_ at left " << wavelet_left << std::endl;
241 distance = fabs(x->getMZ() - (help + 1)->getMZ());
243 if (index_w_r >= wavelet_.size())
245 index_w_r = wavelet_.size() - 1;
247 double wavelet_right = wavelet_[index_w_r];
249 #ifdef DEBUG_PEAK_PICKING
250 std::cout <<
" help+1 " << (help + 1)->getMZ() <<
" distance x, help+1" << distance << std::endl;
251 std::cout <<
"distance in wavelet_ " << index_w_r * spacing_ << std::endl;
252 std::cout <<
"wavelet_ at right " << wavelet_right << std::endl;
255 v += fabs(help->getMZ() - (help + 1)->getMZ()) / 2. * (help->getIntensity() * wavelet_left + (help + 1)->getIntensity() * wavelet_right);
260 #ifdef DEBUG_PEAK_PICKING
261 std::cout <<
"return" << (v / sqrt(scale_)) << std::endl;
263 return v / sqrt(scale_);
267 double integrate_(
const std::vector<double> & processed_input,
double spacing_data,
int index);
270 inline double marr_(
const double x)
const
272 return (1 - x * x) * exp(-x * x / 2);
float IntensityType
Intensity type.
Definition: Peak1D.h:36
int Int
Signed integer type.
Definition: Types.h:76
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:108
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
T round(T x)
Rounds the value.
Definition: MathFunctions.h:184
const double k
Definition: Constants.h:132
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22