CEBL  2.1
EEGTrainingData.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 
25 #ifndef EEGTRAININGDATA_H
26 #define EEGTRAININGDATA_H
27 
28 #include "EEGData.hpp"
29 #include "Serialization.hpp"
30 
31 #include <string>
32 #include <map>
33 #include <vector>
34 #include <string>
35 
36 using std::vector;
37 using std::string;
38 using std::map;
39 
40 
42 {
43  private:
44 
45  //----------------------------------------
46  //serialization
48  template<class Archive>
49  void serialize(Archive & ar, const unsigned int version)
50  {
51  ar & data;
52  ar & class_vector;
53  ar & sequence_order;
54  ar & filtered;
55  ar & class_labels;
56  ar & channel_names;
57  }
58 
59  //----------------------------------------
60  std::vector< std::vector <EEGData> > data;
61  ublas::vector<int> class_vector;
62 
64  std::vector<int> sequence_order;
65 
66  //info about data
67  std::vector<string> class_labels;
68  std::vector<string> channel_names;
69  bool filtered;
70 
71  public:
75  void set(unsigned int cls, unsigned int seq, EEGData &data);
76 
78  void append(unsigned int cls, unsigned int seq, EEGData &data);
79 
81  EEGData& get(unsigned int cls, unsigned int seq);
82 
84  const EEGData & getConst(unsigned int cls, unsigned int seq) const;
85 
87  void reserve(unsigned int cls, unsigned int seq);
88 
90  void clear() { data.clear(); }
91 
93  ublas::matrix<double> collapse() const;
94 
96  ublas::vector<int> getClassVector() const;
97 
99  std::vector<int> getSequenceOrder() const;
100 
102  ublas::vector<int> getTargets() const;
103 
105  int numClasses() const;
106 
108  int numSequences() const;
109 
111  int numSequences(unsigned int cls) const;
112 
114  int samplesInClass(unsigned int cls) const;
115 
117  int numSamples(unsigned int cls) const { return samplesInClass(cls); }
118 
120  int numSamples(unsigned int cls, unsigned int sequence) const;
121 
123  int numSamples() const;
124 
126  int numFeatures() const;
127 
129  std::vector<string> getClassLabels() const;
130 
132  std::vector<string> getChannelNames() const;
133 
135  bool getFiltered() const;
136 
138  void setClassLabels(std::vector<string>);
139 
141  void setChannelNames(std::vector<string>);
142 
144  void setFiltered(bool filtered);
145 
147  void setSequenceOrder(std::vector<int> ord) { sequence_order = ord; }
148 
149 
150 
151 };
152 
153 std::ostream& operator<<(std::ostream &os, const EEGTrainingData &d);
154 
155 
156 
157 
158 #endif