IMP  2.3.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-2014 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/kernel/Restraint.h>
18 
19 IMPEM2D_BEGIN_NAMESPACE
20 
21 //! A restraint for fast scoring of Particles vs. em2d 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 cross correlation score. This is a fast alignment and scoring
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,
36  need to have XYZ, radius and mass
37  \param[in] image_file_names 2D class averages filenames in PGM text format
38  \param[in] pixel_size Pixel size in Angstrom
39  \param[in] resolution Estimated resolution of the images
40  \param[in] projection_number Number of projections to generate and fit to
41  images. The lower the number, the faster the evaluation, but also less
42  accurate.
43  */
45  const std::vector<std::string>& image_files,
46  double pixel_size, double resolution = 10.0,
47  unsigned int projection_number = 100,
48  bool reuse_direction = false);
49 
50  double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const;
51 
52  unsigned int get_projection_number() const { return projection_number_; }
53 
54  void set_projection_number(unsigned int n) { projection_number_ = n; }
55 
56  // write best projections from last calculation, if evaluate is true,
57  // best projections will be recalculated
58  void write_best_projections(std::string file_name, bool evaluate=false);
59 
62 
63  private:
64  // particles to fit to the images
66 
67  // EM2D images
68  std::vector<internal::Image2D<> > images_;
69 
70  // image pixel size
71  double pixel_size_;
72 
73  // estimated image resolution
74  double resolution_;
75 
76  // number of particle projections to generate for image fitting
77  unsigned int projection_number_;
78 
79  // from last score calculation
80  std::vector<internal::Image2D<> > best_projections_;
81 
82  // from last calculation
83  IMP::algebra::Vector3Ds best_projections_axis_;
84 
85  // Projector class instance
86  internal::Projector projector_;
87 
88  bool reuse_direction_;
89 
90  mutable unsigned long counter_;
91 };
92 
93 IMPEM2D_END_NAMESPACE
94 
95 #endif /* IMPEM2D_PCA_FIT_RESTRAINT_H */
Class for adding derivatives from restraints to the model.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
IMP::kernel::ModelObjectsTemp do_get_inputs() const
A restraint for fast scoring of Particles vs. em2d class averages.
Abstract base class for all restraints.
A restraint is a term in an IMP ScoringFunction.