M1_20141113_B001_settings.m 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. global STIM
  2. %% TIMING ================================================================================
  3. STIM.PreFixT = 1000; % time to enter fixation window
  4. STIM.FixT = 200; % time to fix before stim onset
  5. STIM.KeepFixT = 0; % time to fix before target onset. before 26-9-2014 this was 150
  6. STIM.ReacT = 2000; % max allowed reaction time (leave fixwin after target onset)
  7. STIM.SaccT = 2000; % max allowed saccade time (from leave fixwin to enter target win)
  8. STIM.ErrT = 500; % punishment extra ISI after error trial
  9. STIM.ISI = 500; % base inter-stimulus interval
  10. STIM.ISI_RAND = 100; % maximum extra (random) ISI to break any possible rythm
  11. %% STIMULI ===============================================================================
  12. % Background
  13. STIM.BackCol = [0.6 0.6 0.6]; % background color in [R G B] 0-1
  14. % fixation
  15. STIM.FixSz = 0.3; % fixation dot size in degrees visual angle
  16. STIM.FixWinSz = [1.2 1.2]; % oval [width height]
  17. % diameter of circular area (in deg) around fixation dot center that counts as 'fixation'
  18. STIM.FixPos = [0 0]; % position of fixation dot [X Y] in deg, relative to center of screen
  19. STIM.FixCol_NoGo = [1 0 0]; % fixation dot color in [R G B] 0-1 signalling 'hold fixation'
  20. STIM.FixCol_Go = [0 1 0]; % fixation dot color in [R G B] 0-1 signalling 'go to target'
  21. % stimulus objects
  22. % size
  23. STIM.TarSz = 1.8; % deg
  24. % window size
  25. STIM.TarWinSz = [4 4]; % oval [width height]
  26. %deg, circular area around target center used to detect selection with eye movement
  27. % Two color schemes because colors can switch in this paradigm
  28. STIM.ColSchemes(1).TargColCorr =[1 0.65 0.65];%[1 0 0];% [1 0.7 0.7];; % target
  29. STIM.ColSchemes(1).TargColErr_NonSal = STIM.ColSchemes(1).TargColCorr; % nonsalient nontarget
  30. STIM.ColSchemes(1).TargColErr_Sal =[0.65 1 0.65];%[0 1 0];%[0.9 0.9 0.7]; %salient nontarget
  31. STIM.ColSchemes(2).TargColCorr = [0.65 1 0.65];%[0 1 0];
  32. STIM.ColSchemes(2).TargColErr_NonSal = STIM.ColSchemes(2).TargColCorr;
  33. STIM.ColSchemes(2).TargColErr_Sal = [1 0.65 0.65];%[1 0 0];
  34. % probability of switching color-schemes
  35. STIM.ChanceSwitchColScheme = 0.5;
  36. % Reward values
  37. % you can use these for the 'real' Hickey task
  38. STIM.UseSpecRew = true; % if false, use the reward value from the tracker window
  39. STIM.RewardValues = [0.070 0.300]; % in seconds that the reward valve will be opened
  40. STIM.ConsSameRew = 5; % only allow this much consecutive trials with the same reward values
  41. % Positions
  42. STIM.PositionsManually = true;
  43. % If false, only give number of stimuli.
  44. % They will be equally spaced on a circle around fixation
  45. % If true, you can manually make the positions match receptive field locations
  46. if STIM.PositionsManually
  47. % positions
  48. % STIM.TarPos = [...
  49. % -2 -5;...
  50. % -5.3 -1;...
  51. % -3.3 4.3;...
  52. % 2 5;...
  53. % 5.3 1;...
  54. % 3.3 -4.3 ];
  55. STIM.TarPos = [...
  56. 5 -2 ;...
  57. 1 -5.3;...
  58. -4.3 -3.3 ;...
  59. -5 2 ;...
  60. -1 5.3 ;...
  61. 4.3 3.3 ];
  62. STIM.TarN = size(STIM.TarPos,1);
  63. else
  64. % number
  65. STIM.TarN = 6;
  66. % distance from fix
  67. STIM.TarDistFromFix = 5;
  68. % calculate positions
  69. StartAngle=0; %Polar angles start at 3 o'clock and move ccw
  70. STIM.PolarAngles = StartAngle:(2*pi)/(STIM.TarN):StartAngle+2*pi;
  71. %STIM.PolarAngles = 0:(2*pi)/(STIM.TarN):2*pi;
  72. %STIM.PolarAngles = STIM.PolarAngles(1:STIM.TarN);
  73. x=STIM.TarDistFromFix.*cos(STIM.PolarAngles);
  74. y=STIM.TarDistFromFix.*sin(STIM.PolarAngles);
  75. STIM.TarPos = [x' y'];
  76. end
  77. % target shape (possible)
  78. % 1 = circle
  79. % 2 = square
  80. % [1 2] = circle and square
  81. STIM.Shapes(1).name ='circle';
  82. STIM.Shapes(2).name ='rect';
  83. % fraction of the size of a rectangle that is used to create rounded corners
  84. % 1 creates circles, 0 creates sharp cornered rectangles
  85. STIM.RectRndCornerFract = 0;
  86. if STIM.RectRndCornerFract >1
  87. STIM.RectRndCornerFract=1;
  88. elseif STIM.RectRndCornerFract <0
  89. STIM.RectRndCornerFract=0;
  90. end
  91. STIM.TarShapeIncl = [1,2];
  92. % if circle and square, how should it be set up?
  93. % [Startshape SwitchEveryNthTrial]
  94. % StartShape: 1 = circle, 2 = square 0 = random
  95. % If SwitchEveryNthTrial=0 it's random
  96. STIM.TarShapeSetup = [0 0];
  97. %% TRIAL TYPE LIST =================
  98. STIM.TrialTypes = [];
  99. for pos = 1:STIM.TarN % position of target (can be anything)
  100. spos=1:STIM.TarN; % position of salient non-target
  101. spos(spos==pos)=[]; % can be anything but the target position
  102. for type = STIM.TarShapeIncl
  103. for i=1:length(spos)
  104. STIM.TrialTypes = [STIM.TrialTypes; pos type spos(i)];
  105. end
  106. end
  107. end
  108. %% TRIAL ORDER LIST ================
  109. % Predefine a long list of trial-definitions
  110. nTrialsDefined = 50000;
  111. STIM.TrialList=zeros(nTrialsDefined,3);
  112. %This procedure is less well commented & complex but it results in a list of trials
  113. for i=1:nTrialsDefined
  114. if length(STIM.TarShapeIncl)>1 % multiple shapes
  115. NextTrial=false;
  116. while ~NextTrial
  117. % pick a random trialtype number
  118. TypeNo = ceil(rand(1)*size(STIM.TrialTypes,1));
  119. % check against demands
  120. if i==1 && STIM.TarShapeSetup(1) % first target shape matters
  121. if STIM.TrialTypes(TypeNo,2)==STIM.TarShapeSetup(1)
  122. % ok
  123. STIM.TrialList(i,1)=TypeNo;
  124. STIM.TrialList(i,2)=ceil(2*rand(1));
  125. LastShape = STIM.TrialTypes(TypeNo,2);
  126. LastCS = STIM.TrialList(i,2);
  127. NextTrial=true;
  128. nConsec = 1;
  129. end
  130. elseif i==1 && ~STIM.TarShapeSetup(1)
  131. STIM.TrialList(i,1)=TypeNo;
  132. STIM.TrialList(i,2)=ceil(2*rand(1));
  133. NextTrial=true;
  134. LastShape = STIM.TrialTypes(TypeNo,2);
  135. LastCS = STIM.TrialList(i,2);
  136. nConsec = 1;
  137. elseif i~=1
  138. if nConsec < STIM.TarShapeSetup(2) && STIM.TarShapeSetup(2)
  139. % more same-shaped targets
  140. if STIM.TrialTypes(TypeNo,2)==LastShape
  141. STIM.TrialList(i,1)=TypeNo;
  142. if rand(1) <= STIM.ChanceSwitchColScheme
  143. % switch colors
  144. if LastCS == 1
  145. STIM.TrialList(i,2) = 2;
  146. elseif LastCS == 2
  147. STIM.TrialList(i,2) = 1;
  148. end
  149. else
  150. % don't switch
  151. if LastCS == 1
  152. STIM.TrialList(i,2) = 1;
  153. elseif LastCS == 2
  154. STIM.TrialList(i,2) = 2;
  155. end
  156. end
  157. LastCS = STIM.TrialList(i,2);
  158. NextTrial=true;
  159. LastShape = STIM.TrialTypes(TypeNo,2);
  160. nConsec = nConsec+1;
  161. end
  162. elseif nConsec == STIM.TarShapeSetup(2)
  163. if STIM.TrialTypes(TypeNo,2)~=LastShape
  164. STIM.TrialList(i,1)=TypeNo;
  165. if rand(1) <= STIM.ChanceSwitchColScheme
  166. % switch colors
  167. if LastCS == 1
  168. STIM.TrialList(i,2) = 2;
  169. elseif LastCS == 2
  170. STIM.TrialList(i,2) = 1;
  171. end
  172. else
  173. % don't switch
  174. if LastCS == 1
  175. STIM.TrialList(i,2) = 1;
  176. elseif LastCS == 2
  177. STIM.TrialList(i,2) = 2;
  178. end
  179. end
  180. LastCS = STIM.TrialList(i,2);
  181. NextTrial=true;
  182. LastShape = STIM.TrialTypes(TypeNo,2);
  183. nConsec = 1;
  184. end
  185. elseif ~STIM.TarShapeSetup(2)
  186. % random
  187. STIM.TrialList(i,1)=TypeNo;
  188. if rand(1) <= STIM.ChanceSwitchColScheme
  189. % switch colors
  190. if LastCS == 1
  191. STIM.TrialList(i,2) = 2;
  192. elseif LastCS == 2
  193. STIM.TrialList(i,2) = 1;
  194. end
  195. else
  196. % don't switch
  197. if LastCS == 1
  198. STIM.TrialList(i,2) = 1;
  199. elseif LastCS == 2
  200. STIM.TrialList(i,2) = 2;
  201. end
  202. end
  203. LastCS = STIM.TrialList(i,2);
  204. NextTrial=true;
  205. LastShape = STIM.TrialTypes(TypeNo,2);
  206. end
  207. end
  208. end
  209. else
  210. % pick a random trialtype number
  211. TypeNo = ceil(rand(1)*size(STIM.TrialTypes,1));
  212. STIM.TrialList(i)=TypeNo;
  213. end
  214. end
  215. %random reward assignment
  216. rewlist=ceil(rand(nTrialsDefined,1)*2);
  217. RewListDone=false;
  218. while ~RewListDone
  219. % check blocks of consecutive same
  220. rl=rewlist;
  221. for i=1:STIM.ConsSameRew-1
  222. rl=diff(rl);
  223. end
  224. ii=find(rl==0);
  225. if ~isempty(ii)
  226. rewlist(ii+round(STIM.ConsSameRew/2))=...
  227. rewlist(ii+round(STIM.ConsSameRew/2))+1;
  228. rewlist(rewlist==3)=1;
  229. else
  230. RewListDone=true;
  231. end
  232. end
  233. STIM.TrialList(:,3) = rewlist;