MNE-CPP  beta 1.0
realtimeevoked.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //*************************************************************************************************************
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include "realtimeevoked.h"
42 
43 #include <time.h>
44 
45 
46 //*************************************************************************************************************
47 //=============================================================================================================
48 // QT INCLUDES
49 //=============================================================================================================
50 
51 
52 //*************************************************************************************************************
53 //=============================================================================================================
54 // USED NAMESPACES
55 //=============================================================================================================
56 
57 using namespace XMEASLIB;
58 
59 
60 //*************************************************************************************************************
61 //=============================================================================================================
62 // DEFINE MEMBER METHODS
63 //=============================================================================================================
64 
66 : NewMeasurement(QMetaType::type("RealTimeEvoked::SPtr"), parent)
67 , m_pFiffEvoked(new FiffEvoked)
68 , m_bInitialized(false)
69 {
70 
71 }
72 
73 
74 //*************************************************************************************************************
75 
77 {
78 
79 }
80 
81 
82 //*************************************************************************************************************
83 
84 void RealTimeEvoked::init(FiffInfo &p_fiffInfo)
85 {
86  QMutexLocker locker(&m_qMutex);
87  m_qListChInfo.clear();
88  m_qListChColors.clear();
89 
90  m_fiffInfo = p_fiffInfo;
91 
92  qsrand(time(NULL));
93  for(qint32 i = 0; i < p_fiffInfo.nchan; ++i)
94  {
95  m_qListChColors.append(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
96 
97  RealTimeSampleArrayChInfo initChInfo;
98  initChInfo.setChannelName(p_fiffInfo.chs[i].ch_name);
99 
100  // set channel Unit
101  initChInfo.setUnit(p_fiffInfo.chs[i].unit);
102 
103  //Treat stimulus channels different
104  if(p_fiffInfo.chs[i].kind == FIFFV_STIM_CH)
105  {
106 // initChInfo.setUnit("");
107  initChInfo.setMinValue(0);
108  initChInfo.setMaxValue(1.0e6);
109  }
110 
111  // set channel Kind
112  initChInfo.setKind(p_fiffInfo.chs[i].kind);
113 
114  // set channel coil
115  initChInfo.setCoil(p_fiffInfo.chs[i].coil_type);
116 
117  m_qListChInfo.append(initChInfo);
118  }
119 }
120 
121 
122 //*************************************************************************************************************
123 
125 {
126  QMutexLocker locker(&m_qMutex);
127  return m_pFiffEvoked;
128 }
129 
130 
131 //*************************************************************************************************************
132 
134 {
135  if(m_pFiffEvoked->data.cols() != v.data.cols())
136  m_bInitialized = false;
137 
138  //Store
139  m_qMutex.lock();
140  *m_pFiffEvoked = v;
141  m_qMutex.unlock();
142 
143  if(!m_bInitialized)
144  {
145  init(m_pFiffEvoked->info);
146 
147  m_qMutex.lock();
148  m_iPreStimSamples = 0;
149  for(qint32 i = 0; i < m_pFiffEvoked->times.size(); ++i)
150  {
151  if(m_pFiffEvoked->times[i] >= 0)
152  break;
153  else
154  ++m_iPreStimSamples;
155  }
156 
157  m_bInitialized = true;
158  m_qMutex.unlock();
159  }
160 
161  emit notify();
162 }
163 
Channel Info for RealTimeSampleArray.
FIFF measurement file information.
Definition: fiff_info.h:96
virtual FiffEvoked::SPtr & getValue()
RealTimeEvoked(QObject *parent=0)
evoked data
Definition: fiff_evoked.h:91
virtual void setValue(FiffEvoked &v)
Contains the declaration of the RealTimeEvoked class.
QSharedPointer< FiffEvoked > SPtr
Definition: fiff_evoked.h:94
void setChannelName(QString p_qStringChName)
QList< FiffChInfo > chs