00001 /** 00002 * \file CoarseCCatIntervals.h 00003 * \brief Cross correlation coefficient calculator. 00004 * 00005 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00006 * 00007 */ 00008 00009 #ifndef IMPEM_COARSE_CCAT_INTERVALS_H 00010 #define IMPEM_COARSE_CCAT_INTERVALS_H 00011 00012 #include "em_config.h" 00013 #include "CoarseCC.h" 00014 #include <vector> 00015 00016 IMPEM_BEGIN_NAMESPACE 00017 00018 //! Cross correlation coefficient calculator. 00019 /** Store CCC and derivative values and recompute then every X steps. 00020 */ 00021 class IMPEMEXPORT CoarseCCatIntervals : public CoarseCC 00022 { 00023 00024 public: 00025 00026 CoarseCCatIntervals(const int &ncd); 00027 00028 CoarseCCatIntervals(); 00029 00030 //! Evaluate the cross-correlation value only every X calls to the function. 00031 /*! 00032 * Evaluates the value of the cross correlation term 00033 * but only at given intervals to save computation time. 00034 * Otherwise, the same value is returned\n 00035 * This function has an special behavior, as it 00036 * does not return the true cross correlation coefficient ccc, 00037 * but the value:\n scalefac*(1-ccc)\n 00038 * The reason why is to use this term as part of an scoring 00039 * function that is better the lower the term. 00040 * If you want the cross correlation coefficient, 00041 * use cross_correlation_coefficient() instead. 00042 \param[in] em_map exp EM map 00043 \note correct RMSD and mean MUST be in the header! 00044 \param[in] model_map an empty map that will contain the sampled 00045 particles in the access_p 00046 \param[in] dvx to contain the x partial derivatives 00047 \param[in] dvy to contain the y partial derivatives 00048 \param[in] dvz to contain the z partial derivatives 00049 \param[in] scalefac scale factor to apply to the value of the cross 00050 correlation term 00051 \param[in] lderiv if true, the derivatives of the term are computed 00052 \param[in] eval_interval the number of times the function is going to return 00053 the same value before computing the values again 00054 \return the value of the cross correlation term: scalefac * (1-CCC) 00055 */ 00056 float evaluate(DensityMap &em_map, SampledDensityMap &model_map, 00057 std::vector<float> &dvx, std::vector<float>&dvy, 00058 std::vector<float>&dvz, float scalefac, bool lderiv, 00059 unsigned long eval_interval); 00060 00061 00062 protected: 00063 void allocate_derivatives_array(int ncd); 00064 //! Number of times the evaluation has been called. 00065 /** The evaluation is only performed the first time and when calls_counter 00066 reaches eval_interval. Otherwise the stored_cc_ value is returned */ 00067 int calls_counter_; 00068 //! Stored correlation value 00069 float stored_cc_ ; 00070 //! Stored derivative terms 00071 float *stored_dvx_,*stored_dvy_,*stored_dvz_; 00072 // true when memory for the terms storing the derivatives has been assigned 00073 bool dv_memory_allocated_; 00074 }; 00075 00076 IMPEM_END_NAMESPACE 00077 00078 #endif /* IMPEM_COARSE_CCAT_INTERVALS_H */