IMP  2.1.1
The Integrative Modeling Platform
PCAAligner.h
Go to the documentation of this file.
1 /**
2  * \file PCAAligner.h \brief
3  *
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPEM_PCA_ALIGNER_H
9 #define IMPEM_PCA_ALIGNER_H
10 
11 #include <IMP/em/em_config.h>
12 #include <IMP/em/converters.h>
14 #include <IMP/base/Object.h>
15 
16 IMPEM_BEGIN_NAMESPACE
17 
18 /** class that supports fast alignment of a set of points to the density map
19  using principal components of the map and the points.
20 
21  This time of alignment is good for low-resolution maps.
22 
23  Note, that principal components are not well-defined for globular
24  objects, so the method may fail in case of symmetric structures
25  */
26 class IMPEMEXPORT PCAAligner : public IMP::base::Object {
27 public:
28  /** init the distance transform
29  \param map input density map
30  \param density_threshold a threshold that detemines
31  which voxels belong to the object
32  */
33  PCAAligner(IMP::em::DensityMap* map, float density_threshold) :
34  base::Object("EM_PCA_Aligner") {
35  IMP::algebra::Vector3Ds density_points =
36  IMP::em::density2vectors(map, density_threshold);
37  map_pc_ = IMP::algebra::get_principal_components(density_points);
38  }
39 
40  /**
41  align the principal components of the points to the principal
42  components 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::base::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],
60  y[0], y[1], y[2],
61  z[0], z[1], z[2]);
62  }
63 
64 private:
65  IMP::algebra::PrincipalComponentAnalysis map_pc_;
66 };
67 
68 IMPEM_END_NAMESPACE
69 
70 #endif /* IMPEM_PCA_ALIGNER_H */
algebra::Vector3Ds density2vectors(DensityMap *dmap, Float threshold)
Converts a density grid to a set of paritlces.
IMP::base::VersionInfo get_version_info() const
Get information about the module and version of the object.
Definition: PCAAligner.h:49
PCAAligner(IMP::em::DensityMap *map, float density_threshold)
Definition: PCAAligner.h:33
PrincipalComponentAnalysisD< D > get_principal_components(const base::Vector< VectorD< D > > &ps)
Perform principal components analysis on a set of vectors.
Converters of density values.
Class for handling density maps.
Definition: DensityMap.h:98
Vector3D get_vector_product(const Vector3D &p1, const Vector3D &p2)
Returns the vector product (cross product) of two vectors.
Definition: Vector3D.h:31
Common base class for heavy weight IMP objects.
3D rotation class.
Definition: Rotation3D.h:45
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.
Version and module information for Objects.
A shared base class to help in debugging and things.
Principal component analysis of a set of points.