36 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_CONTINUOUSWAVELETTRANSFORMNUMINTEGRATION_H 37 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_CONTINUOUSWAVELETTRANSFORMNUMINTEGRATION_H 45 #ifdef DEBUG_PEAK_PICKING 94 template <
typename InputPeakIterator>
96 InputPeakIterator end_input,
99 #ifdef DEBUG_PEAK_PICKING 100 std::cout <<
"ContinuousWaveletTransformNumIntegration::transform: start " << begin_input->getMZ() <<
" until " << (end_input - 1)->getMZ() << std::endl;
102 if (fabs(resolution - 1) < 0.0001)
105 SignedSize n = distance(begin_input, end_input);
112 #ifdef DEBUG_PEAK_PICKING 113 std::cout <<
"---------START TRANSFORM---------- \n";
115 InputPeakIterator help = begin_input;
116 for (
int i = 0; i < n; ++i)
118 signal_[i].setMZ(help->getMZ());
122 #ifdef DEBUG_PEAK_PICKING 123 std::cout <<
"---------END TRANSFORM----------" << std::endl;
126 begin_right_padding_ = n;
127 end_left_padding_ = -1;
132 double origin = begin_input->getMZ();
133 double spacing = ((end_input - 1)->getMZ() - origin) / (n - 1);
135 std::vector<double> processed_input(n);
139 InputPeakIterator it_help = begin_input;
140 processed_input[0] = it_help->getIntensity();
145 x = origin +
k * spacing;
147 while (((it_help + 1) < end_input) && ((it_help + 1)->getMZ() < x))
151 processed_input[
k] = getInterpolatedValue_(x, it_help);
155 for (
Int i = 0; i < n; ++i)
157 signal_[i].setMZ(origin + i * spacing);
161 begin_right_padding_ = n;
162 end_left_padding_ = -1;
176 virtual void init(
double scale,
double spacing);
181 template <
typename InputPeakIterator>
182 double integrate_(InputPeakIterator x, InputPeakIterator first, InputPeakIterator last)
184 #ifdef DEBUG_PEAK_PICKING 185 std::cout <<
"integrate_" << std::endl;
189 double middle_spacing = wavelet_.size() * spacing_;
191 double start_pos = ((x->getMZ() - middle_spacing) > first->getMZ()) ? (x->getMZ() - middle_spacing)
193 double end_pos = ((x->getMZ() + middle_spacing) < (last - 1)->getMZ()) ? (x->getMZ() + middle_spacing)
194 : (last - 1)->getMZ();
196 InputPeakIterator help = x;
198 #ifdef DEBUG_PEAK_PICKING 199 std::cout <<
"integrate from middle to start_pos " << help->getMZ() <<
" until " << start_pos << std::endl;
203 while ((help != first) && ((help - 1)->getMZ() > start_pos))
206 double distance = fabs(x->getMZ() - help->getMZ());
208 if (index_w_r >= wavelet_.size())
210 index_w_r = wavelet_.size() - 1;
212 double wavelet_right = wavelet_[index_w_r];
214 #ifdef DEBUG_PEAK_PICKING 215 std::cout <<
"distance x help " << distance << std::endl;
216 std::cout <<
"distance in wavelet_ " << index_w_r * spacing_ << std::endl;
217 std::cout <<
"wavelet_right " << wavelet_right << std::endl;
221 distance = fabs(x->getMZ() - (help - 1)->getMZ());
223 if (index_w_l >= wavelet_.size())
225 index_w_l = wavelet_.size() - 1;
227 double wavelet_left = wavelet_[index_w_l];
231 #ifdef DEBUG_PEAK_PICKING 232 std::cout <<
" help-1 " << (help - 1)->getMZ() <<
" distance x, help-1" << distance << std::endl;
233 std::cout <<
"distance in wavelet_ " << index_w_l * spacing_ << std::endl;
234 std::cout <<
"wavelet_ at left " << wavelet_left << std::endl;
236 std::cout <<
" intensity " << fabs((help - 1)->getMZ() - help->getMZ()) / 2. <<
" * " << (help - 1)->getIntensity() <<
" * " << wavelet_left <<
" + " << (help)->getIntensity() <<
"* " << wavelet_right
240 v += fabs((help - 1)->getMZ() - help->getMZ()) / 2. * ((help - 1)->getIntensity() * wavelet_left + help->getIntensity() * wavelet_right);
247 #ifdef DEBUG_PEAK_PICKING 248 std::cout <<
"integrate from middle to endpos " << (help)->getMZ() <<
" until " << end_pos << std::endl;
250 while ((help != (last - 1)) && ((help + 1)->getMZ() < end_pos))
253 double distance = fabs(x->getMZ() - help->getMZ());
255 if (index_w_l >= wavelet_.size())
257 index_w_l = wavelet_.size() - 1;
259 double wavelet_left = wavelet_[index_w_l];
261 #ifdef DEBUG_PEAK_PICKING 262 std::cout <<
" help " << (help)->getMZ() <<
" distance x, help" << distance << std::endl;
263 std::cout <<
"distance in wavelet_ " << index_w_l * spacing_ << std::endl;
264 std::cout <<
"wavelet_ at left " << wavelet_left << std::endl;
268 distance = fabs(x->getMZ() - (help + 1)->getMZ());
270 if (index_w_r >= wavelet_.size())
272 index_w_r = wavelet_.size() - 1;
274 double wavelet_right = wavelet_[index_w_r];
276 #ifdef DEBUG_PEAK_PICKING 277 std::cout <<
" help+1 " << (help + 1)->getMZ() <<
" distance x, help+1" << distance << std::endl;
278 std::cout <<
"distance in wavelet_ " << index_w_r * spacing_ << std::endl;
279 std::cout <<
"wavelet_ at right " << wavelet_right << std::endl;
282 v += fabs(help->getMZ() - (help + 1)->getMZ()) / 2. * (help->getIntensity() * wavelet_left + (help + 1)->getIntensity() * wavelet_right);
287 #ifdef DEBUG_PEAK_PICKING 288 std::cout <<
"return" << (v / sqrt(scale_)) << std::endl;
290 return v / sqrt(scale_);
294 double integrate_(
const std::vector<double> & processed_input,
double spacing_data,
int index);
297 inline double marr_(
const double x)
const 299 return (1 - x * x) * exp(-x * x / 2);
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:135
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
T round(T x)
Rounds the value.
Definition: MathFunctions.h:138
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
int Int
Signed integer type.
Definition: Types.h:103