CEBL  2.1
FileDataStreamConfig.cpp
Go to the documentation of this file.
1 
7 #include "../CEBLModel.hpp"
9 #include "EEGTrainingData.hpp"
10 #include "DataIO.hpp"
11 #include <fstream>
12 #include <sstream>
13 using namespace std;
14 
15 //----------------------------------------------------------------------
16 // Constructors / Destructors
17 
19 {
20  this->model = model;
21  this->filename = "None";
22  this->ready = false;
23  this->sample_rate = 256;
24  this->num_samples = 0;
25  this->num_channels = 0;
26  this->num_classes = 0;
27  this->num_sequences = 0;
28 }
29 
31 
32 
33 
34 //----------------------------------------------------------------------
35 // Getting Operations
36 
38 {
39  return this->ready;
40 }
41 
42 //----------------------------------------------------------------------
43 // Setting Operations
44 
45 void FileDataStreamConfig::openFile(string filename)
46 {
47  this->ready = false;
48  this->filename = filename;
49  EEGData temp;
50 
51  //decide how to load data
52  if(filename.find(".tar.bz2") > 0)
53  {
54  this->training_data = DataIO::loadTrainingDataFromFile(filename);
55  this->num_classes = this->training_data.numClasses();
56  this->num_sequences = this->training_data.numSequences();
57  temp = EEGData(this->training_data.collapse());
58  }
59  else
60  {
61  this->num_classes = 0;
62  this->num_sequences = 0;
63  temp.loadFromFile(filename);
64  }
65 
66  this->num_samples = temp.numSamples();
67  this->num_channels = temp.numChannels();
68 
69  if(num_samples < sample_rate || num_channels < 2)
70  throw DataException("Not enough data found in file.");
71 
72  this->data = temp;
73  this->ready = true;
74 }
75 
77 {
78  this->sample_rate = sample_rate;
79 }