-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
197 lines (147 loc) · 4.08 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* Copyright 2018 Wenbin Yang <[email protected]>
* This file is part of BLITZ (Behavioral Learning In The Zebrafish),
* which is adapted from MindControl (Andrew Leifer et al <[email protected]>
* Leifer, A.M., Fang-Yen, C., Gershow, M., Alkema, M., and Samuel A. D.T.,
* "Optogenetic manipulation of neural activity with high spatial resolution in
* freely moving Caenorhabditis elegans," Nature Methods, Submitted (2010).
*
* BLITZ is a free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the license, or
* (at your option) any later version.
*
* Filename: main.cpp
* Abstract: this file contains all functions used in constructing final
* behavioral learning experiment in zebrafish
*
* Current Version: 2.0
* Author: Wenbin Yang <[email protected]>
* Modified on: Apr. 28, 2018
* Replaced Version: 1.1
* Author: Wenbin Yang <[email protected]>
* Created on: Jan. 1, 2018
*/
// Include 3rd party libraries
#include "3rdPartyLibs/Utilities/Timer.h"
// Include user-defined libraries
#include "MyLibs/experiment.h"
#include "MyLibs/talk2screen.h"
#include "MyLibs/talk2camera.h"
// Include standard libraries
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
string CS_Pattern = "redBlackCheckerboard";
ExperimentData exp(CS_Pattern);
if (!exp.initialize())
{
cout << "Experiment Initialization Failed." << endl;
exit(0);
}
else {
cout << "Experiment initialized." << endl;
}
exp.runOLexp();
/*Test screen function*/
/* Area1 Area2 Area3
(0.233f, 0.300f) (0.800f, -0.850f) (-0.740f, -0.850f)
width, height: all (0.28f, 1.40f)
const char imgName[] = "Images/redCheckerboard.jpg";
float allAreaPos[3][2] = { {0.233f, 0.300f}, {0.800f, -0.850f}, {-0.740f, -0.850f} };
Timer expTimer;
expTimer.start();
ScreenData screen;
screen.initGLFWenvironment();
screen.loadTextureIntoBuffers(imgName);
float* areaPos = allAreaPos[0];
AreaData area1(areaPos,2);
const int delimYarr[] = { 900,900,1000,1000 };
area1.initialize(delimYarr);
screen.allAreas.push_back(area1);
while (1)
{
int timeInSec = expTimer.getElapsedTimeInSec();
cout << "Time (s) : " << timeInSec << endl;
if (timeInSec % 10 == 0)
screen.allAreas[0].allPatches[0].pIdx = !screen.allAreas[0].allPatches[0].pIdx;
screen.allAreas[0].allPatches[0].updatePattern();
screen.renderTexture();
}
*/
/* Test OL Procedure
ExperimentData exp;
const char imgName[] = "Images/redCheckerBoard.jpg";
try {
exp.initialize(imgName);
exp.prepareBgImg();
exp.runOLexp();
}
catch (const GenericException &e)
{
// Error handling
cerr << "An exception occurred." << endl
<< e.GetDescription() << endl;
}
*/
/*
int testVar = 10;
vector<int> headVec(4, 0);
headVec[1] = 1;
headVec[2] = 2;
headVec[3] = 3;
fs << "Frame" << "[";
string vName; // variable name
for (int i = 0; i < headVec.size(); i++)
{
vName = "Head" + to_string(i);
fs << "{:" << vName << headVec[i] << "}";
}
fs << "]";
*/
//yaml << "Frames" << "[";
//writeOutVarInline<int>(fs, testVar, "testVar");
/* Timer.start can be used as reset
Timer expTimer;
expTimer.start();
while (1)
{
int timeInSec = expTimer.getElapsedTimeInSec();
cout << "Time (s): " << timeInSec << endl;
if (timeInSec > 10)
expTimer.start();
}
*/
/* Test camera function
Timer expTimer;
expTimer.start();
CameraData cams;
cams.initialize();
while (cams.grabPylonImg())
{
cout << "Time (s) : " << expTimer.getElapsedTimeInSec() << endl;
#ifdef PYLON_WIN_BUILD
// Display the grabbed image.
Pylon::DisplayImage(1, cams.ptrGrabResult);
#endif
}
*/
// Enquire how many cameras to use
// and enter filenames respectively
/*
try{ // Handle with missing frames of Pylon cameras
ExperimentData myExp;
myExp.initialize();
myExp.prepareBgImg();
myExp.runOLexp(); // run operant learning experiment
}
catch (const GenericException &e)
{
// Error handling
cerr << "An exception occurred." << endl
<< e.GetDescription() << endl;
}
*/
}