M1_20140922_B001_settings.m 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 = 150; % time to fix before target onset
  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.8;
  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.400]; % 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 -1;...
  57. 1.7 -4.8;...
  58. -3.4 -3.8 ;...%-4.5;...
  59. -5 1;...
  60. -1.7 4.8;...
  61. 3.4 3.8];
  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. STIM.TarShapeIncl = [1,2];
  84. % if circle and square, how should it be set up?
  85. % [Startshape SwitchEveryNthTrial]
  86. % StartShape: 1 = circle, 2 = square 0 = random
  87. % If SwitchEveryNthTrial=0 it's random
  88. STIM.TarShapeSetup = [0 0];
  89. %% TRIAL TYPE LIST =================
  90. STIM.TrialTypes = [];
  91. for pos = 1:STIM.TarN % position of target (can be anything)
  92. spos=1:STIM.TarN; % position of salient non-target
  93. spos(spos==pos)=[]; % can be anything but the target position
  94. for type = STIM.TarShapeIncl
  95. for i=1:length(spos)
  96. STIM.TrialTypes = [STIM.TrialTypes; pos type spos(i)];
  97. end
  98. end
  99. end
  100. %% TRIAL ORDER LIST ================
  101. % Predefine a long list of trial-definitions
  102. nTrialsDefined = 50000;
  103. STIM.TrialList=zeros(nTrialsDefined,3);
  104. %This procedure is less well commented & complex but it results in a list of trials
  105. for i=1:nTrialsDefined
  106. if length(STIM.TarShapeIncl)>1 % multiple shapes
  107. NextTrial=false;
  108. while ~NextTrial
  109. % pick a random trialtype number
  110. TypeNo = ceil(rand(1)*size(STIM.TrialTypes,1));
  111. % check against demands
  112. if i==1 && STIM.TarShapeSetup(1) % first target shape matters
  113. if STIM.TrialTypes(TypeNo,2)==STIM.TarShapeSetup(1)
  114. % ok
  115. STIM.TrialList(i,1)=TypeNo;
  116. STIM.TrialList(i,2)=ceil(2*rand(1));
  117. LastShape = STIM.TrialTypes(TypeNo,2);
  118. LastCS = STIM.TrialList(i,2);
  119. NextTrial=true;
  120. nConsec = 1;
  121. end
  122. elseif i==1 && ~STIM.TarShapeSetup(1)
  123. STIM.TrialList(i,1)=TypeNo;
  124. STIM.TrialList(i,2)=ceil(2*rand(1));
  125. NextTrial=true;
  126. LastShape = STIM.TrialTypes(TypeNo,2);
  127. LastCS = STIM.TrialList(i,2);
  128. nConsec = 1;
  129. elseif i~=1
  130. if nConsec < STIM.TarShapeSetup(2) && STIM.TarShapeSetup(2)
  131. % more same-shaped targets
  132. if STIM.TrialTypes(TypeNo,2)==LastShape
  133. STIM.TrialList(i,1)=TypeNo;
  134. if rand(1) <= STIM.ChanceSwitchColScheme
  135. % switch colors
  136. if LastCS == 1
  137. STIM.TrialList(i,2) = 2;
  138. elseif LastCS == 2
  139. STIM.TrialList(i,2) = 1;
  140. end
  141. else
  142. % don't switch
  143. if LastCS == 1
  144. STIM.TrialList(i,2) = 1;
  145. elseif LastCS == 2
  146. STIM.TrialList(i,2) = 2;
  147. end
  148. end
  149. LastCS = STIM.TrialList(i,2);
  150. NextTrial=true;
  151. LastShape = STIM.TrialTypes(TypeNo,2);
  152. nConsec = nConsec+1;
  153. end
  154. elseif nConsec == STIM.TarShapeSetup(2)
  155. if STIM.TrialTypes(TypeNo,2)~=LastShape
  156. STIM.TrialList(i,1)=TypeNo;
  157. if rand(1) <= STIM.ChanceSwitchColScheme
  158. % switch colors
  159. if LastCS == 1
  160. STIM.TrialList(i,2) = 2;
  161. elseif LastCS == 2
  162. STIM.TrialList(i,2) = 1;
  163. end
  164. else
  165. % don't switch
  166. if LastCS == 1
  167. STIM.TrialList(i,2) = 1;
  168. elseif LastCS == 2
  169. STIM.TrialList(i,2) = 2;
  170. end
  171. end
  172. LastCS = STIM.TrialList(i,2);
  173. NextTrial=true;
  174. LastShape = STIM.TrialTypes(TypeNo,2);
  175. nConsec = 1;
  176. end
  177. elseif ~STIM.TarShapeSetup(2)
  178. % random
  179. STIM.TrialList(i,1)=TypeNo;
  180. if rand(1) <= STIM.ChanceSwitchColScheme
  181. % switch colors
  182. if LastCS == 1
  183. STIM.TrialList(i,2) = 2;
  184. elseif LastCS == 2
  185. STIM.TrialList(i,2) = 1;
  186. end
  187. else
  188. % don't switch
  189. if LastCS == 1
  190. STIM.TrialList(i,2) = 1;
  191. elseif LastCS == 2
  192. STIM.TrialList(i,2) = 2;
  193. end
  194. end
  195. LastCS = STIM.TrialList(i,2);
  196. NextTrial=true;
  197. LastShape = STIM.TrialTypes(TypeNo,2);
  198. end
  199. end
  200. end
  201. else
  202. % pick a random trialtype number
  203. TypeNo = ceil(rand(1)*size(STIM.TrialTypes,1));
  204. STIM.TrialList(i)=TypeNo;
  205. end
  206. end
  207. %random reward assignment
  208. rewlist=ceil(rand(nTrialsDefined,1)*2);
  209. RewListDone=false;
  210. while ~RewListDone
  211. % check blocks of consecutive same
  212. rl=rewlist;
  213. for i=1:STIM.ConsSameRew-1
  214. rl=diff(rl);
  215. end
  216. ii=find(rl==0);
  217. if ~isempty(ii)
  218. rewlist(ii+round(STIM.ConsSameRew/2))=...
  219. rewlist(ii+round(STIM.ConsSameRew/2))+1;
  220. rewlist(rewlist==3)=1;
  221. else
  222. RewListDone=true;
  223. end
  224. end
  225. STIM.TrialList(:,3) = rewlist;