CEBL  2.1
PassBand.hpp
Go to the documentation of this file.
1 /*
2 * CEBL : CSU EEG Brain-Computer Interface Lab
3 *
4 * Author: Jeshua Bratman - jeshuabratman@gmail.com
5 *
6 * This file is part of CEBL.
7 *
8 * CEBL is free software; you can redistribute it and/or modify it.
9 * We only ask that if you use our code that you cite the source in
10 * your project or publication.
11 *
12 * EEG Group (www.cs.colostate.edu/eeg)
13 * Department of Computer Science
14 * Colorado State University
15 *
16 */
17 
18 #ifndef PASSBAND_H
19 #define PASSBAND_H
20 //relative to cebl source dir
21 #include "features/Feature.hpp"
22 #include "PassBandFunctions.hpp"
23 
24 #include <map>
25 using namespace std;
26 
27 
28 namespace CEBL
29 {
30 
32  {
33  GtkWidget *spin_low,*spin_high;
34  };
35 
36  struct ConfigRow
37  {
38  int low, high;
39  };
40 
41 
42  class PassBand : public Feature
43  {
44  private:
45  //widgets
46  GtkWidget *gui_container,
47  *spin_bands,
48  *table_bands,
49  *check_trained,
50  *check_variance,
51  *spin_gamma;
52 
53 
54  vector<PassBandGUIRow> widget_rows;
55  vector<ConfigRow> config_rows;
56  map<int, map<int, map<int, ublas::matrix<double> > > > configurations;
57  map<int, ublas::matrix<double> > filters;
58  //means and vars are vectors for each num band, for each feature
59  vector< vector<double> > means;
60  vector< vector<double> > vars;
61  vector<FilterState> states;
62  int num_bands;
63  bool trained;
64  double gamma;
65 
66  //set up gui
67  void InitGUI();
68 
69  //callbacks
70  void ChangeNumBands(int force_bands=-1);
71  void ChangeOptions(int pos = 0);
72 
73  static void CB_ChangeNumBands(GtkWidget *spin, gpointer data);
74  static void CB_ChangeOptionsLow(GtkWidget *spin, gpointer data);
75  static void CB_ChangeOptionsHigh(GtkWidget *spin, gpointer data);
76  static void CB_ChangeGamma(GtkWidget *spin, gpointer data);
77 
78  //saving and loading
79  map<string, SerializedObject> save() const;
80  void load(map<string, SerializedObject> objects);
81 
82  public:
83  //default constructor - initializes members
84  PassBand();
85 
87  ublas::matrix<double> use(const ublas::matrix<double> &);
88 
90  bool needs_training() { return true; }
91  void train();
92  bool isTrained() { return trained; }
93 
94 
95 
96  };
97 
98 }//end namespace
99 
100 
101 #endif