MNE-CPP  0.1.9
A Framework for Electrophysiology
rtdataclient.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include "rtdataclient.h"
42 #include <fiff/fiff_file.h>
43 
44 //=============================================================================================================
45 // USED NAMESPACES
46 //=============================================================================================================
47 
48 using namespace COMMUNICATIONLIB;
49 using namespace FIFFLIB;
50 using namespace Eigen;
51 
52 //=============================================================================================================
53 // DEFINE MEMBER METHODS
54 //=============================================================================================================
55 
57 : QTcpSocket(parent)
58 , m_clientID(-1)
59 {
60  getClientId();
61 }
62 
63 //=============================================================================================================
64 
66 {
67  QTcpSocket::disconnectFromHost();
68  m_clientID = -1;
69 }
70 
71 //=============================================================================================================
72 
74 {
75  if(m_clientID == -1)
76  {
77 // sendFiffCommand(1);//MNE_RT.MNE_RT_GET_CLIENT_ID)
78 
79  FiffStream t_fiffStream(this);
80 
81  QString t_sCommand("");
82  t_fiffStream.write_rt_command(1, t_sCommand);
83 
84  this->waitForReadyRead(100);
85  // ID is send as answer
86  FiffTag::SPtr t_pTag;
87  t_fiffStream.read_tag(t_pTag);
88  if (t_pTag->kind == FIFF_MNE_RT_CLIENT_ID)
89  m_clientID = *t_pTag->toInt();
90  }
91  return m_clientID;
92 }
93 
94 //=============================================================================================================
95 
97 {
98  FiffInfo::SPtr p_pFiffInfo(new FiffInfo());
99  bool t_bReadMeasBlockStart = false;
100  bool t_bReadMeasBlockEnd = false;
101  QString col_names, row_names;
102 
103  FiffStream t_fiffStream(this);
104  //
105  // Find the start
106  //
107  FiffTag::SPtr t_pTag;
108  while(!t_bReadMeasBlockStart)
109  {
110  t_fiffStream.read_rt_tag(t_pTag);
111  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_MEAS_INFO)
112  {
113  printf("FIFF_BLOCK_START FIFFB_MEAS_INFO\n");
114  t_bReadMeasBlockStart = true;
115  }
116  }
117 
118  //
119  // Parse until the endblock
120  //
121 
122  bool dev_head_t_read = false;
123  bool ctf_head_t_read = false;
124 
125  while(!t_bReadMeasBlockEnd)
126  {
127  t_fiffStream.read_rt_tag(t_pTag);
128  //
129  // megacq parameters
130  //
131  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_DACQ_PARS)
132  {
133  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_DACQ_PARS)
134  {
135  t_fiffStream.read_rt_tag(t_pTag);
136  if(t_pTag->kind == FIFF_DACQ_PARS)
137  p_pFiffInfo->acq_pars = t_pTag->toString();
138  else if(t_pTag->kind == FIFF_DACQ_STIM)
139  p_pFiffInfo->acq_stim = t_pTag->toString();
140  }
141  }
142  //
143  // Coordinate transformations if the HPI result block was not there
144  //
145  if (t_pTag->kind == FIFF_COORD_TRANS)
146  {
147  if (!dev_head_t_read)
148  {
149  p_pFiffInfo->dev_head_t = t_pTag->toCoordTrans();
150  dev_head_t_read = true;
151  }
152  else if (!ctf_head_t_read)
153  {
154  p_pFiffInfo->ctf_head_t = t_pTag->toCoordTrans();
155  ctf_head_t_read = true;
156  }
157  }
158  //
159  // Polhemus data
160  //
161  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_ISOTRAK)
162  {
163  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_ISOTRAK)
164  {
165  t_fiffStream.read_rt_tag(t_pTag);
166 
167  if(t_pTag->kind == FIFF_DIG_POINT)
168  p_pFiffInfo->dig.append(t_pTag->toDigPoint());
169  }
170  }
171  //
172  // Projectors
173  //
174  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_PROJ)
175  {
176  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_PROJ)
177  {
178  t_fiffStream.read_rt_tag(t_pTag);
179  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_PROJ_ITEM)
180  {
181  FiffProj proj;
182  qint32 countProj = p_pFiffInfo->projs.size();
183  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_PROJ_ITEM)
184  {
185  t_fiffStream.read_rt_tag(t_pTag);
186  switch (t_pTag->kind)
187  {
188  case FIFF_NAME: // First proj -> Proj is created
189  proj = FiffProj();
190  p_pFiffInfo->projs.append(proj);
191  p_pFiffInfo->projs[countProj].desc = t_pTag->toString();
192  break;
193  case FIFF_PROJ_ITEM_KIND:
194  p_pFiffInfo->projs[countProj].kind = *(t_pTag->toInt());
195  break;
196  case FIFF_NCHAN: // First data -> FiffNamedMatrix is created
197  p_pFiffInfo->projs[countProj].data->ncol = *(t_pTag->toInt());
198  break;
199  case FIFF_PROJ_ITEM_NVEC:
200  p_pFiffInfo->projs[countProj].data->nrow = *(t_pTag->toInt());
201  break;
203  p_pFiffInfo->projs[countProj].active = *(t_pTag->toInt());
204  break;
205  case FIFF_PROJ_ITEM_CH_NAME_LIST:
206  p_pFiffInfo->projs[countProj].data->col_names = FiffStream::split_name_list(t_pTag->toString());
207  break;
208  case FIFF_PROJ_ITEM_VECTORS:
209  //ToDo: Test; Float Matrix
210  p_pFiffInfo->projs[countProj].data->data = t_pTag->toFloatMatrix().transpose().cast<double>();
211  break;
212  }
213  }
214  }
215  }
216  }
217  // Check consisty
218  for(qint32 i = 0; i < p_pFiffInfo->projs.size(); ++i)
219  {
220  if(p_pFiffInfo->projs[i].data->data.rows() != p_pFiffInfo->projs[i].data->nrow)
221  p_pFiffInfo->projs[i].data->data.transposeInPlace();
222  }
223 
224  //
225  // CTF compensation info
226  //
227  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_MNE_CTF_COMP)
228  {
229  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_MNE_CTF_COMP)
230  {
231  t_fiffStream.read_rt_tag(t_pTag);
232  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_MNE_CTF_COMP_DATA)
233  {
234  FiffCtfComp comp;
235  qint32 countComp = p_pFiffInfo->comps.size();
236  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_MNE_CTF_COMP_DATA)
237  {
238  t_fiffStream.read_rt_tag(t_pTag);
239  switch (t_pTag->kind)
240  {
241  case FIFF_MNE_CTF_COMP_KIND: //First comp -> create comp
242  comp = FiffCtfComp();
243  p_pFiffInfo->comps.append(comp);
244  p_pFiffInfo->comps[countComp].ctfkind = *(t_pTag->toInt());
245 
246  if (p_pFiffInfo->comps[countComp].ctfkind == 1194410578) //hex2dec('47314252')
247  p_pFiffInfo->comps[countComp].kind = 1;
248  else if (p_pFiffInfo->comps[countComp].ctfkind == 1194476114) //hex2dec('47324252')
249  p_pFiffInfo->comps[countComp].kind = 2;
250  else if (p_pFiffInfo->comps[countComp].ctfkind == 1194541650) //hex2dec('47334252')
251  p_pFiffInfo->comps[countComp].kind = 3;
252  else if (p_pFiffInfo->comps[countComp].ctfkind == 1194479433)
253  p_pFiffInfo->comps[countComp].kind = 4;
254  else if (p_pFiffInfo->comps[countComp].ctfkind == 1194544969)
255  p_pFiffInfo->comps[countComp].kind = 5;
256  else
257  p_pFiffInfo->comps[countComp].kind = p_pFiffInfo->comps[countComp].ctfkind;
258  break;
260  p_pFiffInfo->comps[countComp].save_calibrated = *(t_pTag->toInt());
261  break;
262  case FIFF_MNE_NROW:
263  p_pFiffInfo->comps[countComp].data->nrow = *(t_pTag->toInt());
264  break;
265  case FIFF_MNE_NCOL:
266  p_pFiffInfo->comps[countComp].data->ncol = *(t_pTag->toInt());
267  break;
268  case FIFF_MNE_ROW_NAMES:
269  row_names = t_pTag->toString();
270  if (!row_names.isEmpty())
271  p_pFiffInfo->comps[countComp].data->row_names = FiffStream::split_name_list(row_names);
272  break;
273  case FIFF_MNE_COL_NAMES:
274  col_names = t_pTag->toString();
275  if (!col_names.isEmpty())
276  p_pFiffInfo->comps[countComp].data->col_names = FiffStream::split_name_list(col_names);
277  break;
279  //ToDo: Test; Float Matrix
280  p_pFiffInfo->comps[countComp].data->data = t_pTag->toFloatMatrix().transpose().cast<double>();
281  break;
282  }
283  }
284  }
285  }
286  }
287  //
288  // Bad channels
289  //
290  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_MNE_BAD_CHANNELS)
291  {
292  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_MNE_BAD_CHANNELS)
293  {
294  t_fiffStream.read_rt_tag(t_pTag);
295  if(t_pTag->kind == FIFF_MNE_CH_NAME_LIST)
296  p_pFiffInfo->bads = FiffStream::split_name_list(t_pTag->data());
297  }
298  }
299  //
300  // General
301  //
302  switch(t_pTag->kind)
303  {
304  case FIFF_SFREQ:
305  p_pFiffInfo->sfreq = *(t_pTag->toFloat());
306  break;
307  case FIFF_LINE_FREQ:
308  p_pFiffInfo->linefreq = *(t_pTag->toFloat());
309  break;
310  case FIFF_HIGHPASS:
311  p_pFiffInfo->highpass = *(t_pTag->toFloat());
312  break;
313  case FIFF_LOWPASS:
314  p_pFiffInfo->lowpass = *(t_pTag->toFloat());
315  break;
316  case FIFF_NCHAN:
317  p_pFiffInfo->nchan = *(t_pTag->toInt());
318  break;
319  case FIFF_MEAS_DATE:
320  p_pFiffInfo->meas_date[0] = t_pTag->toInt()[0];
321  p_pFiffInfo->meas_date[1] = t_pTag->toInt()[1];
322  break;
323  case FIFF_PROJ_ID:
324  p_pFiffInfo->proj_id = *t_pTag->toInt();
325  break;
326  case FIFF_PROJ_NAME:
327  p_pFiffInfo->proj_name = t_pTag->toString();
328  break;
330  p_pFiffInfo->xplotter_layout = t_pTag->toString();
331  break;
332  case FIFF_EXPERIMENTER:
333  p_pFiffInfo->experimenter = t_pTag->toString();
334  break;
335  case FIFF_DESCRIPTION:
336  p_pFiffInfo->description = t_pTag->toString();
337  break;
338  case FIFF_GANTRY_ANGLE:
339  p_pFiffInfo->gantry_angle = *t_pTag->toInt();
340  break;
341  case FIFF_UTC_OFFSET:
342  p_pFiffInfo->utc_offset = t_pTag->toString();
343  break;
344  }
345 
346  if (t_pTag->kind == FIFF_CH_INFO)
347  p_pFiffInfo->chs.append(t_pTag->toChInfo());
348 
349  // END MEAS
350  if(t_pTag->kind == FIFF_BLOCK_END && *t_pTag->toInt() == FIFFB_MEAS_INFO)
351  {
352  printf("FIFF_BLOCK_END FIFFB_MEAS_INFO\n");
353  t_bReadMeasBlockEnd = true;
354  }
355  }
356 
357  //
358  // Add the channel information and make a list of channel names
359  // for convenience
360  //
361  for (qint32 c = 0; c < p_pFiffInfo->nchan; ++c)
362  p_pFiffInfo->ch_names << p_pFiffInfo->chs[c].ch_name;
363 
364  return p_pFiffInfo;
365 }
366 
367 //=============================================================================================================
368 
370 {
371  FiffDigitizerData::SPtr p_pDigData(new FiffDigitizerData());
372  FiffInfo::SPtr p_pFiffInfo(new FiffInfo());
373 
374  bool t_bReadMeasBlockStart = false;
375  bool t_bReadMeasBlockEnd = false;
376  QString col_names, row_names;
377 
378  FiffStream t_fiffStream(this);
379  //
380  // Find the start
381  //
382  FiffTag::SPtr t_pTag;
383  while(!t_bReadMeasBlockStart)
384  {
385  t_fiffStream.read_rt_tag(t_pTag);
386  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_MEAS_INFO)
387  {
388  printf("FIFF_BLOCK_START FIFFB_MEAS_INFO\n");
389  t_bReadMeasBlockStart = true;
390  }
391  }
392 
393  //
394  // Parse until the endblock
395  //
396 
397  bool dev_head_t_read = false;
398  bool ctf_head_t_read = false;
399 
400  while(!t_bReadMeasBlockEnd)
401  {
402  t_fiffStream.read_rt_tag(t_pTag);
403  //
404  // megacq parameters
405  //
406  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_DACQ_PARS)
407  {
408  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_DACQ_PARS)
409  {
410  t_fiffStream.read_rt_tag(t_pTag);
411  if(t_pTag->kind == FIFF_DACQ_PARS)
412  p_pFiffInfo->acq_pars = t_pTag->toString();
413  else if(t_pTag->kind == FIFF_DACQ_STIM)
414  p_pFiffInfo->acq_stim = t_pTag->toString();
415  }
416  }
417  //
418  // Coordinate transformations if the HPI result block was not there
419  //
420  if (t_pTag->kind == FIFF_COORD_TRANS)
421  {
422  if (!dev_head_t_read)
423  {
424  p_pFiffInfo->dev_head_t = t_pTag->toCoordTrans();
425  dev_head_t_read = true;
426  }
427  else if (!ctf_head_t_read)
428  {
429  p_pFiffInfo->ctf_head_t = t_pTag->toCoordTrans();
430  ctf_head_t_read = true;
431  }
432  }
433  //
434  // Polhemus data
435  //
436  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_ISOTRAK)
437  {
438  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_ISOTRAK)
439  {
440  t_fiffStream.read_rt_tag(t_pTag);
441 
442  if(t_pTag->kind == FIFF_DIG_POINT){
443  p_pFiffInfo->dig.append(t_pTag->toDigPoint());
444  p_pDigData->points.append(t_pTag->toDigPoint());
445  }
446  if(t_pTag->kind == FIFF_MNE_COORD_FRAME){
447  p_pDigData->coord_frame = *t_pTag->toInt();
448  }
449  }
450  }
451  //
452  // Projectors
453  //
454  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_PROJ)
455  {
456  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_PROJ)
457  {
458  t_fiffStream.read_rt_tag(t_pTag);
459  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_PROJ_ITEM)
460  {
461  FiffProj proj;
462  qint32 countProj = p_pFiffInfo->projs.size();
463  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_PROJ_ITEM)
464  {
465  t_fiffStream.read_rt_tag(t_pTag);
466  switch (t_pTag->kind)
467  {
468  case FIFF_NAME: // First proj -> Proj is created
469  proj = FiffProj();
470  p_pFiffInfo->projs.append(proj);
471  p_pFiffInfo->projs[countProj].desc = t_pTag->toString();
472  break;
473  case FIFF_PROJ_ITEM_KIND:
474  p_pFiffInfo->projs[countProj].kind = *(t_pTag->toInt());
475  break;
476  case FIFF_NCHAN: // First data -> FiffNamedMatrix is created
477  p_pFiffInfo->projs[countProj].data->ncol = *(t_pTag->toInt());
478  break;
479  case FIFF_PROJ_ITEM_NVEC:
480  p_pFiffInfo->projs[countProj].data->nrow = *(t_pTag->toInt());
481  break;
483  p_pFiffInfo->projs[countProj].active = *(t_pTag->toInt());
484  break;
485  case FIFF_PROJ_ITEM_CH_NAME_LIST:
486  p_pFiffInfo->projs[countProj].data->col_names = FiffStream::split_name_list(t_pTag->toString());
487  break;
488  case FIFF_PROJ_ITEM_VECTORS:
489  //ToDo: Test; Float Matrix
490  p_pFiffInfo->projs[countProj].data->data = t_pTag->toFloatMatrix().transpose().cast<double>();
491  break;
492  }
493  }
494  }
495  }
496  }
497  // Check consisty
498  for(qint32 i = 0; i < p_pFiffInfo->projs.size(); ++i)
499  {
500  if(p_pFiffInfo->projs[i].data->data.rows() != p_pFiffInfo->projs[i].data->nrow)
501  p_pFiffInfo->projs[i].data->data.transposeInPlace();
502  }
503 
504  //
505  // CTF compensation info
506  //
507  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_MNE_CTF_COMP)
508  {
509  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_MNE_CTF_COMP)
510  {
511  t_fiffStream.read_rt_tag(t_pTag);
512  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_MNE_CTF_COMP_DATA)
513  {
514  FiffCtfComp comp;
515  qint32 countComp = p_pFiffInfo->comps.size();
516  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_MNE_CTF_COMP_DATA)
517  {
518  t_fiffStream.read_rt_tag(t_pTag);
519  switch (t_pTag->kind)
520  {
521  case FIFF_MNE_CTF_COMP_KIND: //First comp -> create comp
522  comp = FiffCtfComp();
523  p_pFiffInfo->comps.append(comp);
524  p_pFiffInfo->comps[countComp].ctfkind = *(t_pTag->toInt());
525 
526  if (p_pFiffInfo->comps[countComp].ctfkind == 1194410578) //hex2dec('47314252')
527  p_pFiffInfo->comps[countComp].kind = 1;
528  else if (p_pFiffInfo->comps[countComp].ctfkind == 1194476114) //hex2dec('47324252')
529  p_pFiffInfo->comps[countComp].kind = 2;
530  else if (p_pFiffInfo->comps[countComp].ctfkind == 1194541650) //hex2dec('47334252')
531  p_pFiffInfo->comps[countComp].kind = 3;
532  else if (p_pFiffInfo->comps[countComp].ctfkind == 1194479433)
533  p_pFiffInfo->comps[countComp].kind = 4;
534  else if (p_pFiffInfo->comps[countComp].ctfkind == 1194544969)
535  p_pFiffInfo->comps[countComp].kind = 5;
536  else
537  p_pFiffInfo->comps[countComp].kind = p_pFiffInfo->comps[countComp].ctfkind;
538  break;
540  p_pFiffInfo->comps[countComp].save_calibrated = *(t_pTag->toInt());
541  break;
542  case FIFF_MNE_NROW:
543  p_pFiffInfo->comps[countComp].data->nrow = *(t_pTag->toInt());
544  break;
545  case FIFF_MNE_NCOL:
546  p_pFiffInfo->comps[countComp].data->ncol = *(t_pTag->toInt());
547  break;
548  case FIFF_MNE_ROW_NAMES:
549  row_names = t_pTag->toString();
550  if (!row_names.isEmpty())
551  p_pFiffInfo->comps[countComp].data->row_names = FiffStream::split_name_list(row_names);
552  break;
553  case FIFF_MNE_COL_NAMES:
554  col_names = t_pTag->toString();
555  if (!col_names.isEmpty())
556  p_pFiffInfo->comps[countComp].data->col_names = FiffStream::split_name_list(col_names);
557  break;
559  //ToDo: Test; Float Matrix
560  p_pFiffInfo->comps[countComp].data->data = t_pTag->toFloatMatrix().transpose().cast<double>();
561  break;
562  }
563  }
564  }
565  }
566  }
567  //
568  // Bad channels
569  //
570  if(t_pTag->kind == FIFF_BLOCK_START && *(t_pTag->toInt()) == FIFFB_MNE_BAD_CHANNELS)
571  {
572  while(t_pTag->kind != FIFF_BLOCK_END || *(t_pTag->toInt()) != FIFFB_MNE_BAD_CHANNELS)
573  {
574  t_fiffStream.read_rt_tag(t_pTag);
575  if(t_pTag->kind == FIFF_MNE_CH_NAME_LIST)
576  p_pFiffInfo->bads = FiffStream::split_name_list(t_pTag->data());
577  }
578  }
579  //
580  // General
581  //
582  switch(t_pTag->kind)
583  {
584  case FIFF_SFREQ:
585  p_pFiffInfo->sfreq = *(t_pTag->toFloat());
586  break;
587  case FIFF_LINE_FREQ:
588  p_pFiffInfo->linefreq = *(t_pTag->toFloat());
589  break;
590  case FIFF_HIGHPASS:
591  p_pFiffInfo->highpass = *(t_pTag->toFloat());
592  break;
593  case FIFF_LOWPASS:
594  p_pFiffInfo->lowpass = *(t_pTag->toFloat());
595  break;
596  case FIFF_NCHAN:
597  p_pFiffInfo->nchan = *(t_pTag->toInt());
598  break;
599  case FIFF_MEAS_DATE:
600  p_pFiffInfo->meas_date[0] = t_pTag->toInt()[0];
601  p_pFiffInfo->meas_date[1] = t_pTag->toInt()[1];
602  break;
603  case FIFF_PROJ_ID:
604  p_pFiffInfo->proj_id = *t_pTag->toInt();
605  break;
606  case FIFF_PROJ_NAME:
607  p_pFiffInfo->proj_name = t_pTag->toString();
608  break;
610  p_pFiffInfo->xplotter_layout = t_pTag->toString();
611  break;
612  case FIFF_EXPERIMENTER:
613  p_pFiffInfo->experimenter = t_pTag->toString();
614  break;
615  case FIFF_DESCRIPTION:
616  p_pFiffInfo->description = t_pTag->toString();
617  break;
618  case FIFF_GANTRY_ANGLE:
619  p_pFiffInfo->gantry_angle = *t_pTag->toInt();
620  break;
621  case FIFF_UTC_OFFSET:
622  p_pFiffInfo->utc_offset = t_pTag->toString();
623  break;
624  }
625 
626  if (t_pTag->kind == FIFF_CH_INFO)
627  p_pFiffInfo->chs.append(t_pTag->toChInfo());
628 
629  // END MEAS
630  if(t_pTag->kind == FIFF_BLOCK_END && *t_pTag->toInt() == FIFFB_MEAS_INFO)
631  {
632  printf("FIFF_BLOCK_END FIFFB_MEAS_INFO\n");
633  t_bReadMeasBlockEnd = true;
634  }
635  }
636 
637  //
638  // Add the channel information and make a list of channel names
639  // for convenience
640  //
641  for (qint32 c = 0; c < p_pFiffInfo->nchan; ++c)
642  p_pFiffInfo->ch_names << p_pFiffInfo->chs[c].ch_name;
643 
644  p_pDigData->npoint = p_pDigData->points.size();
645 
646  for (int k = 0; k < p_pDigData->npoint; k++) {
647  p_pDigData->active.append(1);
648  p_pDigData->discard.append(0);
649  }
650 
651  return MetaData(p_pFiffInfo, p_pDigData);
652 }
653 
654 //=============================================================================================================
655 
656 void RtDataClient::readRawBuffer(qint32 p_nChannels,
657  MatrixXf& data,
658  fiff_int_t& kind)
659 {
660  FiffStream t_fiffStream(this);
661  //
662  // Find the start
663  //
664  FiffTag::SPtr t_pTag;
665 
666  t_fiffStream.read_rt_tag(t_pTag);
667 
668  kind = t_pTag->kind;
669 
670  if(kind == FIFF_DATA_BUFFER)
671  {
672  qint32 nSamples = (t_pTag->size()/4)/p_nChannels;
673  data = MatrixXf(Map< MatrixXf >(t_pTag->toFloat(), p_nChannels, nSamples));
674  }
675 // else
676 // data = tag.data;
677 }
678 
679 //=============================================================================================================
680 
681 void RtDataClient::setClientAlias(const QString &p_sAlias)
682 {
683  FiffStream t_fiffStream(this);
684  t_fiffStream.write_rt_command(2, p_sAlias);//MNE_RT.MNE_RT_SET_CLIENT_ALIAS, alias);
685  this->flush();
686 }
FIFFLIB::FiffStream::read_rt_tag
bool read_rt_tag(QSharedPointer< FiffTag > &p_pTag)
Definition: fiff_stream.cpp:1643
FIFF_PROJ_NAME
#define FIFF_PROJ_NAME
Definition: fiff_file.h:576
FIFF_DATA_BUFFER
#define FIFF_DATA_BUFFER
Definition: fiff_file.h:556
FIFF_NAME
#define FIFF_NAME
Definition: fiff_file.h:485
FIFF_PROJ_ID
#define FIFF_PROJ_ID
Definition: fiff_file.h:575
FIFF_LINE_FREQ
#define FIFF_LINE_FREQ
Definition: fiff_file.h:489
FIFF_CH_INFO
#define FIFF_CH_INFO
Definition: fiff_file.h:456
FIFFLIB::FiffCtfComp
CTF software compensation data.
Definition: fiff_ctf_comp.h:73
FIFF_LOWPASS
#define FIFF_LOWPASS
Definition: fiff_file.h:472
FIFFLIB::FiffInfo
FIFF measurement file information.
Definition: fiff_info.h:84
FIFF_MNE_RT_CLIENT_ID
#define FIFF_MNE_RT_CLIENT_ID
Definition: fiff_constants.h:429
FIFFLIB::FiffProj
SSP projector data.
Definition: fiff_proj.h:75
FIFF_MNE_CTF_COMP_CALIBRATED
#define FIFF_MNE_CTF_COMP_CALIBRATED
Definition: fiff_constants.h:423
FIFF_DIG_POINT
#define FIFF_DIG_POINT
Definition: fiff_file.h:466
FIFFLIB::FiffInfo::SPtr
QSharedPointer< FiffInfo > SPtr
Definition: fiff_info.h:87
FIFF_EXPERIMENTER
#define FIFF_EXPERIMENTER
Definition: fiff_file.h:465
FIFF_MNE_CTF_COMP_DATA
#define FIFF_MNE_CTF_COMP_DATA
Definition: fiff_constants.h:422
COMMUNICATIONLIB::RtDataClient::setClientAlias
void setClientAlias(const QString &p_sAlias)
Definition: rtdataclient.cpp:681
FIFFLIB::FiffDigitizerData::SPtr
QSharedPointer< FiffDigitizerData > SPtr
Definition: fiff_digitizer_data.h:76
k
int k
Definition: fiff_tag.cpp:322
FIFF_DESCRIPTION
#define FIFF_DESCRIPTION
Definition: fiff_file.h:486
FIFF_UTC_OFFSET
#define FIFF_UTC_OFFSET
Definition: fiff_file.h:451
COMMUNICATIONLIB::MetaData
Definition: rtdataclient.h:72
FIFF_MEAS_DATE
#define FIFF_MEAS_DATE
Definition: fiff_file.h:457
FIFF_GANTRY_ANGLE
#define FIFF_GANTRY_ANGLE
Definition: fiff_file.h:555
FIFF_MNE_CTF_COMP_KIND
#define FIFF_MNE_CTF_COMP_KIND
Definition: fiff_constants.h:421
FIFF_MNE_COORD_FRAME
#define FIFF_MNE_COORD_FRAME
Definition: fiff_constants.h:331
COMMUNICATIONLIB::RtDataClient::getClientId
qint32 getClientId()
Definition: rtdataclient.cpp:73
FIFF_COORD_TRANS
#define FIFF_COORD_TRANS
Definition: fiff_file.h:475
FIFFLIB::FiffStream::read_tag
bool read_tag(QSharedPointer< FiffTag > &p_pTag, fiff_long_t pos=-1)
Definition: fiff_stream.cpp:1663
COMMUNICATIONLIB::RtDataClient::disconnectFromHost
virtual void disconnectFromHost()
Definition: rtdataclient.cpp:65
FIFFLIB::FiffTag::SPtr
QSharedPointer< FiffTag > SPtr
Definition: fiff_tag.h:152
COMMUNICATIONLIB::RtDataClient::readRawBuffer
void readRawBuffer(qint32 p_nChannels, Eigen::MatrixXf &data, FIFFLIB::fiff_int_t &kind)
Definition: rtdataclient.cpp:656
FIFF_NCHAN
#define FIFF_NCHAN
Definition: fiff_file.h:453
FIFFLIB::FiffStream
FIFF File I/O routines.
Definition: fiff_stream.h:104
FIFFLIB::FiffDigitizerData
Digitization points container and description.
Definition: fiff_digitizer_data.h:73
fiff_file.h
Header file describing the numerical values used in fif files.
FIFF_SFREQ
#define FIFF_SFREQ
Definition: fiff_file.h:454
FIFFLIB::FiffStream::write_rt_command
void write_rt_command(fiff_int_t command, const QString &data)
Definition: fiff_stream.cpp:3165
FIFF_XPLOTTER_LAYOUT
#define FIFF_XPLOTTER_LAYOUT
Definition: fiff_file.h:837
FIFF_HIGHPASS
#define FIFF_HIGHPASS
Definition: fiff_file.h:476
COMMUNICATIONLIB::RtDataClient::readMetadata
MetaData readMetadata()
Definition: rtdataclient.cpp:369
rtdataclient.h
declaration of the RtDataClient Class.
COMMUNICATIONLIB::RtDataClient::RtDataClient
RtDataClient(QObject *parent=Q_NULLPTR)
Definition: rtdataclient.cpp:56
COMMUNICATIONLIB::RtDataClient::readInfo
FIFFLIB::FiffInfo::SPtr readInfo()
Definition: rtdataclient.cpp:96
FIFF_MNE_PROJ_ITEM_ACTIVE
#define FIFF_MNE_PROJ_ITEM_ACTIVE
Definition: fiff_constants.h:407