Skip to content

Commit ce79252

Browse files
Merge pull request OpenMS#4251 from biosustain/emg_separate_fit
[STYLE] Improve EmgGradientDescent's methods names
2 parents e4da9a7 + f731824 commit ce79252

File tree

3 files changed

+55
-55
lines changed

3 files changed

+55
-55
lines changed

src/openms/include/OpenMS/MATH/MISC/EmgGradientDescent.h

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,53 @@ namespace OpenMS
116116
const double right_pos = 0.0
117117
) const;
118118

119+
/**
120+
@brief The implementation of the gradient descent algorithm for the EMG peak model
121+
122+
@param[in] xs Positions
123+
@param[in] ys Intensities
124+
@param[out] best_h `h` (amplitude) parameter
125+
@param[out] best_mu `mu` (mean) parameter
126+
@param[out] best_sigma `sigma` (standard deviation) parameter
127+
@param[out] best_tau `tau` (exponent relaxation time) parameter
128+
129+
@return The number of iterations necessary to reach the best values for the parameters
130+
*/
131+
UInt estimateEmgParameters(
132+
const std::vector<double>& xs,
133+
const std::vector<double>& ys,
134+
double& best_h,
135+
double& best_mu,
136+
double& best_sigma,
137+
double& best_tau
138+
) const;
139+
140+
/**
141+
@brief Compute the EMG function on a set of points
142+
143+
If class parameter `compute_additional_points` is `"true"`, the algorithm
144+
will detect which side of the peak is cutoff and add points to it.
145+
146+
@param[in] xs Positions
147+
@param[in] h Amplitude
148+
@param[in] mu Mean
149+
@param[in] sigma Standard deviation
150+
@param[in] tau Exponent relaxation time
151+
@param[out] out_xs The output positions
152+
@param[out] out_ys The output intensities
153+
*/
154+
void applyEstimatedParameters(
155+
const std::vector<double>& xs,
156+
const double h,
157+
const double mu,
158+
const double sigma,
159+
const double tau,
160+
std::vector<double>& out_xs,
161+
std::vector<double>& out_ys
162+
) const;
163+
119164
protected:
120-
void updateMembers_();
165+
void updateMembers_() override;
121166

122167
/**
123168
@brief Given a peak, extract a training set to be used with the gradient descent algorithm
@@ -181,27 +226,6 @@ namespace OpenMS
181226
) const;
182227

183228
private:
184-
/**
185-
@brief The implementation of the gradient descent algorithm for the EMG peak model
186-
187-
@param[in] xs Positions
188-
@param[in] ys Intensities
189-
@param[out] best_h `h` (amplitude) parameter
190-
@param[out] best_mu `mu` (mean) parameter
191-
@param[out] best_sigma `sigma` (standard deviation) parameter
192-
@param[out] best_tau `tau` (exponent relaxation time) parameter
193-
194-
@return The number of iterations necessary to reach the best values for the parameters
195-
*/
196-
UInt emg_gradient_descent(
197-
const std::vector<double>& xs,
198-
const std::vector<double>& ys,
199-
double& best_h,
200-
double& best_mu,
201-
double& best_sigma,
202-
double& best_tau
203-
) const;
204-
205229
/**
206230
@brief Apply the iRprop+ algorithm for gradient descent
207231
@@ -376,30 +400,6 @@ namespace OpenMS
376400
const double tau
377401
) const;
378402

379-
/**
380-
@brief Compute the EMG function on a set of points
381-
382-
If class parameter `compute_additional_points` is `"true"`, the algorithm
383-
will detect which side of the peak is cutoff and add points to it.
384-
385-
@param[in] xs Positions
386-
@param[in] h Amplitude
387-
@param[in] mu Mean
388-
@param[in] sigma Standard deviation
389-
@param[in] tau Exponent relaxation time
390-
@param[out] out_xs The output positions
391-
@param[out] out_ys The output intensities
392-
*/
393-
void emg_vector(
394-
const std::vector<double>& xs,
395-
const double h,
396-
const double mu,
397-
const double sigma,
398-
const double tau,
399-
std::vector<double>& out_xs,
400-
std::vector<double>& out_ys
401-
) const;
402-
403403
/**
404404
@brief Compute the EMG function on a single point
405405
@@ -506,7 +506,7 @@ namespace OpenMS
506506
return emg_gd_.compute_z(x, mu, sigma, tau);
507507
}
508508

509-
void emg_vector(
509+
void applyEstimatedParameters(
510510
const std::vector<double>& xs,
511511
const double h,
512512
const double mu,
@@ -516,7 +516,7 @@ namespace OpenMS
516516
std::vector<double>& out_ys
517517
) const
518518
{
519-
emg_gd_.emg_vector(xs, h, mu, sigma, tau, out_xs, out_ys);
519+
emg_gd_.applyEstimatedParameters(xs, h, mu, sigma, tau, out_xs, out_ys);
520520
}
521521

522522
double emg_point(

src/openms/source/MATH/MISC/EmgGradientDescent.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ namespace OpenMS
285285
return result;
286286
}
287287

288-
void EmgGradientDescent::emg_vector(
288+
void EmgGradientDescent::applyEstimatedParameters(
289289
const std::vector<double>& xs,
290290
const double h,
291291
const double mu,
@@ -564,7 +564,7 @@ namespace OpenMS
564564
return (max_pos - min_pos) * 0.35;
565565
}
566566

567-
UInt EmgGradientDescent::emg_gradient_descent(
567+
UInt EmgGradientDescent::estimateEmgParameters(
568568
const std::vector<double>& xs,
569569
const std::vector<double>& ys,
570570
double& best_h,
@@ -761,12 +761,12 @@ namespace OpenMS
761761

762762
// EMG parameter estimation with gradient descent
763763
double h, mu, sigma, tau;
764-
emg_gradient_descent(xs, ys, h, mu, sigma, tau);
764+
estimateEmgParameters(xs, ys, h, mu, sigma, tau);
765765

766766
// Estimate the intensities for each point
767767
std::vector<double> out_xs;
768768
std::vector<double> out_ys;
769-
emg_vector(xs, h, mu, sigma, tau, out_xs, out_ys);
769+
applyEstimatedParameters(xs, h, mu, sigma, tau, out_xs, out_ys);
770770

771771
// Prepare the output peak
772772
output_peak = input_peak;

src/tests/class_tests/openms/source/EmgGradientDescent_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ START_SECTION(double emg_point(
594594
}
595595
END_SECTION
596596

597-
START_SECTION(void emg_vector(
597+
START_SECTION(void applyEstimatedParameters(
598598
const std::vector<double>& xs,
599599
const double h,
600600
const double mu,
@@ -616,14 +616,14 @@ START_SECTION(void emg_vector(
616616

617617
params.setValue("compute_additional_points", "false");
618618
emg_f.emg_gd_.setParameters(params);
619-
emg_f.emg_vector(saturated_cutoff_pos_min, h, mu, sigma, tau, out_xs, out_ys);
619+
emg_f.applyEstimatedParameters(saturated_cutoff_pos_min, h, mu, sigma, tau, out_xs, out_ys);
620620
TEST_EQUAL(out_xs.size(), saturated_cutoff_pos_min.size())
621621
TEST_REAL_SIMILAR(out_xs.front(), 14.3310337)
622622
TEST_REAL_SIMILAR(out_ys.front(), 2144281.1472228)
623623

624624
params.setValue("compute_additional_points", "true");
625625
emg_f.emg_gd_.setParameters(params);
626-
emg_f.emg_vector(saturated_cutoff_pos_min, h, mu, sigma, tau, out_xs, out_ys);
626+
emg_f.applyEstimatedParameters(saturated_cutoff_pos_min, h, mu, sigma, tau, out_xs, out_ys);
627627
TEST_EQUAL(out_xs.size(), 71) // more points than before
628628
TEST_REAL_SIMILAR(out_xs.front(), 14.2717555076923) // peak was cutoff on the left side
629629
TEST_REAL_SIMILAR(out_ys.front(), 108845.941990663)

0 commit comments

Comments
 (0)