AwCore
AnyWave core library
AwChannel.h
1 //
3 // Université d’Aix Marseille (AMU) -
4 // Institut National de la Santé et de la Recherche Médicale (INSERM)
5 // Copyright © 2013 AMU, INSERM
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation; either
10 // version 3 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //
21 //
22 //
23 // Author: Bruno Colombet – Laboratoire UMR INS INSERM 1106 - Bruno.Colombet@univ-amu.fr
24 //
26 #ifndef AWCHANNEL_H
27 #define AWCHANNEL_H
28 #include <QStringList>
29 #include <QUuid>
30 #include <QVariant>
31 #include <QSemaphore>
32 #include <QVector>
33 class AwProcess;
34 
50 class AwChannel
51 {
52 public:
53  enum ChannelType {EEG = 0, SEEG = 1, MEG = 2, EMG = 3, ECG = 4, Reference = 5, Trigger = 6, Other = 7};
54  enum SourceType { Real, Virtual };
55 
57  AwChannel();
59  AwChannel(AwChannel *chan);
61  virtual ~AwChannel();
62 
64  virtual AwChannel* duplicate();
65 
67  static QStringList types();
68 
70  float *newData(int length);
72  void clearData();
73 
75  inline SourceType sourceType() { return m_sourceType; }
77  inline float gain() { return m_gain; }
79  inline float samplingRate() { return m_samplingRate; }
81  inline QString& name() {return m_name; }
82 
83  inline int ID() { return m_ID; }
84 
86  inline int dataSize() { return m_dataSize; }
87 
89  inline float *data() { return m_data; }
90 
92  inline QString& unit() { return m_unit; }
93 
95  inline double x() { return m_x; }
97  inline double y() { return m_y; }
99  inline double z() { return m_z; }
100 
102  inline double ox() { return m_ox; }
104  inline double oy() { return m_oy; }
106  inline double oz() { return m_oz; }
107 
109  void xyz(double *x, double *y, double *z);
110 
112  void orientationXyz(double *ox, double *oy, double *oz);
113 
115  inline bool isBad() { return m_bad; }
116 
118  inline int type() { return m_type; }
119 
121  inline QString& referenceName() { return m_referenceName; }
122 
125  inline QList<AwChannel *>& references() { return m_references; }
126 
128  inline bool isVisible() { return m_visible; }
129 
131  inline QString& color() { return m_color; }
132 
134  inline float highFilter() { return m_highFilter; }
135 
137  inline float notch() { return m_notch; }
138 
140  inline bool hasReferences() { return !m_referenceName.isEmpty(); }
141 
143  inline float lowFilter() { return m_lowFilter; }
144 
145  inline AwChannel *parent() { return m_parent; }
146 
147  inline QString& displayPluginName() { return m_registeredDisplayPlugin; }
148 
150  inline bool hasCoordinates() { return m_hasCoordinates; }
151 
153  inline bool isEEG() { return m_type == AwChannel::EEG; }
155  inline bool isMEG() { return m_type == AwChannel::MEG; }
157  inline bool isReference() { return m_type == AwChannel::Reference; }
159  inline bool isECG() { return m_type == AwChannel::ECG; }
161  inline bool isTrigger() { return m_type == AwChannel::Trigger; }
163  inline bool isOther() { return m_type == AwChannel::Other; }
165  inline bool isEMG() { return m_type == AwChannel::EMG; }
167  inline bool isSEEG() { return m_type == AwChannel::SEEG; }
169  inline bool isVirtual() { return m_sourceType == AwChannel::Virtual; }
170 
171  bool isDataReady();
172 
173  inline bool isSelected() { return m_isSelected; }
174 
175  inline QVariantList& customData() { return m_customData; }
176 
177  // SET
178 
179  void addRef(AwChannel *ref);
180  void clearRefChannels();
181  void clearRefName();
182  void setParent(AwChannel *parent);
183 
188  void setDisplayPluginName(const QString& name);
189 
191  void setUnit(const char *u);
193  void setUnit(const QString& u);
194 
196  void setGain(float factor);
198  void setSamplingRate(float rate);
200  void setName(const QString& Name);
202  void setColor(const QString& col);
203 
204  void setID(quint32 id);
205 
207  void setXYZ(double x, double y, double z);
209  void setOrientationXYZ(double ox, double oy, double oz);
211  void setBad(bool flag);
213  void setType(int t);
214 
215  void setVisible(bool flag);
216 
218  void setReferenceName(const QString& ref);
219 
221  void setHighFilter(float val);
223  void setLowFilter(float val);
224 
225  void setNotch(float val);
226  void setCustomData(const QVariantList& data) { m_customData = data; }
227 
229  void setSourceType(SourceType stype);
230 
231  void addProcess(AwProcess *process);
232 
235  static int stringToType(const QString& s);
236 
238  static QString typeToString(int t);
239 
241  void setDataReady(bool flag = true);
242 
244  void setSelected(bool flag);
245 
246 protected:
247  quint32 m_ID;
248  bool m_dataReady;
249  float m_gain;
250  float m_samplingRate;
251  QString m_name;
252  float *m_data;
253 
254  int m_dataSize;
255  QString m_unit; // Unité du signal (µV, fT, etc.)
256  // xyz coordinates
257  double m_x;
258  double m_y;
259  double m_z;
260  // orientation vector
261  double m_ox;
262  double m_oy;
263  double m_oz;
264 
265  bool m_bad;
266  bool m_isSelected;
267  int m_type;
268  bool m_hasCoordinates;
269  SourceType m_sourceType;
270  QString m_registeredDisplayPlugin; // Optional name of a Display Plugin that will display the channel.
271  // If empty, AnyWave will use the default plugin to render signals.
272  AwChannel *m_parent;
273  QString m_referenceName;
274  QList<AwChannel *> m_references;
275  bool m_visible;
276  QString m_color;
277  float m_lowFilter;
278  float m_highFilter;
279  float m_notch;
280  QList<AwProcess *> m_processes; // list of process that might be linked to the channel
281  QVariantList m_customData; // Custom data associated with the channel.
282 };
283 
284 typedef QList<AwChannel *> AwChannelList;
285 Q_DECLARE_METATYPE(AwChannelList)
286 
288 {
289 public:
290  AwVirtualChannel() : AwChannel() { m_sourceType = AwChannel::Virtual; /*m_isDataAvailable = false;*/ }
292  AwVirtualChannel(AwChannel *chan) : AwChannel(chan) { m_sourceType = AwChannel::Virtual; }
294  virtual ~AwVirtualChannel();
295  AwChannelList& connectedChannels() { return m_connectedChannels; }
296  void connectChannels(const AwChannelList& channels);
297 
298  // overide setDataReady from AwChannel
299  void setDataReady(bool f = true) { m_dataReady = f; update(); }
300 
301  virtual void compute() {} // overide this method to compute data for the channel. Default implementation does nothing.
302  virtual void update() {} // overide this method to update the data content for the channel. Called each time data are set to the channel.
303  virtual AwVirtualChannel *duplicate() { return new AwVirtualChannel(this); }
304 protected:
305  AwChannelList m_connectedChannels; // may be empty
306 };
307 
308 #endif
bool isOther()
Definition: AwChannel.h:163
float * data()
Definition: AwChannel.h:89
void xyz(double *x, double *y, double *z)
Definition: AwChannel.cpp:108
void setOrientationXYZ(double ox, double oy, double oz)
Definition: AwChannel.cpp:223
void setDataReady(bool flag=true)
Definition: AwChannel.cpp:279
void setBad(bool flag)
Definition: AwChannel.cpp:230
bool isVirtual()
Definition: AwChannel.h:169
float notch()
Definition: AwChannel.h:137
AwChannel()
Definition: AwChannel.cpp:39
bool isVisible()
Definition: AwChannel.h:128
bool isBad()
Definition: AwChannel.h:115
void setSamplingRate(float rate)
Definition: AwChannel.cpp:203
int type()
Definition: AwChannel.h:118
static QStringList types()
Definition: AwChannel.cpp:29
bool isReference()
Definition: AwChannel.h:157
double y()
Definition: AwChannel.h:97
void setDisplayPluginName(const QString &name)
Definition: AwChannel.cpp:183
void setName(const QString &Name)
Definition: AwChannel.cpp:208
bool hasReferences()
Definition: AwChannel.h:140
double x()
Definition: AwChannel.h:95
bool isECG()
Definition: AwChannel.h:159
void setUnit(const char *u)
Definition: AwChannel.cpp:188
void setReferenceName(const QString &ref)
Definition: AwChannel.cpp:240
void clearData()
Definition: AwChannel.cpp:269
float lowFilter()
Definition: AwChannel.h:143
double oy()
Definition: AwChannel.h:104
static int stringToType(const QString &s)
Definition: AwChannel.cpp:290
void setXYZ(double x, double y, double z)
Definition: AwChannel.cpp:124
SourceType sourceType()
Definition: AwChannel.h:75
virtual AwChannel * duplicate()
Definition: AwChannel.cpp:95
void setLowFilter(float val)
Definition: AwChannel.cpp:252
AwVirtualChannel(AwChannel *chan)
Definition: AwChannel.h:292
static QString typeToString(int t)
Definition: AwChannel.cpp:311
Definition: AwChannel.h:287
void setType(int t)
Changing the type will clear the reference channel.
Definition: AwChannel.cpp:132
double ox()
Definition: AwChannel.h:102
bool isEMG()
Definition: AwChannel.h:165
float gain()
Definition: AwChannel.h:77
void setColor(const QString &col)
Definition: AwChannel.cpp:213
QString & color()
Definition: AwChannel.h:131
virtual AwVirtualChannel * duplicate()
Definition: AwChannel.h:303
QString & name()
Definition: AwChannel.h:81
bool isEEG()
Definition: AwChannel.h:153
void setSourceType(SourceType stype)
Definition: AwChannel.cpp:259
double oz()
Definition: AwChannel.h:106
bool isMEG()
Definition: AwChannel.h:155
double z()
Definition: AwChannel.h:99
void orientationXyz(double *ox, double *oy, double *oz)
Definition: AwChannel.cpp:115
bool isSEEG()
Definition: AwChannel.h:167
void setGain(float factor)
Definition: AwChannel.cpp:198
This class defines the AwChannel object.
Definition: AwChannel.h:50
float highFilter()
Definition: AwChannel.h:134
void setSelected(bool flag)
Definition: AwChannel.cpp:264
bool hasCoordinates()
Definition: AwChannel.h:150
QList< AwChannel * > & references()
Definition: AwChannel.h:125
float samplingRate()
Definition: AwChannel.h:79
QString & referenceName()
Definition: AwChannel.h:121
int dataSize()
Definition: AwChannel.h:86
bool isTrigger()
Definition: AwChannel.h:161
virtual ~AwChannel()
Definition: AwChannel.cpp:337
void setHighFilter(float val)
Definition: AwChannel.cpp:245
QString & unit()
Definition: AwChannel.h:92
float * newData(int length)
Definition: AwChannel.cpp:147