MNE-CPP  beta 1.0
mainwindow.h
1 //=============================================================================================================
40 #ifndef MAINWINDOW_H
41 #define MAINWINDOW_H
42 
43 //*************************************************************************************************************
44 //=============================================================================================================
45 // INCLUDES
46 //=============================================================================================================
47 
48 #include <mne/mne.h>
49 #include <utils/mp/atom.h>
50 #include <utils/mp/adaptivemp.h>
51 #include <utils/mp/fixdictmp.h>
52 
53 #include "editorwindow.h"
54 #include "ui_editorwindow.h"
55 #include "formulaeditor.h"
56 #include "ui_formulaeditor.h"
57 #include "enhancededitorwindow.h"
58 #include "ui_enhancededitorwindow.h"
59 #include "deletemessagebox.h"
60 #include "ui_deletemessagebox.h"
62 #include "ui_processdurationmessagebox.h"
63 #include "treebaseddictwindow.h"
64 #include "ui_treebaseddictwindow.h"
65 #include "settingwindow.h"
66 #include "ui_settingwindow.h"
67 
68 //*************************************************************************************************************
69 //=============================================================================================================
70 // Qt INCLUDES
71 //=============================================================================================================
72 
73 #include <QMainWindow>
74 #include <QtGui>
75 #include <QAbstractTableModel>
76 #include <QImage>
77 #include <QAbstractItemDelegate>
78 #include <QFontMetrics>
79 #include <QModelIndex>
80 #include <QSize>
81 
82 #ifndef UINT32
83 typedef unsigned int UINT32, *PUINT32;
84 #endif
85 #ifndef INT32
86 typedef signed int INT32, *PINT32;
87 #endif
88 #ifndef MAXUINT32
89 #define MAXUINT32 ((UINT32)~((UINT32)0))
90 #endif
91 #ifndef MAXINT32
92 #define MAXINT32 ((INT32)(MAXUINT32 >> 1))
93 #endif
94 #ifndef MININT32
95 #define MININT32 ((INT32)~MAXINT32)
96 #endif
97 
98 
99 //=============================================================================================================
100 // USED NAMESPACES
101 
102 using namespace MNELIB;
103 
104 //=============================================================================================================
105 
106 namespace Ui
107 {
108  class MainWindow;
109 }
110 
111 
112 enum truncation_criterion
113 {
114  Iterations,
115  SignalEnergy,
116  Both
117 };
118 
119 enum source_file_type
120 {
121  AVE,
122  RAW,
123  TXT
124 };
125 
126 class GraphWindow;
127 class ResiduumWindow;
128 class AtomSumWindow;
129 class XAxisWindow;
130 
131 class MainWindow : public QMainWindow
132 {
133  Q_OBJECT
134 
135 public:
136  //**********************************************************************************************************
137  //constructor
138  explicit MainWindow(QWidget *parent = 0);
139  ~MainWindow();
140  //**********************************************************************************************************
141 
142  typedef QList<QList<GaborAtom> > adaptive_atom_list;
143  typedef QList<FixDictAtom> fix_dict_atom_list;
144  typedef QMap<qint32, bool> select_map;
145  typedef Eigen::VectorXd VectorXd;
146  typedef Eigen::RowVectorXi RowVectorXi;
147  //==========================================================================================================
157  void fill_dict_combobox();
158 
159  //==========================================================================================================
160 
161  //==========================================================================================================
171  void save_fif_file();
172 
173 
174 private slots:
175  //==========================================================================================================
185  void on_btt_Calc_clicked();
186 
187  //==========================================================================================================
197  void on_actionW_rterbucheditor_triggered();
198 
199  //==========================================================================================================
209  void on_actionAtomformeleditor_triggered();
210 
211  //==========================================================================================================
221  void on_actionErweiterter_W_rterbucheditor_triggered();
222 
223  //==========================================================================================================
233  void on_actionNeu_triggered();
234 
235  //==========================================================================================================
245  void on_btt_OpenSignal_clicked();
246 
247  //==========================================================================================================
259  void cb_selection_changed(const QModelIndex&, const QModelIndex&);
260 
261  //==========================================================================================================
271  void tbv_selection_changed(const QModelIndex& topLeft, const QModelIndex& bottomRight);
272 
273  //==========================================================================================================
289  void recieve_result(qint32 current_iteration, qint32 max_iterations, qreal current_energy, qreal max_energy, MatrixXd residuum,
290  adaptive_atom_list adaptive_atom_res_list, fix_dict_atom_list fix_dict_atom_res_list);
291 
292  //==========================================================================================================
312  void recieve_warnings(qint32 warning_number);
313 
314  //==========================================================================================================
324  void calc_thread_finished();
325 
326  //==========================================================================================================
336  void on_actionCreate_treebased_dictionary_triggered();
337 
338  //==========================================================================================================
348  void on_dsb_from_editingFinished();
349 
350  //==========================================================================================================
360  void on_dsb_to_editingFinished();
361 
362  //==========================================================================================================
374  void on_dsb_to_valueChanged(double arg1);
375 
376  //==========================================================================================================
388  void on_dsb_from_valueChanged(double arg1);
389 
390  //==========================================================================================================
400  void on_sb_sample_count_editingFinished();
401 
402  //==========================================================================================================
414  void on_sb_sample_count_valueChanged(int arg1);
415 
416  //==========================================================================================================
426  void on_cb_all_select_clicked();
427 
428  //==========================================================================================================
438  void on_time_out();
439 
440  //==========================================================================================================
450  void on_actionSettings_triggered();
451 
452  //==========================================================================================================
462  void on_dicts_saved();
463 
464  //==========================================================================================================
474  void on_actionSpeicher_unter_triggered();
475 
476  //==========================================================================================================
486  void on_actionSpeicher_triggered();
487 
488  //==========================================================================================================
498  void on_actionExport_triggered();
499 
500  //==========================================================================================================
510  void on_dsb_sample_rate_editingFinished();
511 
512  //==========================================================================================================
524  void on_cb_Dicts_currentIndexChanged(const QString &arg1);
525 
526  //==========================================================================================================
536  void on_rb_adativMp_clicked();
537 
538  //==========================================================================================================
548  void activate_info_label();
549 
550  //==========================================================================================================
560  void recieve_save_progress(qint32 current_progress, qint32 finished);
561 
562  //==========================================================================================================
563 
564  void on_dsb_energy_valueChanged(double arg1);
565  void on_actionBeenden_triggered();
566  void on_mouse_button_release();
567 
568  void on_rb_OwnDictionary_clicked();
569 
570 signals:
571 
572  void send_input(MatrixXd send_signal, qint32 send_max_iterations, qreal send_epsilon, bool fix_phase, qint32 boost, qint32 simplex_it,
573  qreal simplex_reflection, qreal simplex_expansion, qreal simplex_contraction, qreal simplex_full_contraction, bool trial_separation);
574  void send_input_fix_dict(MatrixXd send_signal, qint32 send_max_iterations, qreal send_epsilon, qint32 boost, QString path, qreal delta);
575  void to_save(QString source_path, QString save_path, fiff_int_t start_change, fiff_int_t end_change, MatrixXd changes, MatrixXd original_signal, select_map select_channel_map, RowVectorXi picks, source_file_type file_type);
576  void kill_save_thread();
577 
578 private:
579 
580  bool is_saved;
581  bool has_warning;
582  bool is_save_white;
583  bool tbv_is_loading;
584  bool auto_change;
585  bool was_partialchecked;
586  bool read_fiff_changed;
587  bool is_white;
588  bool is_calulating;
589  fiff_int_t last_to;
590  fiff_int_t last_from;
591  qint32 last_sample_count;
592  qreal residuum_energy;
593  qreal signal_energy;
594  qreal composed_energy;
595  qint32 recieved_result_counter;
596  qint32 max_tbv_header_width;
597  QString save_path;
598  QString file_name;
599  source_file_type file_type;
600  QString last_open_path;
601  QString last_save_path;
602  QMap<qint32, bool> select_channel_map;
603  QMap<qint32, bool> select_atoms_map;
604  QList<QColor> original_colors;
605  QList<QList<GaborAtom> > _adaptive_atom_list;
606  QList<FixDictAtom> _fix_dict_atom_list;
607  MatrixXd datas;
608  RowVectorXf times_vec;
609  MatrixXd times;
610  MatrixXd original_signal_matrix;
611  MatrixXd reference_matrix;
612  MatrixXd real_residuum_matrix;
613  QTime counter_time;
614  Ui::MainWindow *ui;
615  GraphWindow *callGraphWindow;
616  AtomSumWindow *callAtomSumWindow;
617  ResiduumWindow *callResidumWindow;
618  XAxisWindow *callXAxisWindow;
619  QStandardItem* cb_item;
620  QStandardItemModel* cb_model;
621  std::vector<QStandardItem*> cb_items;
622  RowVectorXi picks;
623  FiffInfo pick_info;
624  QPalette pal;
625 
626  QTimer *_counter_timer;
627  QThread* mp_Thread;
628  AdaptiveMp *adaptive_Mp;
629  FixDictMp *fixDict_Mp ;
630 
631  //==========================================================================================================
641  void open_file();
642 
643  //==========================================================================================================
655  bool read_matlab_file(QString fileName);
656 
657  //==========================================================================================================
669  void read_matlab_file_new();
670 
671  //==========================================================================================================
684  void calc_adaptiv_mp(MatrixXd signal, truncation_criterion criterion);
685 
686  //==========================================================================================================
698  bool read_fiff_file(QString fileName);
699 
700  //==========================================================================================================
710  void read_fiff_file_new(QString file_name);
711 
712  //==========================================================================================================
724  bool read_fiff_ave(QString file_name);
725 
726  //==========================================================================================================
738  void read_fiff_ave_new();
739 
740  //==========================================================================================================
750  void fill_channel_combobox();
751 
752 
753  //==========================================================================================================
763  void save_parameters();
764 
765  //==========================================================================================================
779  void calc_fix_mp(QString path, MatrixXd signal, truncation_criterion criterion);
780 
781  //==========================================================================================================
793  QString create_display_text(FixDictAtom global_best_matching);
794 
795  //==========================================================================================================
807  void closeEvent(QCloseEvent * event);
808 
809  //==========================================================================================================
822  static bool sort_energy_adaptive(const QList<GaborAtom> atom_1, const QList<GaborAtom> atom_2);
823 
824  //==========================================================================================================
837  static bool sort_energy_fix(const FixDictAtom atom_1, const FixDictAtom atom_2);
838 
839  //==========================================================================================================
840 };
841 
842 //*************************************************************************************************************
843 // Widget to paint inputsignal
844 class GraphWindow : public QWidget
845 {
846  Q_OBJECT
847 private:
848  fiff_int_t press_pos;
849 
850 protected:
851  void paintEvent(QPaintEvent *event);
852  void mouseMoveEvent(QMouseEvent *event);
853  void mousePressEvent(QMouseEvent *event);
854  void mouseReleaseEvent(QMouseEvent *event);
855  void wheelEvent (QWheelEvent *event);
856 
857 public:
858  //==========================================================================================================
871  void paint_signal(MatrixXd signalMatrix, QSize windowSize);
872 
873 signals:
874  void read_new();
875 
876  //==========================================================================================================
877 };
878 
879 //*************************************************************************************************************
880 // Widget to paint atoms
881 class AtomSumWindow : public QWidget
882 {
883  Q_OBJECT
884 
885 protected:
886  void paintEvent(QPaintEvent *event);
887  void mouseMoveEvent(QMouseEvent *event);
888 
889 public:
890  //=========================================================================================================
905  void paint_atom_sum(MatrixXd atom_matrix, QSize windowSize, qreal signalMaximum, qreal signalNegativeMaximum);
906 
907  //==========================================================================================================
908 };
909 
910 //*************************************************************************************************************
911 // Widget to paint residuum
912 class ResiduumWindow : public QWidget
913 {
914  Q_OBJECT
915 
916  protected:
917  void paintEvent(QPaintEvent *event);
918  void mouseMoveEvent(QMouseEvent *event);
919 
920 public:
921  //=========================================================================================================
936  void paint_residuum(MatrixXd residuum_matrix, QSize windowSize, qreal maxPos, qreal maxNeg);
937 
938  //=========================================================================================================
939 };
940 
941 // Widget to paint x-axis
942 class XAxisWindow : public QWidget
943 {
944  Q_OBJECT
945 
946 protected:
947  void paintEvent(QPaintEvent *event);
948 
949 public:
950  //==========================================================================================================
963  void paint_axis(MatrixXd signalMatrix, QSize windowSize);
964 
965  //==========================================================================================================
966 };
967 
968 //save fif file class
969 class SaveFifFile : public QThread
970 {
971  Q_OBJECT
972 
973  typedef QMap<qint32, bool> select_map;
974  typedef Eigen::MatrixXd MatrixXd;
975  typedef FIFFLIB::fiff_int_t fiff_int_t;
976  typedef Eigen::RowVectorXi RowVectorXi;
977 
978 public:
979  SaveFifFile();
980 
981  ~SaveFifFile();
982 
983 private slots:
984  //==========================================================================================================
994  void save_fif_file(QString source_path, QString save_path, fiff_int_t start_change, fiff_int_t end_change, MatrixXd changes, MatrixXd original_signal, select_map select_channel_map, RowVectorXi picks, source_file_type file_type);
995 
996 signals:
997  void save_progress(qint32 current_progress, qint32 finished);
998 
999 };
1000 
1001 //*************************************************************************************************************
1002 
1003 #endif // MAINWINDOW_H
FIFF measurement file information.
Definition: fiff_info.h:96
Definition: aboutwindow.h:52
ADAPIVEMP class declaration, providing the implemetation of the Matching Pursuit Algorithm introduced...
Editorwindow class declaration which enables the generation of individual dictionaries. Gaussian atoms (with parameters scale, modulation and phase) or chirp atoms could be created and saved as part dictionaries. For using the atoms for decompostion it's necessary to build an entire dictionary from serveral (minimum one) part dictionaries.
ProcessDurationMessagebox class declaration which gives the notice that calculation might take long...
FixDictAtom used in fix dict MP Algorithm.
Definition: atom.h:123
The fixdictMP class provides functions several calculating functions to run the Matching Pursuit Algo...
Definition: fixdictmp.h:149
EnhancedEditorWindow class declaration which enables the adaption of parameters for stored formulas...
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...
DeleteMessageBox class declaration, which asked for acknowledgment to delete dictionaries or formulas...
FormulaEditor class declaration which allows the definition of individual atomformulas for the usage ...