MNE-CPP  beta 1.0
adaptivemp.h
Go to the documentation of this file.
1 //=============================================================================================================
42 #ifndef ADAPTIVEMP_H
43 #define ADAPTIVEMP_H
44 
45 //*************************************************************************************************************
46 //=============================================================================================================
47 // STL INCLUDES
48 //=============================================================================================================
49 
50 #include <iostream>
51 #include <vector>
52 #include <math.h>
53 
54 //*************************************************************************************************************
55 //=============================================================================================================
56 // Utils INCLUDES
57 //=============================================================================================================
58 
59 #include <utils/mp/atom.h>
60 #include <utils/utils_global.h>
61 
62 //*************************************************************************************************************
63 //=============================================================================================================
64 // Eigen INCLUDES
65 //=============================================================================================================
66 
67 #include <Eigen/Core>
68 #include <Eigen/SparseCore>
69 #include <unsupported/Eigen/FFT>
70 
71 //*************************************************************************************************************
72 //=============================================================================================================
73 // QT INCLUDES
74 //=============================================================================================================
75 
76 #include <QThread>
77 #include <QtConcurrent/QtConcurrent>
78 
79 //*************************************************************************************************************
80 //=============================================================================================================
81 // DEFINE NAMESPACE UTILSLIB
82 //=============================================================================================================
83 
84 namespace UTILSLIB
85 {
86 
87 //*************************************************************************************************************
88 //=============================================================================================================
89 // USED NAMESPACES
90 //=============================================================================================================
91 
92 using namespace Eigen;
93 using namespace std;
94 
95 //=============================================================================================================
96 
97 enum ReturnValue{RETURNATOM, RETURNPARAMETERS};
99 //*************************************************************************************************************
105 class UTILSSHARED_EXPORT AdaptiveMp : public QThread
106 {
107  Q_OBJECT
108 
109 public:
110 
121  AdaptiveMp();
122 
123  //=========================================================================================================
134  ~AdaptiveMp();
135 
136  //=========================================================================================================
137 
138  typedef QList<QList<GaborAtom> > adaptive_atom_list;
139  typedef QList<FixDictAtom> fix_dict_atom_list;
140  typedef Eigen::VectorXd VectorXd;
141  typedef Eigen::MatrixXd MatrixXd;
142 
143  bool fix_phase;
144  qreal signal_energy;
145  qreal current_energy;
146  qreal epsilon;
147  qint32 it;
148  qint32 max_it;
149  qint32 max_iterations;
150  VectorXd best_match;
151  MatrixXd signal;
152  QList<QList<GaborAtom> > atom_list;
153  QList<GaborAtom> atoms_in_chns;
154  QList<FixDictAtom> fix_dict_list;
155 
156  //=========================================================================================================
157  /*
158  * adaptiveMP_matching_pursuit
159  *
160  * ### MP Algorithm ###
161  *
162  * running the MP Algorithm introduced by Mallat and Zhang
163  *
164  * @param[in] signal Matrix containing single or mulitchannel signals
165  * @param[in] max_it maximum number of iterations of MP Algorithm
166  * @param[in] epsilon threshold for number of iterations of MP Algorithm
167  *
168  * @return result of MP Algorithm as QList of GaborAtoms
169  */
170  //QList<GaborAtom> matching_pursuit (MatrixXd signal, qint32 max_iterations, qreal epsilon);
171 
172  //=========================================================================================================
185  VectorXcd modulation_function(qint32 N, qreal k);
186 
187  //=========================================================================================================
205  static VectorXd calculate_atom(qint32 sample_count, qreal scale, qint32 translation, qreal modulation, qint32 channel, MatrixXd residuum, ReturnValue return_value, bool fix_phase);
206 
207  //=========================================================================================================
228  void simplex_maximisation(qint32 simplex_it, qreal simplex_reflection, qreal simplex_expansion, qreal simplex_contraction, qreal simplex_full_contraction,
229  GaborAtom *gabor_Atom, VectorXd max_scalar_product, qint32 sample_count, bool fix_phase, MatrixXd residuum, bool trial_separation, qint32 chn);
230 
231  //=========================================================================================================
232 
233 
234 public slots:
235 
236  //ToDo: incapsulate settings in own class and give them to matching_pursuit()
237  QList<QList<GaborAtom> > matching_pursuit (MatrixXd signal, qint32 max_iterations, qreal epsilon, bool fix_phase, qint32 boost, qint32 simplex_it,
238  qreal simplex_reflection, qreal simplex_expansion, qreal simplex_contraction, qreal simplex_full_contraction, bool trial_separation);
239  void recieve_input(MatrixXd signal, qint32 max_iterations, qreal epsilon, bool fix_phase, qint32 boost, qint32 simplex_it,
240  qreal simplex_reflection, qreal simplex_expansion, qreal simplex_contraction, qreal simplex_full_contraction, bool trial_separation);
241 
242  //=========================================================================================================
243 
244 signals:
245 
246  void current_result(qint32 current_iteration, qint32 max_iteration, qreal current_energy, qreal max_energy, MatrixXd residuum,
247  adaptive_atom_list atom_list, fix_dict_atom_list fix_dict_list);
248  void finished_calc();
249 
250  void send_warning(qint32 warning);
251 
252 };
253 
254 } // NAMESPACE
255 
256 #endif // ADAPTIVEMP_H
GaborAtom used in adaptive MP Algorithm.
Definition: atom.h:192
#define UTILSSHARED_EXPORT
Definition: utils_global.h:57
utils library export/import macros.
The adaptiveMP class provides functions several calculating functions to run the Matching Pursuit Alg...
Definition: adaptivemp.h:105
ATOM class declaration, providing core features and parameters of Atoms used in Matching Pursiut Algo...