IMP  2.0.0
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 */