children_multimod.sce 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. randomize_trials=true;
  2. #no_logfile = true;
  3. active_buttons = 1;
  4. button_codes = 0;
  5. response_matching = simple_matching;
  6. begin;
  7. array {
  8. sound{
  9. wavefile { filename = "koza.wav"; } snd_buck;
  10. } standard_stimulus; # standard stimulus;
  11. sound{
  12. wavefile { filename = "pes.wav"; } snd_dog;
  13. }; # target 1
  14. sound{
  15. wavefile { filename = "kocka.wav"; } snd_cat;
  16. };
  17. } sound_stimulus;
  18. array {
  19. picture {
  20. bitmap { filename = "koza.jpg"; } buck;
  21. x=0; y=0;
  22. } standard_pic;
  23. picture {
  24. bitmap { filename = "pes.jpg"; } dog;
  25. x=0; y=0;
  26. } target1_pic;
  27. picture {
  28. bitmap { filename = "kocka.jpg"; } cat;
  29. x=0; y=0;
  30. } target2_pic;
  31. } picture_stimulus;
  32. trial {
  33. trial_duration = 1200;
  34. stimulus_event{
  35. picture standard_pic;
  36. duration=700;
  37. } event1;
  38. stimulus_event{
  39. sound standard_stimulus;
  40. duration=700;
  41. port_code=1;
  42. code=1;
  43. } event2;
  44. } main;
  45. begin_pcl;
  46. array <int> stim[300];
  47. array <int> out_code[300];
  48. array <int> tg_stim_list[60];
  49. array <int> tg_type_list[60]; # obsahuje info o typu targetu 2 - pes štěká 3 - kočka mňouká 4- kočka štěká 5 - pes mňouká
  50. array <string> type[6]={"kz ","pe s", "ko m","ko s","pe m"};
  51. int st,num,en,pos,cat_pos;
  52. int cat_dog_pos, dog_cat_pos;
  53. int react_time, cum_react_time,false_react_time, false_cum_react_time;
  54. double avg_react,false_avg_react;
  55. string userid;
  56. output_file s_output = new output_file;
  57. # naplnění­ pole standardními stimuly
  58. loop int j=1 until j>300
  59. begin
  60. stim[j]=1;
  61. out_code[j]=1;
  62. j=j+1;
  63. end;
  64. # 20% se vymění za targety s kodem 2 (pes)
  65. st=3; num=60;
  66. loop int k=1 until k>60
  67. begin
  68. if (st <205) then en=st+4; else en=st + 3; end;
  69. if (en>295) then en=295; end;
  70. pos=random(st,en);
  71. tg_stim_list[k]=pos;
  72. tg_type_list[k]=2;
  73. stim[pos]=2;
  74. out_code[pos]=2; out_code[pos+1]=101;
  75. st=pos+3;
  76. k=k+1;
  77. end;
  78. # z př™edchozíchch 20% se jich 10% zamě›ní za tg s kodem 3 (kočka)
  79. loop int l=1 until l>30
  80. begin
  81. pos=random(1,60);
  82. cat_pos= tg_stim_list[pos];
  83. if (stim[cat_pos]!=3) then
  84. tg_type_list[pos] = 3;
  85. stim[cat_pos]=3; out_code[cat_pos]=3;
  86. out_code[cat_pos+1]=102;
  87. l=l+1;
  88. end;
  89. end;
  90. # u 5% targetu se zamění zvuky - tj. pes mňˆouká¡ a kočka štěká
  91. loop int l=1 until l>15
  92. begin
  93. int pos1, pos2;
  94. loop
  95. pos1=random(1,60);
  96. pos2=random(1,60);
  97. until (tg_type_list[pos1]==2) && (tg_type_list[pos2]==3)
  98. begin
  99. pos1=random(1,60);
  100. pos2=random(1,60);
  101. end;
  102. tg_type_list[pos1]=5; tg_type_list[pos2]=4;
  103. dog_cat_pos= tg_stim_list[pos1]; cat_dog_pos = tg_stim_list[pos2];
  104. stim[dog_cat_pos]=2; out_code[dog_cat_pos]=5;
  105. stim[cat_dog_pos]=3; out_code[cat_dog_pos]=4;
  106. out_code[dog_cat_pos+1]=103;out_code[cat_dog_pos+1]=104;
  107. l=l+1;
  108. end;
  109. /*-----------------------------------------------------------------------------------*/
  110. loop int i=1 until i>300
  111. begin
  112. term.print(stim[i]);
  113. i=i+1;
  114. end;
  115. term.print("\n");
  116. loop int i=1 until i>300
  117. begin
  118. term.print(out_code[i]); term.print(" ");
  119. i=i+1;
  120. end;
  121. term.print("\n");
  122. /*---------------------------------------------------------------------------------*/
  123. /* ----------------------- tady se spouští vlastní stimulace ----------------------*/
  124. userid=logfile.subject();
  125. s_output.open(userid+".txt");
  126. cum_react_time=0;
  127. false_cum_react_time=0;
  128. loop int i=1 until i>30
  129. begin
  130. s_output.print(i); s_output.print("\t"); s_output.print(out_code[i]);s_output.print("\t");
  131. event1.set_stimulus(picture_stimulus[stim[i]]);
  132. if (out_code[i]>3) && (out_code[i]<6) then
  133. event2.set_stimulus(sound_stimulus[out_code[i]-2]);
  134. s_output.print(type[out_code[i]]+"\t");
  135. else
  136. event2.set_stimulus(sound_stimulus[stim[i]]);
  137. s_output.print(type[stim[i]]+"\t");
  138. end;
  139. event2.set_port_code(out_code[i]);
  140. event2.set_event_code(string(out_code[i]));
  141. if (out_code[i]==2) || (out_code[i]==4)
  142. then event2.set_target_button(1);
  143. event2.set_stimulus_time_in(200);
  144. event2.set_stimulus_time_out(700);
  145. else event2.set_target_button(0);
  146. event2.set_response_active(true);
  147. end;
  148. main.present();
  149. i=i+1;
  150. stimulus_data last = stimulus_manager.last_stimulus_data();
  151. if (last.type()==stimulus_hit)
  152. then react_time=last.reaction_time();
  153. cum_react_time=cum_react_time+react_time;
  154. s_output.print("o"+"\t");s_output.print(react_time);
  155. /* term.print("React_time = "); term.print(react_time); term.print("\n"); */
  156. elseif (last.type()==stimulus_false_alarm)
  157. then
  158. false_react_time=last.reaction_time();
  159. false_cum_react_time=false_cum_react_time+false_react_time;
  160. s_output.print("x"+"\t"); s_output.print(false_react_time);
  161. end;
  162. s_output.print("\n");
  163. end;
  164. int total_hits = response_manager.total_hits();
  165. int total_false_alarms = response_manager.total_false_alarms();
  166. if (total_hits!=0)
  167. then avg_react=double(cum_react_time)/double(total_hits);
  168. else avg_react=0.;
  169. end;
  170. if (total_false_alarms!=0)
  171. then false_avg_react=double(false_cum_react_time)/double(total_false_alarms);
  172. else avg_react=0.;
  173. end;
  174. s_output.print("\n\n");
  175. s_output.print("Total hits = "); s_output.print(total_hits); s_output.print("\n");
  176. s_output.print("Total reaction time = "); s_output.print(avg_react); s_output.print("\n\n");
  177. s_output.print("Total false alarms = "); s_output.print(total_false_alarms); s_output.print("\n");
  178. s_output.print("Total false reaction time = "); s_output.print(false_avg_react); s_output.print("\n");
  179. term.print("Total hits = "); term.print(total_hits); term.print("\n");
  180. term.print("Total reaction time = "); term.print(avg_react); term.print("\n");
  181. s_output.close();