IMP logo
IMP Reference Guide  2.11.1
The Integrative Modeling Platform
PCAAligner.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em/PCAAligner.h
3  * \brief Fast alignment of points to a density map using principal components
4  *
5  * Copyright 2007-2019 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEM_PCA_ALIGNER_H
10 #define IMPEM_PCA_ALIGNER_H
11 
12 #include <IMP/em/em_config.h>
13 #include <IMP/em/converters.h>
15 #include <IMP/Object.h>
16 
17 IMPEM_BEGIN_NAMESPACE
18 
19 //! Fast alignment of points to a density map using principal components
20 /** Fast alignment of a set of points to a density map using principal
21  components of the map and the points.
22 
23  This type of alignment is good for low-resolution maps.
24 
25  Note, that principal components are not well-defined for globular
26  objects, so the method may fail in the case of symmetric structures
27  */
28 class IMPEMEXPORT PCAAligner : public IMP::Object {
29  public:
30  //! Constructor
31  /** \param map input density map
32  \param density_threshold a threshold that determines
33  which map voxels to use in the fit
34  */
35  PCAAligner(IMP::em::DensityMap* map, float density_threshold)
36  : Object("EM_PCA_Aligner") {
37  IMP::algebra::Vector3Ds density_points =
38  IMP::em::density2vectors(map, density_threshold);
39  map_pc_ = IMP::algebra::get_principal_components(density_points);
40  }
41 
42  //! Align the principal components of the points to those of the density map.
43  /** \param points The points for PCA alignment to the map
44  \return 24 transformations to the density map
45  */
46  algebra::Transformation3Ds align(const algebra::Vector3Ds& points) const;
47 
48  // methods required by Object
50  return IMP::VersionInfo(get_module_name(), get_module_version());
51  }
52 
53  ~PCAAligner() {}
54 
55  private:
56  algebra::Rotation3D get_rotation_matrix(const algebra::Vector3D& x,
57  const algebra::Vector3D& y) const {
59  return algebra::get_rotation_from_matrix(x[0], x[1], x[2], y[0], y[1], y[2],
60  z[0], z[1], z[2]);
61  }
62 
63  private:
64  IMP::algebra::PrincipalComponentAnalysis map_pc_;
65 };
66 
67 IMPEM_END_NAMESPACE
68 
69 #endif /* IMPEM_PCA_ALIGNER_H */
algebra::Vector3Ds density2vectors(DensityMap *dmap, Float threshold)
Convert a density grid to a set of vectors.
PCAAligner(IMP::em::DensityMap *map, float density_threshold)
Constructor.
Definition: PCAAligner.h:35
Converters of density values.
Fast alignment of points to a density map using principal components.
Definition: PCAAligner.h:28
Class for handling density maps.
Definition: DensityMap.h:93
Vector3D get_vector_product(const Vector3D &p1, const Vector3D &p2)
Return the vector product (cross product) of two vectors.
Definition: Vector3D.h:31
Common base class for heavy weight IMP objects.
Definition: Object.h:106
Version and module information for Objects.
Definition: VersionInfo.h:28
PrincipalComponentAnalysisD< D > get_principal_components(const Vector< VectorD< D > > &ps)
Perform principal components analysis on a set of vectors.
3D rotation class.
Definition: Rotation3D.h:46
Rotation3D get_rotation_from_matrix(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
Generate a Rotation3D object from a rotation matrix.
A shared base class to help in debugging and things.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
Principal component analysis of a set of points.
IMP::VersionInfo get_version_info() const
Get information about the module and version of the object.
Definition: PCAAligner.h:49