CEBL  2.1
EEGData.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 
30 #ifndef EEGDATA_H
31 #define EEGDATA_H
32 
33 #include "Serialization.hpp"
34 #include <boost/numeric/ublas/matrix.hpp>
35 #include <boost/numeric/ublas/vector.hpp>
36 #include <iostream>
37 using namespace std;
38 
44 
45 //define ublas namespace to be shorter
46 namespace ublas = boost::numeric::ublas;
47 
48 class EEGData
49 {
50  private:
51  //----------------------------------------
52  //serialization
53  friend class boost::serialization::access;
54  template<class Archive>
55  void serialize(Archive & ar, const unsigned int version)
56  {
57  ar & data;
58  }
59 
61  ublas::matrix<double> data;
62 
63  public:
64  EEGData();
65  EEGData(const ublas::matrix<double>&);
66  EEGData(const EEGData &data);
67  ~EEGData();
68 
70  void append(const EEGData &data);
71 
73  void clear();
74 
75  //Operators
76  operator ublas::matrix<double>() const { return data; };
77  EEGData& operator=(const EEGData& data);
78 
79  ublas::matrix<double> & getMatrix() { return data; }
80 
81  //determine size of data matrix
83  int size1() const { return data.size1(); }
85  int size2() const { return data.size2(); }
86 
88  int nrow() const { return size1(); }
89  int ncol() const { return size2(); }
90 
91 
93  int numSamples() const { return data.size2(); }
95  int numChannels() const { return data.size1(); }
96 
97  //File Output
98  void saveToFile(const char *filename, std::ios_base::openmode mode = std::ios_base::app) const;
99  void saveToFile(std::ofstream &ofs) const;
100 
101  //File Input
102  void loadFromFile(const std::string str) { loadFromFile(str.c_str()); };
103  void loadFromFile(const char *filename);
104  void loadFromFile(std::ifstream &ifs);
105 
106  //Selection Methods
107  void splitData(EEGData *, EEGData *, int, DataSelectionMethod) const;
108 
109  //printing
110  void print();
111 
112 };
113 //non-member operators
114 EEGData operator+(const EEGData &, const EEGData &);
115 std::ostream& operator<<(std::ostream &os, const EEGData &d);
116 
117 #endif