IMP logo
IMP Reference Guide  2.6.1
The Integrative Modeling Platform
d/PCAFitRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em2d/PCAFitRestraint.h
3  * \brief fast scoring of fit between Particles in 3D and 2D class averages
4  *
5  * \authors Dina Schneidman
6  * Copyright 2007-2016 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPEM2D_PCA_FIT_RESTRAINT_H
11 #define IMPEM2D_PCA_FIT_RESTRAINT_H
12 
13 #include <IMP/em2d/em2d_config.h>
14 #include <IMP/em2d/internal/Image2D.h>
15 #include <IMP/em2d/internal/Projector.h>
16 
17 #include <IMP/Restraint.h>
18 
19 IMPEM2D_BEGIN_NAMESPACE
20 
21 //! Fast scoring of Particles against electron microscopy class averages
22 /**
23  The restraint fits the particles into the 2D images by alignment of
24  principal components of each of the particles' projections with
25  principal components of the 2D class average. Therefore, the
26  particle set should comprise all subunits that are in the
27  image. The aligned projections are scored against 2D class averages
28  using the cross correlation score. This is a fast alignment and score
29  that works well for negative stain EM class averages.
30  */
31 class IMPEM2DEXPORT PCAFitRestraint : public IMP::Restraint {
32 public:
33  //! Constructor
34  /**
35  \param[in] particles The particles participating in the score, which
36  need to have XYZ, radius and mass
37  \param[in] image_files 2D class average filenames in PGM text format
38  \param[in] pixel_size Pixel size in angstroms
39  \param[in] resolution Estimated resolution of the images in angstroms
40  \param[in] projection_number Number of projections of the model
41  to generate and fit to images. The lower the number, the
42  faster the evaluation, but the lower the accuracy.
43  \param[in] reuse_direction Speed up evaluation by only periodically
44  recalculating projections
45  \param[in] n_components Number of the largest components to be
46  considered for the EM image
47  */
48  PCAFitRestraint(Particles particles,
49  const std::vector<std::string>& image_files,
50  double pixel_size, double resolution = 10.0,
51  unsigned int projection_number = 100,
52  bool reuse_direction = false,
53  unsigned int n_components = 1);
54 
55  double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const;
56 
57  unsigned int get_projection_number() const { return projection_number_; }
58 
59  void set_projection_number(unsigned int n) { projection_number_ = n; }
60 
61  // write best projections from last calculation, if evaluate is true,
62  // best projections will be recalculated
63  void write_best_projections(std::string file_name, bool evaluate=false);
64 
65  IMP::ModelObjectsTemp do_get_inputs() const { return ps_; }
67 
68  private:
69  // particles to fit to the images
70  Particles ps_;
71 
72  // EM2D images
73  std::vector<internal::Image2D<> > images_;
74 
75  // image pixel size
76  double pixel_size_;
77 
78  // estimated image resolution
79  double resolution_;
80 
81  // number of particle projections to generate for image fitting
82  unsigned int projection_number_;
83 
84  // from last score calculation
85  std::vector<internal::Image2D<> > best_projections_;
86 
87  // from last calculation
88  IMP::algebra::Vector3Ds best_projections_axis_;
89 
90  // Projector class instance
91  internal::Projector projector_;
92 
93  // Speed up evaluation by only periodically recalculating projections
94  bool reuse_direction_;
95 
96  // Number of the largest components to be considered for the EM image
97  unsigned int n_components_;
98 
99  mutable unsigned long counter_;
100 };
101 
102 IMPEM2D_END_NAMESPACE
103 
104 #endif /* IMPEM2D_PCA_FIT_RESTRAINT_H */
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Fast scoring of Particles against electron microscopy class averages.
IMP::ModelObjectsTemp do_get_inputs() const
Abstract base class for all restraints.
Class for adding derivatives from restraints to the model.
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:52