00001 #include "drawShape.H" 00002 #include "defineShape.H" 00003 00004 int target_Pt3[2] = {4,6}; 00005 int target_Pt2[4] = {1,2,3,5}; 00006 int BO_L[2][2] = {{1,3},{0,2}}; 00007 int BO_Sq[2][2] = {{0,2},{1,3}}; 00008 int BO_Pt2[2][2] = {{0,2},{1,3}}; 00009 int BO_Shapes[2][12] = {{0,1,2,3,7,8,9,10,15,16,19,20}, 00010 {4,5,6,11,12,13,14,17,18,21,22,23}}; 00011 int target_dir; 00012 00013 int msleep(int ms) 00014 { 00015 struct timeval timeout; 00016 00017 timeout.tv_sec = ms / 1000; 00018 timeout.tv_usec = (ms % 1000) * 1000; 00019 if (select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, &timeout) < 0) { 00020 perror("usleep"); 00021 return -1; 00022 } 00023 return 0; 00024 } 00025 00026 int search(int tar) 00027 { 00028 int i,j; 00029 00030 for(i=0;i<2;i++){ 00031 for(j=0;j<12;j++){ 00032 if(tar == BO_Shapes[i][j]){ 00033 return(i); 00034 } 00035 } 00036 } 00037 printf("Error\n tar = %d\n", tar); 00038 exit(0); 00039 } 00040 00041 int selection(int tar) 00042 { 00043 if(tar >= 0 && tar < 4)return 0; //target is Square 00044 else if((tar >=4 && tar < 8) || (tar >= 16 && tar < 19))return 1; //target is New 00045 else return 2; //target is L shape 00046 } 00047 00048 void shuffle (int array[],int count) 00049 { 00050 int i,tmp,change,array2[400]; 00051 00052 srand((unsigned int)time(NULL)); 00053 00054 for (i = 0; i < count; ++i) 00055 array2[i]=array[i]; 00056 00057 for (i = 0; i < count; ++i) { 00058 change = rand() % count; 00059 tmp = array2[i]; 00060 array2[i] = array2[change]; 00061 array2[change] = tmp; 00062 00063 } 00064 00065 for( i = 0; i < count; i++ ){ 00066 array[i]=array2[i]; 00067 } 00068 } 00069 00070 void fragStimuliShape(int stimuli[],int target_stim,int target_Shape) 00071 { 00072 if(target_stim >= 0 && target_stim < 4){ //target is Square1 00073 target_dir = 0; 00074 stimuli[0]=3; 00075 stimuli[1]=3; 00076 stimuli[2]=3; 00077 stimuli[3]=3; 00078 stimuli[12]=3; 00079 stimuli[13]=3; 00080 stimuli[14]=3; 00081 stimuli[15]=3; 00082 }//else if(target_stim >=4 && target_stim < 8){ //target is Square2 00083 //for(i=4;i<7;i++)stimuli[i][target_type]=3; 00084 else if(target_stim==4){//target is new 00085 target_dir=1; 00086 stimuli[9]=3; 00087 stimuli[17]=3; 00088 } 00089 else if(target_stim == 5){//target is new 00090 target_dir = 0; 00091 stimuli[8]=3; 00092 stimuli[16]=3; 00093 }else if(target_stim == 6){//target is new 00094 target_dir = 3; 00095 stimuli[11]=3; 00096 stimuli[19]=3; 00097 } 00098 else if(target_stim == 7){//target is new 00099 target_dir = 2; 00100 stimuli[10]=3; 00101 stimuli[18]=3; 00102 } 00103 else if(target_stim == 8){//target is L 00104 target_dir = 0; 00105 stimuli[1]=3; 00106 stimuli[13]=3; 00107 stimuli[16]=3; 00108 } 00109 else if(target_stim == 9){//target is L 00110 target_dir = 1; 00111 stimuli[0]=3; 00112 stimuli[12]=3; 00113 stimuli[17]=3; 00114 } 00115 else if(target_stim == 10){//target is L 00116 target_dir = 2; 00117 stimuli[3]=3; 00118 stimuli[5]=3; 00119 stimuli[18]=3; 00120 } 00121 else if(target_stim == 11){//target is L 00122 target_dir = 3; 00123 stimuli[2]=3; 00124 stimuli[14]=3; 00125 stimuli[19]=3; 00126 }else if(target_stim == 12){//target is L 00127 target_dir = 1; 00128 stimuli[0]=3; 00129 stimuli[9]=3; 00130 stimuli[17]=3; 00131 }else if(target_stim == 13){//target is L 00132 target_dir = 0; 00133 stimuli[1]=3; 00134 stimuli[8]=3; 00135 stimuli[16]=3; 00136 }else if(target_stim == 14){//target is L 00137 target_dir = 3; 00138 stimuli[2]=3; 00139 stimuli[14]=3; 00140 stimuli[11]=3; 00141 }else if(target_stim == 15){//target is L 00142 target_dir = 2; 00143 stimuli[3]=3; 00144 stimuli[10]=3; 00145 stimuli[18]=3; 00146 }else if(target_stim == 16){//target is new 00147 target_dir = 0; 00148 stimuli[5]=3; 00149 stimuli[8]=3; 00150 }else if(target_stim == 17){//target is new 00151 target_dir = 1; 00152 stimuli[4]=3; 00153 stimuli[9]=3; 00154 }else if(target_stim == 18){//target is new 00155 target_dir = 2; 00156 stimuli[7]=3; 00157 stimuli[10]=3; 00158 }else if(target_stim == 19){//target is new 00159 target_dir = 3; 00160 stimuli[6]=3; 00161 stimuli[11]=3; 00162 } 00163 stimuli[target_stim] = 1; 00164 } 00165 00166 void SelectStimuli(int stimuli, float Lcolor, float x, float y, float times) 00167 { 00168 float Newcolor; 00169 00170 if(Lcolor ==1.0) Newcolor = 0.0; 00171 else Newcolor = 1.0; 00172 00173 switch (stimuli){ 00174 case 0: //Sq1. based on BO 00175 { 00176 draw_dist(1,x,y,Newcolor,times); 00177 }break; //end of "case 0:" 00178 case 1: //Sq1. based on BO right 00179 { 00180 draw_dist(0,x,y,Newcolor,times); 00181 }break; //end of "case 1:" 00182 case 2: //Sq1. based on BO right 00183 { 00184 draw_dist(3,x,y,Newcolor,times); 00185 }break; //end of "case 2:" 00186 case 3: //Sq1. based on BO right 00187 { 00188 draw_dist(2,x,y,Newcolor,times); 00189 }break; //end of "case 3:" 00190 case 4: 00191 { //New. based on BO left 00192 draw_L1(1,x,y,Newcolor,times); 00193 draw_New1(1,x,y,Lcolor,times); 00194 }break; //end of "case 4:" 00195 case 5:// New. based on BO left 00196 { 00197 draw_L1(0,x,y,Newcolor,times); 00198 draw_New1(0,x,y,Lcolor,times); 00199 }break; //end of "case 5:" 00200 case 6:// New. based on BO left 00201 { 00202 draw_L1(3,x,y,Newcolor,times); 00203 draw_New1(3,x,y,Lcolor,times); 00204 }break; //end of "case 6:" 00205 case 7: // New. based on BO left 00206 { 00207 draw_L1(2,x,y,Newcolor,times); 00208 draw_New1(2,x,y,Lcolor,times); 00209 }break; //end of "case 7:" 00210 case 8: // L. based on left 00211 { 00212 draw_Square1(0,x,y,Newcolor,times); 00213 draw_L1(0,x,y,Lcolor,times); 00214 }break; //end of "case 8:" 00215 case 9: // L. based on left 00216 { 00217 draw_Square1(1,x,y,Newcolor,times); 00218 draw_L1(1,x,y,Lcolor,times); 00219 }break; //end of "case 9:" 00220 case 10: // L. based on left 00221 { 00222 draw_Square1(2,x,y,Newcolor,times); 00223 draw_L1(2,x,y,Lcolor,times); 00224 }break; //end of "case 10:" 00225 case 11: // L. based on left 00226 { 00227 draw_Square1(3,x,y,Newcolor,times); 00228 draw_L1(3,x,y,Lcolor,times); 00229 }break; //end of "case 11:" 00230 case 12: //Sq1. based on BO 00231 { 00232 draw_dist(1,x,y,Newcolor,times); 00233 }break; //end of "case 12:" 00234 case 13: //Sq1. based on BO right 00235 { 00236 draw_dist(0,x,y,Newcolor,times); 00237 }break; //end of "case 13:" 00238 case 14: //Sq1. based on BO right 00239 { 00240 draw_dist(3,x,y,Newcolor,times); 00241 }break; //end of "case 14:" 00242 case 15: //Sq1. based on BO right 00243 { 00244 draw_dist(2,x,y,Newcolor,times); 00245 }break; //end of "case 15:" 00246 case 16: // L. based on left 00247 { 00248 draw_Square1(0,x,y,Newcolor,times); 00249 draw_L1(0,x,y,Lcolor,times); 00250 }break; //end of "case 16:" 00251 case 17: // L. based on left 00252 { 00253 draw_Square1(1,x,y,Newcolor,times); 00254 draw_L1(1,x,y,Lcolor,times); 00255 }break; //end of "case 17:" 00256 case 18: // L. based on left 00257 { 00258 draw_Square1(2,x,y,Newcolor,times); 00259 draw_L1(2,x,y,Lcolor,times); 00260 }break; //end of "case 18:" 00261 case 19: // L. based on left 00262 { 00263 draw_Square1(3,x,y,Newcolor,times); 00264 draw_L1(3,x,y,Lcolor,times); 00265 }break; //end of "case 19:" 00266 default: 00267 { 00268 }break; 00269 } //end of "switch (stimuli)" 00270 00271 } 00272 00273 void Display_TargetShape(int target,int type) 00274 { 00275 glPushMatrix(); 00276 00277 switch (target){ 00278 case 0: 00279 {//void draw_Target_1(int type, float x, float y, float color, float times) //Square Shape 00280 shape_Sq(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00281 }break; 00282 case 1: 00283 { 00284 shape_New(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00285 }break; 00286 case 2: 00287 { 00288 shape_L(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00289 }break; 00290 } 00291 00292 glPopMatrix(); 00293 } 00294 00295 void Display_TargetCon(int BO, int target,int type) 00296 { 00297 glPushMatrix(); 00298 00299 if(BO == 0){//BO right 00300 switch (target){ 00301 case 0: 00302 {//void draw_Target_1(int type, float x, float y, float color, float times) //Square Shape 00303 blue_Sq(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00304 }break; 00305 case 1: 00306 { 00307 blue_New(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00308 }break; 00309 default: 00310 { 00311 blue_L(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00312 }break; 00313 } 00314 }else { //BO left 00315 switch (target){ 00316 case 0: 00317 {//void draw_Target_1(int type, float x, float y, float color, float times) //Square Shape 00318 red_Sq(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00319 }break; 00320 case 1: 00321 { 00322 red_New(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00323 }break; 00324 default: 00325 { 00326 red_L(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00327 }break; 00328 } 00329 } 00330 00331 glPopMatrix(); 00332 } 00333 00334 void Display_Blank(void) 00335 { 00336 glPushMatrix(); 00337 00338 glPopMatrix(); 00339 } 00340 00341 void Display_Shape_L(int target_Shape,int target_stim,int target_location,int stimuli[], 00342 int array[], int place[][16], int trial, float hor[],float ver[],float color[]) 00343 /* target is L shape and BO */ 00344 { 00345 time_t timer; 00346 struct tm *t_st; 00347 int x; 00348 float noise_x,noise_y; 00349 int wait; 00350 int dist_stim; 00351 00352 00353 time(&timer); 00354 t_st = localtime(&timer); 00355 00356 /***** Show only Fixation *****/ 00357 glClearColor(BGC, BGC, BGC, 0); 00358 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00359 Display_TargetShape(target_Shape,target_dir);//Display_TargetCon(int BO, int target,int type) 00360 glutSwapBuffers(); 00361 00362 /***** Show Flash Fixation ******/ 00363 for(wait = 0 ; wait < 5 ; wait++){ 00364 glClearColor(BGC, BGC, BGC, 0); 00365 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00366 Display_TargetShape(target_Shape,target_dir); 00367 glutSwapBuffers(); 00368 msleep(H_SLEEP); 00369 glClearColor(BGC, BGC, BGC, 0); 00370 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00371 Display_Blank(); 00372 glutSwapBuffers(); 00373 msleep(H_SLEEP); 00374 } 00375 00376 /*Draw Target*/ 00377 noise_x = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00378 noise_y = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00379 00380 glClearColor(BGC, BGC, BGC, 0); 00381 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00382 SelectStimuli(target_stim,color[target_location],hor[target_location]+noise_x,ver[target_location]+noise_y,2.0/(4.0*4.0)); 00383 00384 for(x = 0 ; x < 16; x++){ 00385 for(;;){ 00386 if(array[x] != 0)break; 00387 else if(array[x] == 0){ 00388 array[x] = 2; 00389 for(;;){ 00390 dist_stim = (t_st->tm_sec+rand())%STIM; 00391 if(stimuli[dist_stim] == 0){ 00392 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00393 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00394 SelectStimuli(dist_stim,color[x],hor[x]+noise_x,ver[x]+noise_y,2.0/(4.0*4.0)); //SelectStimuli(int stimuli, int type, int top, float Lcolor, float x, float y, float times) 00395 place[trial][x]=dist_stim; 00396 break; 00397 } 00398 } 00399 } 00400 } 00401 } 00402 //Display_TargetShape(target_Shape,target_dir); 00403 glutSwapBuffers(); 00404 00405 } 00406 00407 void Display_Shape_Sq(int target_Shape,int target_stim,int target_location,int stimuli[], 00408 int array[], int place[][16],int trial, float hor[],float ver[],float color[]) 00409 /* target is L shape and BO */ 00410 { 00411 time_t timer; 00412 struct tm *t_st; 00413 int x; 00414 float noise_x,noise_y; 00415 int wait; 00416 int dist_stim; 00417 00418 00419 time(&timer); 00420 t_st = localtime(&timer); 00421 00422 /***** Show only Fixation *****/ 00423 glClearColor(BGC, BGC, BGC, 0); 00424 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00425 Display_TargetShape(target_Shape,target_dir);//Display_TargetCon(int BO, int target,int type) 00426 glutSwapBuffers(); 00427 00428 /***** Show Flash Fixation ******/ 00429 for(wait = 0 ; wait < 5 ; wait++){ 00430 glClearColor(BGC, BGC, BGC, 0); 00431 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00432 Display_TargetShape(target_Shape,target_dir); 00433 glutSwapBuffers(); 00434 msleep(H_SLEEP); 00435 glClearColor(BGC, BGC, BGC, 0); 00436 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00437 Display_Blank(); 00438 glutSwapBuffers(); 00439 msleep(H_SLEEP); 00440 } 00441 00442 /*Draw Target*/ 00443 noise_x = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00444 noise_y = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00445 00446 glClearColor(BGC, BGC, BGC, 0); 00447 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00448 SelectStimuli(target_stim,color[target_location],hor[target_location]+noise_x,ver[target_location]+noise_y,2.0/(4.0*4.0)); 00449 //dist_type = target_type; 00450 00451 for(x = 0 ; x < 16; x++){ 00452 for(;;){ 00453 if(array[x] != 0)break; 00454 else if(array[x] == 0){ 00455 array[x] = 2; 00456 for(;;){ 00457 dist_stim = (t_st->tm_sec+rand())%STIM; 00458 if( stimuli[dist_stim] == 0){ 00459 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00460 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00461 SelectStimuli(dist_stim,color[x],hor[x]+noise_x,ver[x]+noise_y,2.0/(4.0*4.0)); //SelectStimuli(int stimuli, int type, int top, float Lcolor, float x, float y, float times) 00462 place[trial][x]=dist_stim; 00463 break; 00464 } 00465 } 00466 } 00467 } 00468 } 00469 //Display_TargetShape(target_Shape,target_dir); 00470 glutSwapBuffers(); 00471 } 00472 00473 void Display_Shape_New(int target_Shape,int target_stim,int target_location,int stimuli[], 00474 int array[], int place[][16],int trial, float hor[],float ver[],float color[]) 00475 /* target is L shape and BO */ 00476 { 00477 time_t timer; 00478 struct tm *t_st; 00479 int x; 00480 float noise_x,noise_y; 00481 int wait; 00482 int dist_stim; 00483 00484 00485 time(&timer); 00486 t_st = localtime(&timer); 00487 00488 /***** Show only Fixation *****/ 00489 glClearColor(BGC, BGC, BGC, 0); 00490 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00491 Display_TargetShape(target_Shape,target_dir);//Display_TargetCon(int BO, int target,int type) 00492 glutSwapBuffers(); 00493 00494 /***** Show Flash Fixation ******/ 00495 for(wait = 0 ; wait < 5 ; wait++){ 00496 glClearColor(BGC, BGC, BGC, 0); 00497 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00498 Display_TargetShape(target_Shape,target_dir); 00499 glutSwapBuffers(); 00500 msleep(H_SLEEP); 00501 glClearColor(BGC, BGC, BGC, 0); 00502 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00503 Display_Blank(); 00504 glutSwapBuffers(); 00505 msleep(H_SLEEP); 00506 } 00507 00508 /*Draw Target*/ 00509 noise_x = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00510 noise_y = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00511 glClearColor(BGC, BGC, BGC, 0); 00512 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00513 SelectStimuli(target_stim,color[target_location],hor[target_location]+noise_x,ver[target_location]+noise_y,2.0/(4.0*4.0)); 00514 //void SelectStimuli(int stimuli, int type, float Lcolor, float x, float y, float times) 00515 00516 00517 for(x = 0 ; x < 16; x++){ 00518 for(;;){ 00519 if(array[x] != 0)break; 00520 else if(array[x] == 0){ 00521 array[x] = 2; 00522 for(;;){ 00523 dist_stim = (t_st->tm_sec+rand())%STIM; 00524 if(stimuli[dist_stim] == 0){ 00525 //stimuli[dist_stim][dist_type] = 2; 00526 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00527 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00528 SelectStimuli(dist_stim,color[x],hor[x]+noise_x,ver[x]+noise_y,2.0/(4.0*4.0)); //SelectStimuli(int stimuli, int type, int top, float Lcolor, float x, float y, float times) 00529 place[trial][x]=dist_stim; 00530 break; 00531 //break; 00532 } 00533 } 00534 } 00535 } 00536 } 00537 //Display_TargetShape(target_Shape,target_dir); 00538 glutSwapBuffers(); 00539 } 00540 00541 void Display_Con_L(int target_BO, int target_Shape,int target_stim,int target_type,int target_location, 00542 int stimuli[], int array[], float hor[],float ver[],float color[]) 00543 /* target is L shape and BO */ 00544 { 00545 time_t timer; 00546 struct tm *t_st; 00547 int x; 00548 float noise_x,noise_y; 00549 int wait; 00550 int dist_location,dist_stim,dist_stim1,dist_stim2; 00551 00552 dist_stim1 = 0;dist_stim2 = 0; 00553 00554 time(&timer); 00555 t_st = localtime(&timer); 00556 00557 /***** Show only Fixation *****/ 00558 glClearColor(BGC, BGC, BGC, 0); 00559 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00560 Display_TargetCon(target_BO,target_Shape,target_dir);//Display_TargetCon(int BO, int target,int type) 00561 glutSwapBuffers(); 00562 00563 /***** Show Flash Fixation ******/ 00564 for(wait = 0 ; wait < 5 ; wait++){ 00565 glClearColor(BGC, BGC, BGC, 0); 00566 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00567 Display_TargetCon(target_BO,target_Shape,target_dir); 00568 glutSwapBuffers(); 00569 msleep(H_SLEEP); 00570 glClearColor(BGC, BGC, BGC, 0); 00571 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00572 Display_Blank(); 00573 glutSwapBuffers(); 00574 msleep(H_SLEEP); 00575 } 00576 00577 /*Draw Target*/ 00578 noise_x = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00579 noise_y = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00580 00581 glClearColor(BGC, BGC, BGC, 0); 00582 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00583 SelectStimuli(target_stim,color[target_location],hor[target_location]+noise_x,ver[target_location]+noise_y,2.0/(4.0*4.0)); 00584 00585 switch (target_stim){ 00586 case (8): 00587 { 00588 dist_stim1 = 1; 00589 dist_stim2 = 5; 00590 }break; 00591 case (9): 00592 { 00593 dist_stim1 = 0; 00594 dist_stim2 = 4; 00595 }break; 00596 00597 case (10): 00598 { 00599 dist_stim1 = 3; 00600 dist_stim2 = 7; 00601 }break; 00602 case (11): 00603 { 00604 dist_stim1 = 2; 00605 dist_stim2 = 6; 00606 }break; 00607 } 00608 00609 for(x=0;x<4;x++){ 00610 for(;;){ 00611 dist_location = (t_st->tm_sec+rand())%16; 00612 if(array[dist_location]==0){ 00613 SelectStimuli(dist_stim1,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00614 array[dist_location]=2; 00615 break; 00616 } 00617 } 00618 } 00619 00620 for(x=0;x<4;x++){ 00621 for(;;){ 00622 dist_location = (t_st->tm_sec+rand())%16; 00623 if(array[dist_location]==0){ 00624 SelectStimuli(dist_stim2,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00625 array[dist_location]=2; 00626 break; 00627 } 00628 } 00629 } 00630 00631 for(x=0;x<2;x++){ //New 00632 for(;;){ 00633 dist_location = (t_st->tm_sec+rand())%16; 00634 dist_stim = ((t_st->tm_sec+rand())%4)+4; 00635 //dist_type = (t_st->tm_sec+rand())%TYPE; 00636 if(array[dist_location]==0 && stimuli[dist_stim]==0 && dist_stim%2 == target_BO){ 00637 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00638 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00639 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00640 array[dist_location]=2; 00641 break; 00642 } 00643 } 00644 } 00645 00646 for(x=0;x<3;x++){ //L 00647 for(;;){ 00648 dist_location = (t_st->tm_sec+rand())%16; 00649 dist_stim = ((t_st->tm_sec+rand())%4)+8; 00650 //dist_type = (t_st->tm_sec+rand())%TYPE; 00651 if(array[dist_location]==0 && stimuli[dist_stim]==0 /*&& dist_stim%2 == target_BO*/){ 00652 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00653 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00654 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00655 array[dist_location]=2; 00656 break; 00657 } 00658 } 00659 } 00660 00661 for(x=0;x<2;x++){//square 00662 for(;;){ 00663 dist_location = (t_st->tm_sec+rand())%16; 00664 dist_stim = (t_st->tm_sec+rand())%4; 00665 //dist_type = (t_st->tm_sec+rand())%TYPE; 00666 if(array[dist_location]==0 && stimuli[dist_stim]==0 && dist_stim%2 != target_BO){ 00667 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00668 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00669 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00670 array[dist_location]=2; 00671 break; 00672 } 00673 } 00674 } 00675 //Display_TargetCon(target_BO,target_Shape,target_dir); 00676 glutSwapBuffers(); 00677 } 00678 00679 void Display_Con_Sq(int target_BO, int target_Shape,int target_stim,int target_type,int target_location, 00680 int stimuli[], int array[], float hor[],float ver[],float color[]) 00681 /* target is L shape and BO */ 00682 { 00683 time_t timer; 00684 struct tm *t_st; 00685 int x; 00686 float noise_x,noise_y; 00687 int wait; 00688 int dist_location,dist_stim; 00689 00690 00691 time(&timer); 00692 t_st = localtime(&timer); 00693 00694 /***** Show only Fixation *****/ 00695 glClearColor(BGC, BGC, BGC, 0); 00696 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00697 Display_TargetCon(target_BO,target_Shape,target_type);//Display_TargetCon(int BO, int target,int type) 00698 glutSwapBuffers(); 00699 00700 00701 /***** Show Flash Fixation ******/ 00702 for(wait = 0 ; wait < 5 ; wait++){ 00703 glClearColor(BGC, BGC, BGC, 0); 00704 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00705 Display_TargetCon(target_BO,target_Shape,target_type); 00706 glutSwapBuffers(); 00707 msleep(H_SLEEP); 00708 glClearColor(BGC, BGC, BGC, 0); 00709 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00710 Display_Blank(); 00711 glutSwapBuffers(); 00712 msleep(H_SLEEP); 00713 } 00714 00715 /*Draw Target*/ 00716 noise_x = ((t_st->tm_sec+rand())%21-10.0)/100.0; 00717 noise_y = ((t_st->tm_sec+rand())%21-10.0)/100.0; 00718 00719 glClearColor(BGC, BGC, BGC, 0); 00720 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00721 SelectStimuli(target_stim,color[target_location],hor[target_location]+noise_x,ver[target_location]+noise_y,2.0/(4.0*4.0)); 00722 //dist_type = target_type; 00723 00724 for(x=0;x<5;x++){//square 00725 for(;;){ 00726 dist_location = (t_st->tm_sec+rand())%16; 00727 dist_stim = (t_st->tm_sec+rand())%4; 00728 //dist_type = (t_st->tm_sec+rand())%TYPE; 00729 if(array[dist_location]==0 && stimuli[dist_stim]==0){ 00730 noise_x = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00731 noise_y = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00732 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00733 array[dist_location]=2; 00734 break; 00735 } 00736 } 00737 } 00738 00739 for(x=0;x<5;x++){ //New 00740 for(;;){ 00741 dist_location = (t_st->tm_sec+rand())%16; 00742 dist_stim = ((t_st->tm_sec+rand())%4)+4; 00743 //dist_type = (t_st->tm_sec+rand())%TYPE; 00744 if(array[dist_location]==0 && stimuli[dist_stim]==0){ 00745 noise_x = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00746 noise_y = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00747 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00748 array[dist_location]=2; 00749 break; 00750 } 00751 } 00752 } 00753 00754 for(x=0;x<5;x++){ //L 00755 for(;;){ 00756 dist_location = (t_st->tm_sec+rand())%16; 00757 dist_stim = ((t_st->tm_sec+rand())%4)+8; 00758 //dist_type = (t_st->tm_sec+rand())%TYPE; 00759 if(array[dist_location]==0 && stimuli[dist_stim]==0 && dist_stim%2 == target_BO){ 00760 noise_x = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00761 noise_y = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00762 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00763 array[dist_location]=2; 00764 break; 00765 } 00766 } 00767 } 00768 00769 //Display_TargetCon(target_BO,target_Shape,target_type); 00770 glutSwapBuffers(); 00771 } 00772 00773 void Display_Con_New(int target_BO, int target_Shape,int target_stim,int target_type,int target_location, 00774 int stimuli[], int array[], float hor[],float ver[],float color[]) 00775 /* target is New shape and BO */ 00776 { 00777 time_t timer; 00778 struct tm *t_st; 00779 int x; 00780 float noise_x,noise_y; 00781 int i,wait; 00782 int dist_location,dist_stim1,dist_stim2; 00783 00784 dist_stim1 = 0;dist_stim2 = 0; 00785 00786 time(&timer); 00787 t_st = localtime(&timer); 00788 00789 /***** Show only Fixation *****/ 00790 glClearColor(BGC, BGC, BGC, 0); 00791 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00792 Display_TargetCon(target_BO,target_Shape,target_dir);//Display_TargetCon(int BO, int target,int type) 00793 glutSwapBuffers(); 00794 00795 /***** Show Flash Fixation ******/ 00796 for(wait = 0 ; wait < 5 ; wait++){ 00797 glClearColor(BGC, BGC, BGC, 0); 00798 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00799 Display_TargetCon(target_BO,target_Shape,target_dir); 00800 glutSwapBuffers(); 00801 msleep(H_SLEEP); 00802 glClearColor(BGC, BGC, BGC, 0); 00803 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00804 Display_Blank(); 00805 glutSwapBuffers(); 00806 msleep(H_SLEEP); 00807 } 00808 00809 /*Draw Target*/ 00810 noise_x = ((t_st->tm_sec+rand())%21-10.0)/100.0; 00811 noise_y = ((t_st->tm_sec+rand())%21-10.0)/100.0; 00812 glClearColor(BGC, BGC, BGC, 0); 00813 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00814 SelectStimuli(target_stim,color[target_location],hor[target_location]+noise_x,ver[target_location]+noise_y,2.0/(4.0*4.0)); 00815 //void SelectStimuli(int stimuli, int type, float Lcolor, float x, float y, float times) 00816 00817 switch (target_stim){ 00818 case (4): 00819 { 00820 dist_stim1 = 9; 00821 }break; 00822 case (5): 00823 { 00824 dist_stim1 = 8; 00825 }break; 00826 case (6): 00827 { 00828 dist_stim1 = 11; 00829 }break; 00830 case (7): 00831 { 00832 dist_stim1 = 10; 00833 }break; 00834 } 00835 00836 for(i = 0 ;i < 3; i++){ //same shape 00837 for(;;){ 00838 dist_location = (t_st->tm_sec+rand())%16; 00839 if(array[dist_location]==0){ 00840 noise_x = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00841 noise_y = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00842 SelectStimuli(dist_stim1,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00843 array[dist_location]=2; 00844 break; 00845 } 00846 } 00847 } 00848 00849 for(x=0;x<5;x++){//New 00850 for(;;){ 00851 dist_location = (t_st->tm_sec+rand())%16; 00852 dist_stim2 = 4+(t_st->tm_sec+rand())%4; 00853 //dist_type = (t_st->tm_sec+rand())%TYPE; 00854 if(array[dist_location]==0 && stimuli[dist_stim2]==0 && dist_stim2%2 != target_BO){ 00855 noise_x = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00856 noise_y = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00857 SelectStimuli(dist_stim2,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00858 array[dist_location]=2; 00859 break; 00860 } 00861 } 00862 } 00863 00864 for(x=0;x<3;x++){//L 00865 for(;;){ 00866 dist_location = (t_st->tm_sec+rand())%16; 00867 dist_stim2 = 8+(t_st->tm_sec+rand())%4; 00868 //dist_type = (t_st->tm_sec+rand())%TYPE; 00869 if(array[dist_location]==0 && stimuli[dist_stim2]==0 && dist_stim2 != dist_stim1){ 00870 noise_x = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00871 noise_y = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00872 SelectStimuli(dist_stim2,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00873 array[dist_location]=2; 00874 break; 00875 } 00876 } 00877 } 00878 00879 for(x=0;x<4;x++){//square 00880 for(;;){ 00881 dist_location = (t_st->tm_sec+rand())%16; 00882 dist_stim2 = (t_st->tm_sec+rand())%4; 00883 //dist_type = (t_st->tm_sec+rand())%TYPE; 00884 if(array[dist_location]==0 && stimuli[dist_stim2]==0 && dist_stim2 != dist_stim1){ 00885 noise_x = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00886 noise_y = (((t_st->tm_sec+rand())%21)-10.0)/100.0; 00887 SelectStimuli(dist_stim2,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00888 array[dist_location]=2; 00889 break; 00890 } 00891 } 00892 } 00893 //Display_TargetCon(target_BO,target_Shape,target_dir); 00894 glutSwapBuffers(); 00895 } 00896 00897 void Display_Conjunction(int target_BO, int target_Shape,int target_stim,int target_type, 00898 int target_location, int stimuli[], int array[], float hor[],float ver[],float color[]) 00899 { 00900 if(target_Shape == 0){ //target is Square 00901 Display_Con_Sq(target_BO, target_Shape,target_stim,target_type,target_location,stimuli,array,hor,ver,color); 00902 }else if(target_Shape == 1){ //target is Pt2 00903 Display_Con_New(target_BO, target_Shape,target_stim,target_type,target_location,stimuli,array,hor,ver,color); 00904 }else if(target_Shape == 2){ //target is L shape 00905 Display_Con_L(target_BO, target_Shape,target_stim,target_type,target_location,stimuli,array,hor,ver,color); 00906 } 00907 } 00908 00909 void Display_Shape(int target_Shape,int target_stim,int target_location, 00910 int stimuli[], int array[], int place[][16], int trial, 00911 float hor[],float ver[],float color[]) 00912 { 00913 if(target_Shape == 0){ 00914 Display_Shape_Sq(target_Shape,target_stim,target_location,stimuli,array,place,trial,hor,ver,color); 00915 }else if(target_Shape == 1){ 00916 Display_Shape_New(target_Shape,target_stim,target_location,stimuli,array,place,trial,hor,ver,color); 00917 }else if(target_Shape == 2){ 00918 Display_Shape_L(target_Shape,target_stim,target_location,stimuli,array,place,trial,hor,ver,color); 00919 } 00920 } 00921 00922 void Display_Calibration(int state_calib, int calib[9]) 00923 { 00924 int i,check; 00925 time_t timer; 00926 struct tm *t_st; 00927 00928 time(&timer); 00929 t_st = localtime(&timer); 00930 //printf("state_calib = %d\n",state_calib); 00931 if(state_calib == 0 || state_calib == 2){ 00932 glClearColor(BGC, BGC, BGC, 0); 00933 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00934 Display_Fixation(); 00935 glutSwapBuffers(); 00936 } 00937 else if(state_calib == 1){ 00938 glClearColor(BGC, BGC, BGC, 0); 00939 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00940 //Display_Blank(); 00941 Display_Fixation(); 00942 glutSwapBuffers(); 00943 msleep(F_SLEEP); 00944 glClearColor(BGC, BGC, BGC, 0); 00945 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00946 Display_CalibPoints(); 00947 glutSwapBuffers(); 00948 }else if(state_calib >= 3 && state_calib <= 11){ 00949 for(;;){ 00950 check = ((t_st->tm_sec+rand())%9); 00951 if(calib[check]==0){ 00952 calib[check]=1; 00953 break; 00954 } 00955 } 00956 00957 for(i=0;i<5;i++){ 00958 msleep(CALIB); 00959 glClearColor(BGC, BGC, BGC, 0); 00960 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00961 Display_Blank(); 00962 glutSwapBuffers(); 00963 msleep(CALIB); 00964 glClearColor(BGC, BGC, BGC, 0); 00965 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00966 Display_Fixation(); 00967 glutSwapBuffers(); 00968 } 00969 //printf("state_calib = %d\n",state_calib); 00970 switch (check){ 00971 case 0:{ 00972 for(i=0;i<5;i++){ 00973 //msleep(CALIB); 00974 glClearColor(BGC, BGC, BGC, 0); 00975 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00976 //Display_Fixation(); 00977 Display_Calib1(); 00978 glutSwapBuffers(); 00979 msleep(CALIB); 00980 glClearColor(BGC, BGC, BGC, 0); 00981 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00982 Display_Blank(); 00983 //Display_Fixation(); 00984 glutSwapBuffers(); 00985 msleep(CALIB); 00986 } 00987 break; 00988 } 00989 case 1:{ 00990 for(i=0;i<5;i++){ 00991 //msleep(CALIB); 00992 glClearColor(BGC, BGC, BGC, 0); 00993 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00994 Display_Calib2(); 00995 //Display_Fixation(); 00996 glutSwapBuffers(); 00997 msleep(CALIB); 00998 glClearColor(BGC, BGC, BGC, 0); 00999 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01000 Display_Blank(); 01001 //Display_Fixation(); 01002 glutSwapBuffers(); 01003 msleep(CALIB); 01004 } 01005 break; 01006 } 01007 case 2:{ 01008 for(i=0;i<5;i++){ 01009 //msleep(CALIB); 01010 glClearColor(BGC, BGC, BGC, 0); 01011 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01012 Display_Calib3(); 01013 //Display_Fixation(); 01014 glutSwapBuffers(); 01015 msleep(CALIB); 01016 glClearColor(BGC, BGC, BGC, 0); 01017 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01018 Display_Blank(); 01019 //Display_Fixation(); 01020 glutSwapBuffers(); 01021 msleep(CALIB); 01022 } 01023 break; 01024 } 01025 case 3:{ 01026 for(i=0;i<5;i++){ 01027 //msleep(CALIB); 01028 glClearColor(BGC, BGC, BGC, 0); 01029 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01030 Display_Calib4(); 01031 //Display_Fixation(); 01032 glutSwapBuffers(); 01033 msleep(CALIB); 01034 glClearColor(BGC, BGC, BGC, 0); 01035 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01036 Display_Blank(); 01037 //Display_Fixation(); 01038 glutSwapBuffers(); 01039 msleep(CALIB); 01040 } 01041 break; 01042 } 01043 case 4:{ 01044 for(i=0;i<5;i++){ 01045 //msleep(CALIB); 01046 glClearColor(BGC, BGC, BGC, 0); 01047 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01048 Display_Calib5(); 01049 //Display_Fixation(); 01050 glutSwapBuffers(); 01051 msleep(CALIB); 01052 glClearColor(BGC, BGC, BGC, 0); 01053 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01054 Display_Blank(); 01055 //Display_Fixation(); 01056 glutSwapBuffers(); 01057 msleep(CALIB); 01058 } 01059 break; 01060 } 01061 case 5:{ 01062 for(i=0;i<5;i++){ 01063 //msleep(CALIB); 01064 glClearColor(BGC, BGC, BGC, 0); 01065 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01066 Display_Calib6(); 01067 //Display_Fixation(); 01068 glutSwapBuffers(); 01069 msleep(CALIB); 01070 glClearColor(BGC, BGC, BGC, 0); 01071 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01072 Display_Blank(); 01073 //Display_Fixation(); 01074 glutSwapBuffers(); 01075 msleep(CALIB); 01076 } 01077 break; 01078 } 01079 case 6:{ 01080 for(i=0;i<5;i++){ 01081 //msleep(CALIB); 01082 glClearColor(BGC, BGC, BGC, 0); 01083 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01084 Display_Calib7(); 01085 //Display_Fixation(); 01086 glutSwapBuffers(); 01087 msleep(CALIB); 01088 glClearColor(BGC, BGC, BGC, 0); 01089 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01090 Display_Blank(); 01091 //Display_Fixation(); 01092 glutSwapBuffers(); 01093 msleep(CALIB); 01094 } 01095 break; 01096 } 01097 case 7:{ 01098 for(i=0;i<5;i++){ 01099 //msleep(CALIB); 01100 glClearColor(BGC, BGC, BGC, 0); 01101 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01102 Display_Calib8(); 01103 //Display_Fixation(); 01104 glutSwapBuffers(); 01105 msleep(CALIB); 01106 glClearColor(BGC, BGC, BGC, 0); 01107 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01108 Display_Blank(); 01109 //Display_Fixation(); 01110 glutSwapBuffers(); 01111 msleep(CALIB); 01112 } 01113 break; 01114 } 01115 case 8:{ 01116 for(i=0;i<5;i++){ 01117 //msleep(CALIB); 01118 glClearColor(BGC, BGC, BGC, 0); 01119 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01120 Display_Calib9(); 01121 //Display_Fixation(); 01122 glutSwapBuffers(); 01123 msleep(CALIB); 01124 glClearColor(BGC, BGC, BGC, 0); 01125 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01126 Display_Blank(); 01127 //Display_Fixation(); 01128 glutSwapBuffers(); 01129 msleep(CALIB); 01130 } 01131 break; 01132 } 01133 default:break; 01134 } 01135 glClearColor(BGC, BGC, BGC, 0); 01136 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01137 //Display_Blank(); 01138 Display_Fixation(); 01139 glutSwapBuffers(); 01140 }else if(state_calib == 12){ 01141 glClearColor(BGC, BGC, BGC, 0); 01142 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01143 //Display_Blank(); 01144 Display_Fixation(); 01145 glutSwapBuffers(); 01146 msleep(F_SLEEP); 01147 glClearColor(BGC, BGC, BGC, 0); 01148 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 01149 Display_PointsF(); 01150 glutSwapBuffers(); 01151 } 01152 }