psycho-geon.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "Component/ModelManager.H"
00039 #include "Image/Image.H"
00040 #include "Psycho/PsychoDisplay.H"
00041 #include "Psycho/EyeTrackerConfigurator.H"
00042 #include "Psycho/EyeTracker.H"
00043 #include "Psycho/PsychoOpts.H"
00044 #include "Component/EventLog.H"
00045 #include "Component/ComponentOpts.H"
00046 #include "Raster/Raster.H"
00047 #include "Util/MathFunctions.H"
00048 #include "Util/Types.H"
00049 #include <fstream>
00050
00051 using namespace std;
00052
00053
00054 extern "C" int main(const int argc, char** argv)
00055 {
00056 MYLOGVERB = LOG_INFO;
00057
00058
00059 ModelManager manager("Psycho Still");
00060
00061
00062 nub::soft_ref<PsychoDisplay> d(new PsychoDisplay(manager));
00063 manager.addSubComponent(d);
00064
00065 nub::soft_ref<EyeTrackerConfigurator>
00066 etc(new EyeTrackerConfigurator(manager));
00067 manager.addSubComponent(etc);
00068
00069 nub::soft_ref<EventLog> el(new EventLog(manager));
00070 manager.addSubComponent(el);
00071
00072
00073
00074
00075
00076
00077 if (manager.parseCommandLine(argc, argv,
00078 "<img1.ppm> ... <imgN.ppm>", 1, -1)==false){
00079 cout<<"please give the following arguments:\n Subject-Initials Run-Number Is-Adaptation(1 for adaptation 0 for control) PresentationTime(1 or 2 in secs) MaleOrFemale(M for Male, F you guessed it...) Handedness(R L)"<< endl;
00080 return(1);
00081 }
00082
00083
00084 string Sub=manager.getExtraArg(0);
00085 string Run=manager.getExtraArg(1);
00086 string IA=manager.getExtraArg(2);
00087 int IsAdapt=(int)IA[0]-48;
00088 cout<<IsAdapt<<"is adaptation"<<endl;
00089 string PT=manager.getExtraArg(3);
00090 int PresentationTime=(int)PT[0]-48;
00091 cout<<"presentation time is:"<<PresentationTime<<endl;
00092 string Gender=manager.getExtraArg(4);
00093 string Handedness=manager.getExtraArg(5);
00094
00095 string DataDir="/lab/ilab19/geonexp/stimuli/Data/";
00096 string psyFileName=DataDir + "BG_Run" + Run + "_Adapt" + IA +"_"+ Sub+"_StimONTime-"+PT+"_"+Gender+"_"+Handedness;
00097 manager.setOptionValString(&OPT_EventLogFileName, psyFileName);
00098 manager.setOptionValString(&OPT_EyeTrackerType, "ISCAN");
00099
00100 d->pushEvent(std::string("Run=") + Run + "\n" + Sub +"\nGender="+ Gender);
00101 if (IsAdapt) {d->pushEvent("Adaptation");}
00102 else {d->pushEvent("Control");};
00103
00104
00105
00106
00107 nub::soft_ref<EyeTracker> et = etc->getET();
00108 d->setEyeTracker(et);
00109 d->setEventLog(el);
00110 et->setEventLog(el);
00111
00112
00113 manager.start();
00114
00115
00116 et->calibrate(d);
00117
00118 d->clearScreen();
00119 d->displayText("<SPACE> for random play; other key for ordered");
00120
00121
00122
00123
00124
00125
00126
00127
00128 string FileName;
00129
00130 string ExpDir="/lab/ilab19/geonexp/stimuli/sequences/";
00131 string ImgDir="/lab/ilab19/geonexp/stimuli/images/";
00132
00133 if (IsAdapt){
00134 FileName=ExpDir+"GRun_"+Run+"Adapt.txt";
00135 }else{
00136 FileName=ExpDir+"GRun_"+Run+"Control.txt";
00137 };
00138
00139 cout<<FileName<<endl;
00140 const char *FileNameP=FileName.c_str();
00141
00142
00143 ifstream RunFile (FileNameP);
00144 string u;
00145
00146 int NumOfTrials, j;
00147
00148 getline(RunFile, u);
00149 cout<<u;
00150 const char *p;
00151 p=u.c_str();
00152 NumOfTrials=atoi(p);
00153 string ImageSequence[NumOfTrials];
00154
00155 for(j=0; j<NumOfTrials; j++){
00156 getline(RunFile, ImageSequence[j]);
00157 ImageSequence[j]= ImgDir +ImageSequence[j];
00158 cout <<ImageSequence[j]<<endl;
00159 }
00160
00161 RunFile.close();
00162
00163
00164 LINFO("Ready to go");
00165
00166
00167 for (int i = 0; i < NumOfTrials; i ++)
00168 {
00169
00170 d->clearScreen();
00171 LINFO("Loading '%s'...", ImageSequence[i].c_str());
00172 Image< PixRGB<byte> > image =
00173 Raster::ReadRGB(ImageSequence[i]);
00174
00175 SDL_Surface *surf = d->makeBlittableSurface(image, true);
00176
00177 LINFO("'%s' ready.", ImageSequence[i].c_str());
00178 d->displayFixation();
00179
00180
00181 d->waitForKey();
00182 d->waitNextRequestedVsync(false, true);
00183 d->pushEvent(std::string("===== Showing image: ") +
00184 ImageSequence[i] + " =====");
00185
00186
00187 et->track(true);
00188
00189
00190 d->displayFixationBlink();
00191
00192
00193 d->displaySurface(surf, -2);
00194
00195
00196 d->waitFrames(PresentationTime*30);
00197
00198
00199 SDL_FreeSurface(surf);
00200
00201
00202 d->clearScreen();
00203
00204
00205 usleep(50000);
00206 et->track(false);
00207 }
00208
00209 d->clearScreen();
00210 d->displayText("Experiment complete. Thank you!");
00211 d->waitForKey();
00212
00213
00214 manager.stop();
00215
00216
00217 return 0;
00218 }
00219
00220
00221
00222
00223
00224
00225