JA_outcome_feedback_warming_up.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. function [Par] = JA_outcome_feedback_warming_up(Par)
  2. if ~isempty(find(ismember(Par.outcome_feedback_trials, Par.tr), 1))
  3. game_number = Par.final_design.Games{Par.tr};
  4. % set rigger for game number
  5. value = Par.final_design.Games{Par.tr};
  6. EEG_Trigger(Par.PP,Par.address,value);
  7. %% set parameters
  8. slide = prop2dim(Par.screen_dimensions, 0.1, 0);
  9. dimension = 30;
  10. text_catch = [];
  11. text_catch.dimension = dimension;
  12. text_catch.position = Par.screen_dimensions(3:4)/2;
  13. text_catch.position(1) = text_catch.position(1) - round(slide(1)/2);
  14. text_real = [];
  15. text_real.dimension = dimension;
  16. text_real.position = Par.screen_dimensions(3:4)/2;
  17. text_real.position(1) = text_real.position(1) - round(slide(1)/2);
  18. text_real.position(2) = round(Par.screen_dimensions(4)/1.5);
  19. %CF_catch_correctness(1:11) = [];
  20. %% check correctness
  21. for x = (Par.tr - 11+1):Par.tr
  22. % in case it is a catch trial...
  23. if strcmp(Par.final_design.CF_colors{x}, 'catch_color')
  24. if strcmp(Par.CF_classification(x), 'no_response')
  25. CF_catch_correctness(x) = 1;
  26. else
  27. CF_catch_correctness(x) = 0;
  28. end
  29. if strcmp(Par.SBJ_classification(x), 'no_response')
  30. SBJ_catch_correctness(x) = 1;
  31. else
  32. SBJ_catch_correctness(x) = 0;
  33. end
  34. else % in case it is a standard one...
  35. % considering CF performance
  36. switch Par.final_design.CF_colors{x}
  37. case 'press_color'
  38. if strcmp(Par.CF_classification(x), 'press')
  39. CF_real_correctness(x) = 1;
  40. else
  41. CF_real_correctness(x) = 0;
  42. end
  43. case 'lift_color'
  44. if strcmp(Par.CF_classification(x), 'lift')
  45. CF_real_correctness(x) = 1;
  46. else
  47. CF_real_correctness(x) = 0;
  48. end
  49. end
  50. % considering SBJ performance
  51. switch Par.final_design.SBJ_colors{x}
  52. case 'press_color'
  53. if strcmp(Par.SBJ_classification(x), 'press')
  54. SBJ_real_correctness(x) = 1;
  55. else
  56. SBJ_real_correctness(x) = 0;
  57. end
  58. case 'lift_color'
  59. if strcmp(Par.SBJ_classification(x), 'lift')
  60. SBJ_real_correctness(x) = 1;
  61. else
  62. SBJ_real_correctness(x) = 0;
  63. end
  64. end
  65. end
  66. end
  67. total_catch = (100*(sum(CF_catch_correctness) + sum(SBJ_catch_correctness))/(2*Par.catch_trials_x_game));
  68. total_real = (100*(sum(CF_real_correctness) + sum(SBJ_real_correctness))/(2*Par.real_trials_x_game));
  69. % if strcmp(Par.relationship, 'warming_up')
  70. %
  71. %
  72. %
  73. % end
  74. %%
  75. text_catch.string = strcat('prove di attenzione:', ' ', num2str(round(total_catch,0)), '%');
  76. text_real.string = strcat('prove normali:', ' ', num2str(round(total_real,0)), '%');
  77. % set colors based onpercentage of correctness
  78. if total_catch >= 50
  79. text_catch.color = [0 1 0];
  80. else
  81. text_catch.color = [1 0 0];
  82. end
  83. if total_real >= 70
  84. text_real.color = [0 1 0];
  85. else
  86. text_real.color = [1 0 0];
  87. end
  88. %% draw on the screen with text
  89. Screen('FillRect', Par.window, [0 0 0], Par.screen_dimensions);
  90. Screen('TextSize', Par.window, dimension); % prova 20
  91. DrawFormattedText(Par.window, text_catch.string, 'center',...
  92. text_catch.position(2), text_catch.color);
  93. DrawFormattedText(Par.window, text_real.string, 'center',...
  94. text_real.position(2), text_real.color);
  95. [Par.VBL] = Screen(Par.window, 'Flip');
  96. % leave it on the screen for 2 seconds
  97. WaitSecs(5);
  98. % Ready screen
  99. Screen('FillRect', Par.window, [0 0 0], Par.screen_dimensions);
  100. Screen('TextSize', Par.window, dimension); % prova 20
  101. DrawFormattedText(Par.window, 'Pronti', 'center',...
  102. 'center', [1 1 1]);
  103. % wait for someone allowing going on
  104. %KbStrokeWait;
  105. [Par.VBL] = Screen(Par.window, 'Flip');
  106. % leave it on the screen for 2 seconds
  107. WaitSecs(1);
  108. Par.warming_up_correctness.catch{game_number}= total_catch;
  109. Par.warming_up_correctness.real{game_number}= total_real;
  110. else % in case is not a last Game trials go ahead
  111. return
  112. end
  113. end