35 #ifndef OPENMS_FILTERING_TRANSFORMERS_LINEARRESAMPLER_H 36 #define OPENMS_FILTERING_TRANSFORMERS_LINEARRESAMPLER_H 72 defaults_.setValue(
"spacing", 0.05,
"Spacing of the resampled output peaks.");
84 template <
typename PeakType>
88 if (spectrum.empty())
return;
93 double end_pos = (last - 1)->getMZ();
94 double start_pos = first->getMZ();
95 int number_raw_points =
static_cast<int>(spectrum.size());
96 int number_resampled_points =
static_cast<int>(ceil((end_pos - start_pos) / spacing_ + 1));
98 typename std::vector<PeakType> resampled_peak_container;
99 resampled_peak_container.resize(number_resampled_points);
102 typename std::vector<PeakType>::iterator it = resampled_peak_container.begin();
103 for (
int i = 0; i < number_resampled_points; ++i)
105 it->setMZ(start_pos + i * spacing_);
111 double distance_left = 0.;
112 double distance_right = 0.;
116 it = resampled_peak_container.begin();
117 for (
int i = 0; i < number_raw_points; ++i)
119 int help =
static_cast<int>(floor(((first + i)->getMZ() - start_pos) / spacing_));
120 left_index = (help < 0) ? 0 : help;
121 help = distance(first, last) - 1;
122 right_index = (left_index >= help) ? help : left_index + 1;
125 distance_left = fabs((first + i)->getMZ() - (it + left_index)->getMZ()) / spacing_;
128 distance_right = fabs((first + i)->getMZ() - (it + right_index)->getMZ());
133 double intensity = (it + left_index)->getIntensity();
134 intensity += (first + i)->getIntensity() * distance_right / spacing_;
135 (it + left_index)->setIntensity(intensity);
136 intensity = (it + right_index)->getIntensity();
137 intensity += (first + i)->getIntensity() * distance_left;
138 (it + right_index)->setIntensity(intensity);
141 spectrum.swap(resampled_peak_container);
147 template <
typename PeakType>
150 startProgress(0, exp.
size(),
"resampling of data");
151 for (
Size i = 0; i < exp.
size(); ++i)
166 spacing_ = param_.getValue(
"spacing");
174 #endif // OPENMS_FILTERING_TRANSFORMERS_LINEARRESAMPLER_H Linear Resampling of raw data.
Definition: LinearResampler.h:61
Size size() const
Definition: MSExperiment.h:117
~LinearResampler()
Destructor.
Definition: LinearResampler.h:77
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
LinearResampler()
Constructor.
Definition: LinearResampler.h:69
void rasterExperiment(MSExperiment< PeakType > &exp)
Resamples the data in an MSExperiment.
Definition: LinearResampler.h:148
virtual void updateMembers_()
This method is used to update extra member variables at the end of the setParameters() method...
Definition: LinearResampler.h:164
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:69
void raster(MSSpectrum< PeakType > &spectrum)
Applies the resampling algorithm to an MSSpectrum.
Definition: LinearResampler.h:85
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
double spacing_
Spacing of the resampled data.
Definition: LinearResampler.h:162