MNE-CPP  beta 1.0
main.cpp
1 //=============================================================================================================
36 //*************************************************************************************************************
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include <iostream>
42 #include <vector>
43 #include <math.h>
44 
45 
46 #include <utils/layoutmaker.h>
47 #include <fiff/fiff.h>
48 #include <mne/mne.h>
49 
50 
51 //*************************************************************************************************************
52 //=============================================================================================================
53 // QT INCLUDES
54 //=============================================================================================================
55 
56 #include <QtCore/QCoreApplication>
57 
58 
59 //*************************************************************************************************************
60 //=============================================================================================================
61 // USED NAMESPACES
62 //=============================================================================================================
63 
64 using namespace FIFFLIB;
65 using namespace MNELIB;
66 
67 
68 //*************************************************************************************************************
69 //=============================================================================================================
70 // MAIN
71 //=============================================================================================================
72 
73 //=============================================================================================================
82 int main(int argc, char *argv[])
83 {
84  //
85  // Please notice that this example only works in release mode.
86  // Debug mode somehow corrupts the simplex coder. ToDo: Fix this!
87  //
88  QCoreApplication a(argc, argv);
89 
90  // Get fiff info
91  QFile t_fileRaw("./MNE-sample-data/baby_meg/babymegtest1.fif");
92 
93  FiffRawData raw(t_fileRaw);
94 
95  FiffInfo fiffInfo = raw.info;
96 
97  //get 3d locations from fiff file
98  QList<QVector<double> > inputPoints;
99  QList<QVector<double> > outputPoints;
100  QStringList names;
101  QFile out("./MNE_Browse_Raw_Resources/Templates/Layouts/babymeg-mag-outer-layer.lout");
102  QFile out_file_3d("./MNE_Browse_Raw_Resources/Templates/Layouts/3D_points_all.lout");
103  QTextStream out3D(&out_file_3d);
104 
105  if (!out_file_3d.open(QIODevice::WriteOnly)) {
106  std::cout<<"could not open out_file_3d file";
107  qDebug()<<"could not open out_file_3d file";
108  }
109 
110  for(int i = 0; i<fiffInfo.ch_names.size(); i++) {
111  int kind = fiffInfo.chs.at(i).coil_type;
112 
113  if(kind == FIFFV_COIL_BABY_REF_MAG) { //FIFFV_MEG_CH FIFFV_EEG_CH FIFFV_REF_MEG_CH
114  QVector<double> temp;
115  double x = fiffInfo.chs.at(i).loc(0,0) * 100;
116  double y = fiffInfo.chs.at(i).loc(1,0) * 100;
117  double z = fiffInfo.chs.at(i).loc(2,0) * 100;
118 
119  temp.append(x);
120  temp.append(y);
121  temp.append(-z);
122  inputPoints.append(temp);
123 
124  std::cout << x << " " << y << " " << z <<std::endl;
125 
126  out3D << i+1 << " " << fiffInfo.ch_names.at(i) << " " << x << " " << y << " " << z << endl;
127  names<<fiffInfo.ch_names.at(i);
128  }
129  }
130 
131  out_file_3d.close();
132 
133  float prad = 60.0;
134  float width = 5.0;
135  float height = 4.0;
136 
137  // convert 3d points to layout
138  if(inputPoints.size()>0)
139  LayoutMaker::makeLayout(inputPoints,
140  outputPoints,
141  names,
142  out,
143  true,
144  prad,
145  width,
146  height,
147  true);
148 
149  return a.exec();
150 }
LayoutLoader class declaration.
FIFF measurement file information.
Definition: fiff_info.h:96
FIFF raw measurement data.
Definition: fiff_raw_data.h:94
QList< FiffChInfo > chs
Definition: fiff.h:98
#define FIFFV_COIL_BABY_REF_MAG
FIFF class declaration, which provides static wrapper functions to stay consistent with mne matlab to...