00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef OPENMS_FILTERING_TRANSFORMERS_INTENSITYBALANCEFILTER_H
00028 #define OPENMS_FILTERING_TRANSFORMERS_INTENSITYBALANCEFILTER_H
00029
00030 #include <OpenMS/FILTERING/TRANSFORMERS/FilterFunctor.h>
00031
00032 #include <map>
00033 #include <utility>
00034
00035 namespace OpenMS
00036 {
00045 class IntensityBalanceFilter : public FilterFunctor
00046 {
00047
00048 public:
00049
00050
00051
00053 IntensityBalanceFilter();
00054
00056 IntensityBalanceFilter(const IntensityBalanceFilter& source);
00057
00059 virtual ~IntensityBalanceFilter();
00060
00061
00062
00063
00065 IntensityBalanceFilter& operator=(const IntensityBalanceFilter& source);
00066
00067
00068
00069
00071 static FilterFunctor* create() { return new IntensityBalanceFilter();}
00072
00074 template <typename SpectrumType> double apply(SpectrumType& spectrum)
00075 {
00076 double bands = 10;
00077 std::multimap<double, uint> band_intensity;
00078 double size = spectrum.getPrecursorPeak().getPosition()[0];
00079 uint j = 0;
00080 for (uint i = 0; i < bands; ++i)
00081 {
00082 double intensity = 0;
00083
00084
00085
00086 while (j < spectrum.size() && spectrum.getContainer()[j].getPosition()[0] < (size-300)/bands*(i+1) +300)
00087 {
00088 intensity += spectrum.getContainer()[j++].getIntensity();
00089 }
00090 band_intensity.insert(std::make_pair(intensity,i));
00091 }
00092 j = 0;
00093 double total_intensity = 0;
00094 double twobiggest = 0;
00095 double sevensmallest = 0;
00096 for (std::multimap<double, uint>::reverse_iterator mmrit = band_intensity.rbegin(); mmrit != band_intensity.rend(); ++mmrit, ++j)
00097 {
00098 total_intensity += mmrit->first;
00099
00100 if (j < 2)
00101 {
00102 twobiggest+=mmrit->first;
00103 }
00104
00105 if (j > 2)
00106 {
00107 sevensmallest += mmrit->first;
00108 }
00109 }
00110
00111 return (twobiggest - sevensmallest) / total_intensity;
00112 }
00113
00115 static const String getProductName()
00116 {
00117 return "IntensityBalanceFilter";
00118 }
00119
00120
00121 };
00122 }
00123 #endif // OPENMS_FILTERING_TRANSFORMERS_INTENSITYBALANCEFILTER_H