35 #ifndef OPENMS_FILTERING_TRANSFORMERS_LINEARRESAMPLER_H    36 #define OPENMS_FILTERING_TRANSFORMERS_LINEARRESAMPLER_H    73       defaults_.setValue(
"spacing", 0.05, 
"Spacing of the resampled output peaks.");
    88       if (spectrum.empty()) 
return;
    90       typename MSSpectrum::iterator first = spectrum.begin();
    91       typename MSSpectrum::iterator last = spectrum.end();
    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       std::vector<Peak1D> resampled_peak_container;
    99       resampled_peak_container.resize(number_resampled_points);
   102       std::vector<Peak1D>::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 = 
static_cast<double>((it + left_index)->getIntensity());
   134         intensity += 
static_cast<double>((first + i)->getIntensity()) * distance_right / spacing_;
   135         (it + left_index)->setIntensity(intensity);
   136         intensity = 
static_cast<double>((it + right_index)->getIntensity());
   137         intensity += 
static_cast<double>((first + i)->getIntensity()) * distance_left;
   138         (it + right_index)->setIntensity(intensity);
   141       spectrum.swap(resampled_peak_container);
   149       startProgress(0, exp.
size(), 
"resampling of data");
   150       for (
Size i = 0; i < exp.
size(); ++i)
   165       spacing_ =  param_.getValue(
"spacing");
   173 #endif // OPENMS_FILTERING_TRANSFORMERS_LINEARRESAMPLER_H 
Linear Resampling of raw data. 
Definition: LinearResampler.h:62
 
~LinearResampler()
Destructor. 
Definition: LinearResampler.h:78
 
void rasterExperiment(PeakMap &exp)
Resamples the data in an MSExperiment. 
Definition: LinearResampler.h:147
 
Size size() const
Definition: MSExperiment.h:132
 
Main OpenMS namespace. 
Definition: FeatureDeconvolution.h:47
 
LinearResampler()
Constructor. 
Definition: LinearResampler.h:70
 
The representation of a 1D spectrum. 
Definition: MSSpectrum.h:67
 
virtual void updateMembers_()
This method is used to update extra member variables at the end of the setParameters() method...
Definition: LinearResampler.h:163
 
void raster(MSSpectrum &spectrum)
Applies the resampling algorithm to an MSSpectrum. 
Definition: LinearResampler.h:85
 
In-Memory representation of a mass spectrometry experiment. 
Definition: MSExperiment.h:82
 
size_t Size
Size type e.g. used as variable which can hold result of size() 
Definition: Types.h:128
 
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:161