IMP  2.3.0
The Integrative Modeling Platform
WeightedProfileFitter.h
Go to the documentation of this file.
1 /**
2  * \file IMP/saxs/WeightedProfileFitter.h
3  * \brief Fitting of multiple profiles to the experimental one.
4  * The weights of the profiles are computed analytically using
5  * non-negative least squares fitting (NNLS)
6  *
7  * \authors Dina Schneidman
8  * Copyright 2007-2014 IMP Inventors. All rights reserved.
9  *
10  */
11 
12 #ifndef IMPSAXS_WEIGHTED_PROFILE_FITTER_H
13 #define IMPSAXS_WEIGHTED_PROFILE_FITTER_H
14 
15 #include "ProfileFitter.h"
16 #include "ChiScore.h"
17 #include "WeightedFitParameters.h"
18 #include <IMP/algebra/eigen3/Eigen/Dense>
19 
20 IMPSAXS_BEGIN_NAMESPACE
21 
22 /**
23  Fitting of multiple profiles to the experimental one.
24  The weights of the profiles are computed analytically using
25  non-negative least squares fitting (NNLS).
26 */
27 class IMPSAXSEXPORT WeightedProfileFitter : public ProfileFitter<ChiScore> {
28 
29  public:
30  //! Constructor
31  /**
32  \param[in] exp_profile Experimental profile we want to fit
33  */
34  WeightedProfileFitter(const Profile* exp_profile);
35 
36  //! compute a weighted score that minimizes chi
37  /**
38  it is assumed that the q values of the profiles are the same as
39  the q values of the experimental profile. Use Profile::resample to resample
40  if(NNLS = true, solve non-negative least squares, otherwise solve just
41  least squares, that may return negative weights to be discarded later
42  */
43  Float compute_score(const ProfilesTemp& profiles,
44  std::vector<double>& weights, bool NNLS = true) const;
45 
46  //! fit profiles by optimization of c1/c2 and weights
47  /**
48  it is assumed that the q values of the profiles are the same as
49  the q values of the experimental profile. Use Profile::resample to resample
50  */
51  WeightedFitParameters fit_profile(ProfilesTemp partial_profiles,
52  float min_c1 = 0.95, float max_c1 = 1.05,
53  float min_c2 = -2.0,
54  float max_c2 = 4.0) const;
55 
56  //! write a fit file
57  void write_fit_file(ProfilesTemp partial_profiles,
58  const WeightedFitParameters& fp,
59  const std::string fit_file_name) const;
60 
61  private:
62  WeightedFitParameters search_fit_parameters(
63  ProfilesTemp& partial_profiles, float min_c1, float max_c1, float min_c2,
64  float max_c2, float old_chi, std::vector<double>& weights) const;
65 
66  private:
67  IMP_Eigen::MatrixXf W_; // weights matrix
68 
69  // weights matrix multiplied by experimental intensities vector
70  IMP_Eigen::VectorXf Wb_;
71 
72  // intensities
73  IMP_Eigen::MatrixXf A_;
74 };
75 
76 IMPSAXS_END_NAMESPACE
77 
78 #endif /* IMPSAXS_WEIGHTED_PROFILE_FITTER_H */
Basic chi score implementation.
a class for fitting two profiles
Copyright 2007-2014 IMP Inventors. All rights reserved.
Float compute_score(const Profile *model_profile, bool use_offset=false, const std::string fit_file_name="") const
compute fit score
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
FitParameters fit_profile(Profile *partial_profile, float min_c1=0.95, float max_c1=1.05, float min_c2=-2.0, float max_c2=4.0, bool use_offset=false, const std::string fit_file_name="") const
fit experimental profile through optimization of c1 and c2 parameters