OpenWalnut  1.5.0dev
WEEG.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WEEG_H
26 #define WEEG_H
27 
28 #include <map>
29 #include <memory>
30 #include <string>
31 #include <utility>
32 #include <vector>
33 
34 #include "../common/WPrototyped.h"
35 #include "../common/math/linearAlgebra/WPosition.h"
36 #include "WRecording.h"
37 
38 /**
39  * An incomplete implementation to store information about electrodes of EEG data
40  */
41 class WEEGElectrodeObject // NOLINT
42 {
43 public:
44  /**
45  * Contructor taking the position of the elctrode.
46  * \param position The position of the electrode in world space.
47  */
48  explicit WEEGElectrodeObject( WPosition position );
49 
50  /**
51  * Returns the position of the electrode.
52  * \return The position of the electrode.
53  */
54  WPosition getPosition() const;
55 protected:
56 private:
57  WPosition m_position; //!< Position of the electrode in space
58 };
59 
60 typedef std::vector< double > WEEGElectrode;
61 typedef std::vector< WEEGElectrode > WEEGSegment;
62 typedef std::vector< WEEGSegment > WEEGSegmentArray;
63 
64 typedef std::vector< WEEGElectrodeObject > WEEGElectrodeLibrary;
65 typedef std::vector< std::pair< std::string, std::string > > WEEGChannelLabels;
66 /**
67  * Contains EEG recording data.
68  * \ingroup dataHandler
69  */
70 class WEEG : public WRecording // NOLINT
71 {
72 public:
73  /**
74  * Constructs a WEEG object from the give infos.
75  * \param data Array of segments
76  * \param electrodeLib Information about the electrodes
77  * \param channelLabels The names of the channels.
78  */
79  explicit WEEG( const WEEGSegmentArray& data,
80  const WEEGElectrodeLibrary& electrodeLib,
81  const WEEGChannelLabels& channelLabels );
82 
83  /**
84  * Constructor creating a quite unusable instance. Useful for prototype mechanism.
85  */
86  WEEG();
87 
88  /**
89  * Access operator for single samples.
90  * \param segment id of segment to access
91  * \param signal id of signal to access
92  * \param sample id of sample to access
93  * \return The data sample at the given location
94  */
95  const double& operator()( size_t segment, size_t signal, size_t sample ) const;
96 
97  /**
98  * Returns number of samples of a given segment.
99  * \param segmentId id of segment beeing inspected.
100  * \return Number of samples of segment with segmentId.
101  */
102  size_t getNumberOfSamples( size_t segmentId ) const;
103 
104  /**
105  * Return the number of channels this EEG has.
106  * \return Number of channels.
107  */
108  size_t getNumberOfChannels() const;
109 
110  /**
111  * Return the number of segments this EEG consists of.
112  * \return Number of segments.
113  */
114  size_t getNumberOfSegments() const;
115 
116  /**
117  * Return the label of a certain channel.
118  * \param channelId id of channel beeing inspected.
119  * \return Name of channel with channelId
120  */
121  std::string getChannelLabel( size_t channelId ) const;
122 
123  /**
124  * Return the position of the sensor for a certain channel.
125  * \param channelId id of channel beeing inspected.
126  * \return Position of sensor of channel channelId
127  */
128  WPosition getChannelPosition( size_t channelId ) const;
129 
130  /**
131  * Determines whether this dataset can be used as a texture.
132  *
133  * \return true if usable as texture.
134  */
135  virtual bool isTexture() const;
136 
137  /**
138  * Gets the name of this prototype.
139  *
140  * \return the name.
141  */
142  virtual const std::string getName() const;
143 
144  /**
145  * Gets the description for this prototype.
146  *
147  * \return the description
148  */
149  virtual const std::string getDescription() const;
150 
151  /**
152  * Returns a prototype instantiated with the true type of the deriving class.
153  *
154  * \return the prototype.
155  */
156  static std::shared_ptr< WPrototyped > getPrototype();
157 
158 protected:
159  /**
160  * The prototype as singleton.
161  */
162  static std::shared_ptr< WPrototyped > m_prototype;
163 
164 private:
165  /**
166  * Description of electrodes
167  */
168  std::map< std::string, size_t > m_electrodeDescriptions;
169 
170  /**
171  * Information about the electrodes.
172  */
173  WEEGElectrodeLibrary m_electrodeLibrary;
174 
175  /**
176  * Contains the EEG data as an arry of segements
177  * of data which consist of an array of electrodes
178  * which again consist of an array of samples over time.
179  */
180  WEEGSegmentArray m_segments;
181 
182  /**
183  * Label for each channel.
184  */
185  WEEGChannelLabels m_channelLabels;
186 
187  /**
188  * Is the channel enabled?
189  */
190  std::vector< bool > m_channelEnabled;
191 };
192 
193 inline const double& WEEG::operator()( size_t segment, size_t signal, size_t sample ) const
194 {
195  return m_segments[segment][signal][sample];
196 }
197 
198 inline size_t WEEG::getNumberOfSamples( size_t segmentId ) const
199 {
200  return m_segments[segmentId][0].size();
201 }
202 
203 inline size_t WEEG::getNumberOfChannels() const
204 {
205  return m_segments[0].size();
206 }
207 
208 inline size_t WEEG::getNumberOfSegments() const
209 {
210  return m_segments.size();
211 }
212 
213 inline std::string WEEG::getChannelLabel( size_t channelId ) const
214 {
215  // TODO(wiebel): what is done with the second string of the label?
216  return m_channelLabels[channelId].first;
217 }
218 
219 inline WPosition WEEG::getChannelPosition( size_t channelId ) const
220 {
221  return m_electrodeLibrary[channelId].getPosition();
222 }
223 
224 #endif // WEEG_H
An incomplete implementation to store information about electrodes of EEG data.
Definition: WEEG.h:42
WPosition getPosition() const
Returns the position of the electrode.
Definition: WEEG.cpp:93
WPosition m_position
Position of the electrode in space.
Definition: WEEG.h:57
WEEGElectrodeObject(WPosition position)
Contructor taking the position of the elctrode.
Definition: WEEG.cpp:88
Contains EEG recording data.
Definition: WEEG.h:71
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
Definition: WEEG.h:162
WEEGChannelLabels m_channelLabels
Label for each channel.
Definition: WEEG.h:185
std::vector< bool > m_channelEnabled
Is the channel enabled?
Definition: WEEG.h:190
WPosition getChannelPosition(size_t channelId) const
Return the position of the sensor for a certain channel.
Definition: WEEG.h:219
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
Definition: WEEG.cpp:77
WEEGElectrodeLibrary m_electrodeLibrary
Information about the electrodes.
Definition: WEEG.h:173
size_t getNumberOfChannels() const
Return the number of channels this EEG has.
Definition: WEEG.h:203
std::map< std::string, size_t > m_electrodeDescriptions
Description of electrodes.
Definition: WEEG.h:168
std::string getChannelLabel(size_t channelId) const
Return the label of a certain channel.
Definition: WEEG.h:213
virtual bool isTexture() const
Determines whether this dataset can be used as a texture.
Definition: WEEG.cpp:62
size_t getNumberOfSegments() const
Return the number of segments this EEG consists of.
Definition: WEEG.h:208
WEEG()
Constructor creating a quite unusable instance.
Definition: WEEG.cpp:56
WEEGSegmentArray m_segments
Contains the EEG data as an arry of segements of data which consist of an array of electrodes which a...
Definition: WEEG.h:180
virtual const std::string getName() const
Gets the name of this prototype.
Definition: WEEG.cpp:67
const double & operator()(size_t segment, size_t signal, size_t sample) const
Access operator for single samples.
Definition: WEEG.h:193
virtual const std::string getDescription() const
Gets the description for this prototype.
Definition: WEEG.cpp:72
size_t getNumberOfSamples(size_t segmentId) const
Returns number of samples of a given segment.
Definition: WEEG.h:198
This only is a 3d double vector.
Base class for all recorded data and results with events and sensor positions.
Definition: WRecording.h:41