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_NORMALIZER_H
00028 #define OPENMS_FILTERING_TRANSFORMERS_NORMALIZER_H
00029
00030 #include <OpenMS/FILTERING/TRANSFORMERS/PreprocessingFunctor.h>
00031 #include <vector>
00032
00033 namespace OpenMS
00034 {
00042 class Normalizer
00043 : public PreprocessingFunctor
00044 {
00045 public:
00046
00047
00048
00050 Normalizer();
00051
00053 Normalizer(const Normalizer& source);
00054
00056 virtual ~Normalizer();
00057
00058
00059
00060
00062 Normalizer& operator = (const Normalizer& source);
00063
00064
00065
00066
00068 static PreprocessingFunctor* create() { return new Normalizer();}
00069
00071 static const String getProductName()
00072 {
00073 return "Normalizer";
00074 }
00075
00077 template <typename SpectrumType> void filterSpectrum(SpectrumType& spectrum)
00078 {
00079 typedef typename SpectrumType::Iterator Iterator;
00080 typedef typename SpectrumType::ConstIterator ConstIterator;
00081
00082 String method = param_.getValue("method");
00083
00084
00085 if (method == "to_one")
00086 {
00087 double max(0);
00088 for (ConstIterator it = spectrum.begin(); it != spectrum.end(); ++it)
00089 {
00090 if (max < it->getIntensity())
00091 {
00092 max = it->getIntensity();
00093 }
00094 }
00095 for (Iterator it = spectrum.begin(); it != spectrum.end(); ++it)
00096 {
00097 it->setIntensity(it->getIntensity() / max);
00098 }
00099 return;
00100 }
00101
00102
00103 if (method == "to_TIC")
00104 {
00105 double sum(0);
00106 for (ConstIterator it = spectrum.begin(); it != spectrum.end(); ++it)
00107 {
00108 sum += it->getIntensity();
00109 }
00110
00111 for (Iterator it = spectrum.begin(); it != spectrum.end(); ++it)
00112 {
00113 it->setIntensity(it->getIntensity() / sum);
00114 }
00115 return;
00116 }
00117
00118
00119 throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Method not known", method);
00120 return;
00121
00122 }
00123
00125 void filterPeakSpectrum(PeakSpectrum& spectrum);
00126
00128 void filterPeakMap(PeakMap& exp);
00129
00130
00131 };
00132
00133
00134 }
00135 #endif //OPENMS_FILTERING_TRANSFORMERS_NORMALIZER_H