42 baseline.set_size(spectrum.n_rows);
43 arma::vec T1 = spectrum;
44 arma::vec T2 = spectrum;
47 u1 = std::ceil((wm + 1) / 2) + 1;
49 for (arma::uword i = 2; i <= wm; ++i){
50 u2 = u1 + 1 + (i % 2);
54 for (arma::uword i = wm + 1; i <= spectrum.n_rows - wm; ++i){
55 if ((spectrum(u1) <= T1(i - 2)) && spectrum(u1 - wm - 1) != T1(i - 2))
61 u1 = spectrum.n_rows - 2*wm - 1;
62 for (arma::uword i = spectrum.n_rows - wm + 1; i <= spectrum.n_rows; ++i){
63 u2 = u1 + 1 + ((i + 1) % 2);
72 u1 = std::ceil((wm + 1) / 2.0) + 1;
74 for (arma::uword i = 2; i <= wm; ++i){
75 u2 = u1 + 1 + (i % 2);
79 for (arma::uword i = wm + 1; i <= spectrum.n_rows - wm; ++i){
80 if ((T1(u1) >= T2(i - 2)) && (T1(u1 - wm - 1) != T2(i - 2)))
86 for (arma::uword i = spectrum.n_rows - wm + 1; i <= spectrum.n_rows; ++i){
87 u2 = u1 + 1 + ((i + 1) % 2);
89 T2(i - 1) = T2(i - 2);
96 u1 = std::ceil(ws / 2.0);
98 for (arma::uword i = 1; i <= ws; ++i){
99 u2 = u1 + 1 + (i % 2);
101 baseline(i - 1) = v / double(u2);
105 baseline(ws) = v / (2*ws+1);
106 for (arma::uword i = ws + 2; i <= spectrum.n_rows - ws; ++i){
107 v = v - T2(i - ws - 2) + T2(i + ws - 1);
108 baseline(i - 1) = v / double(2*ws+1);
110 u1 = spectrum.n_rows - 2 * ws + 1;
112 baseline(spectrum.n_rows - ws) = v / double(2*ws);
113 for (arma::uword i = spectrum.n_rows - ws + 2; i <= spectrum.n_rows; ++i){
114 u2 = u1 + 1 + (i+1) % 2;
116 baseline(i - 1) = v / double(spectrum.n_rows - u2 + 1);
120 return spectrum - baseline;
124 arma::mat &baselines,
128 arma::mat corrected(spectra.n_rows, spectra.n_cols);
130 baselines.set_size(spectra.n_rows, spectra.n_cols);
132 #pragma omp parallel for default(none) \ 133 shared(spectra, baselines, wm, ws, corrected) 134 for (intmax_t i = 0; i < (intmax_t) spectra.n_cols; ++i)
136 #pragma omp parallel for default(none) \ 137 shared(spectra, baselines, wm, ws, corrected) 138 for (
size_t i = 0; i < spectra.n_cols; ++i)
143 baselines.col(i) = baseline;
VESPUCCI_EXPORT arma::uword max(arma::uword a, arma::uword b)
Vespucci::Math::max.
VESPUCCI_EXPORT arma::vec RollingBallBaseline(const arma::vec &spectrum, arma::vec &baseline, arma::uword wm, arma::uword ws)
Vespucci::Math::Baseline::RollingBallBaseline.
VESPUCCI_EXPORT arma::mat SafeRows(const arma::mat &x, arma::uword a, arma::uword b)
Vespucci::Math::SafeRows.
VESPUCCI_EXPORT arma::uword min(arma::uword a, arma::uword b)
Vespucci::Math::min.
VESPUCCI_EXPORT arma::mat RollingBallBaselineMat(const arma::mat &spectra, arma::mat &baselines, arma::uword wm, arma::uword ws)