MNE-CPP  beta 1.0
mne_epoch_data_list.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //*************************************************************************************************************
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include "mne_epoch_data_list.h"
42 
43 
44 //*************************************************************************************************************
45 //=============================================================================================================
46 // USED NAMESPACES
47 //=============================================================================================================
48 
49 using namespace MNELIB;
50 
51 
52 //*************************************************************************************************************
53 //=============================================================================================================
54 // DEFINE MEMBER METHODS
55 //=============================================================================================================
56 
58 {
59 
60 }
61 
62 
63 //*************************************************************************************************************
64 
66 {
67 // MNEEpochDataList::iterator i;
68 // for( i = this->begin(); i!=this->end(); ++i) {
69 // if (*i)
70 // delete (*i);
71 // }
72 }
73 
74 
75 //*************************************************************************************************************
76 
77 FiffEvoked MNEEpochDataList::average(FiffInfo& info, fiff_int_t first, fiff_int_t last, VectorXi sel, bool proj)
78 {
79  FiffEvoked p_evoked;
80 
81  printf("Calculate evoked... ");
82 
83  MatrixXd matAverage;
84  if(this->size() > 0)
85  matAverage = MatrixXd::Zero(this->at(0)->epoch.rows(), this->at(0)->epoch.cols());
86  else
87  {
89  return p_evoked;
90  }
91 
92  if(sel.size() > 0)
93  {
94  p_evoked.nave = sel.size();
95 
96  for(qint32 i = 0; i < sel.size(); ++i)
97  matAverage.array() += this->at(sel(i))->epoch.array();
98  }
99  else
100  {
101  p_evoked.nave = this->size();
102 
103  for(qint32 i = 0; i < this->size(); ++i)
104  matAverage.array() += this->at(i)->epoch.array();
105  }
106  matAverage.array() /= p_evoked.nave;
107 
108  printf("%d averages used [done]\n ", p_evoked.nave);
109 
110  p_evoked.setInfo(info, proj);
111 
113 
114  p_evoked.first = first;
115  p_evoked.last = last;
116 
117  RowVectorXf times = RowVectorXf(last-first+1);
118  for (qint32 k = 0; k < times.size(); ++k)
119  times[k] = ((float)(first+k)) / info.sfreq;
120  p_evoked.times = times;
121 
122  p_evoked.comment = QString::number(this->at(0)->event);
123 
124  p_evoked.data = matAverage;
125 
126  return p_evoked;
127 }
FIFF measurement file information.
Definition: fiff_info.h:96
MNEEpochDataList class declaration.
evoked data
Definition: fiff_evoked.h:91
RowVectorXf times
Definition: fiff_evoked.h:216
fiff_int_t aspect_kind
Definition: fiff_evoked.h:212
FiffEvoked average(FiffInfo &p_info, fiff_int_t first, fiff_int_t last, VectorXi sel=defaultVectorXi, bool proj=false)
#define FIFFV_ASPECT_STD_ERR
void setInfo(FiffInfo &p_info, bool proj=true)