Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

ParSettings_NoDas.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. function ParSettings_SPIKE_MOCK_FIX_TR2500ms
  2. % ParSettings gives all parameters for the experiment in global Par
  3. global Par
  4. global StimObj
  5. %% Triggering =============================================================
  6. Par.TR = 2.5; % Not important during training
  7. Par.MRITriggeredStart = false;
  8. Par.MRITrigger_OnlyOnce = true;
  9. %% Get stimulus info ======================================================
  10. eval(Par.STIMSETFILE); % loads the chosen stimfile
  11. Stm=StimObj.Stm;
  12. % overwrites the stimsetting!
  13. StimObj.Stm.FixDotCol = [.3 .3 .3 ; .1 .1 .1]; %[RGB if not fixating; RGB fixating]
  14. % overrule generic fixation window
  15. Par.FixWinSize = [2.5 2.5]; % [W H] in deg
  16. %% Eyetracking parameters =================================================
  17. Par.SetZero = false; %initialize zero key to not pressed
  18. Par.SCx = 0.11; %initial scale in control window
  19. Par.SCy = 0.11;
  20. Par.OFFx = 0; %initial eye offset x => (center) of camera das output
  21. Par.OFFy = 0; %initial eye offset y
  22. Par.ScaleOff = [Par.OFFx; Par.OFFy; Par.SCx; Par.SCy];
  23. %Offx, %Offy, Scalex, Scaley ; offset and scaling of eyechannels
  24. %if using eyelink set to -1.0 else 1.0
  25. Par.xdir = 1;
  26. Par.ydir = 1;
  27. Par.Sdx = 0; %2* standard error on eyechannels in pixels
  28. Par.Sdy = 0;
  29. Par.FixWdDeg = Par.FixWinSize(1);
  30. Par.FixHtDeg = Par.FixWinSize(2);
  31. Par.TargWdDeg = 2;
  32. Par.TargHtDeg = 2;
  33. Par.Bsqr = 0; %use square (1) or ellipse (0 )
  34. Par.MousePress = 2; %0 left = 'normal', 1 middle = 'extend', 2 right = 'alt'
  35. Par.NoiseUpdate = false; %show standard error of noise in fixation period
  36. Par.NoiseUpdate = 0; %calculate noise level
  37. %to use or not use the mouse
  38. if ~exist('Par','var') || ~isfield(Par,'Mouserun')
  39. Par.Mouserun = 0;
  40. Par.MOff(1) = 0; %mouse offsets
  41. Par.MOff(2) = 0;
  42. end
  43. % parameters for interfacing with ISCAN
  44. Par.EyeRecAutoTrigger = false;
  45. Par.EyeRecStatus = 0; % recording status initially to 'not recording'
  46. Par.EyeRecTriggerLevel = 1; % 1 = stop recording, 0 = start recording
  47. %% Screen info ============================================================
  48. [ScrWidth, ScrHeight] = Screen('WindowSize',Par.ScrNr);
  49. Par.HW = ScrWidth/2; %get half width of the screen
  50. Par.HH = ScrHeight/2;
  51. Par.ScrCenter = [Par.HW Par.HH];
  52. [Par.ScreenWidthD2, Par.ScreenHeightD2] = Screen('DisplaySize',Par.ScrNr);
  53. if strcmp(Par.SetUp,'NIN')
  54. Par.DistanceToScreen = 700; % distance to screen in mm
  55. elseif strcmp(Par.SetUp,'Spinoza_MOCK')
  56. Par.DistanceToScreen = 1200; % distance to screen in mm
  57. % physical display size report is unreliable
  58. % these measures are taken by hand
  59. Par.ScreenWidthD2 = 600;
  60. Par.ScreenHeightD2 = 337.5;
  61. elseif strcmp(Par.SetUp,'Spinoza_3T')
  62. Par.DistanceToScreen = 1300; % distance to screen in mm
  63. Par.ScreenWidthD2 = 705;
  64. Par.ScreenHeightD2 = 400;
  65. end
  66. Par.PixPerDeg = Par.HW/atand(Par.ScreenWidthD2/(2*Par.DistanceToScreen));
  67. % CheckFlipRate
  68. hz = Screen('NominalFrameRate', Par.ScrNr); RefRate100=hz*100;
  69. [MeasuredFlip,nrValidSamples,stddev] = ...
  70. Screen('GetFlipInterval',Par.window,100,[],[]);
  71. Rf = 1/MeasuredFlip;
  72. if round(RefRate100/1000) ~= round(Rf/10) %should be approximately the same
  73. disp(['Warning!: refreshrate not properly reported by PTB; ' ...
  74. num2str(RefRate100/100) 'Hz'] )
  75. Par.fliptime = MeasuredFlip*1000; %in ms
  76. else
  77. Par.fliptime = 100000/RefRate100; %fliptime in ms
  78. end
  79. Par.fliptimeSec = Par.fliptime/1000;
  80. Par.nFlipsRefresh=round(Stm(1).FlipTimePredef/Par.fliptimeSec);
  81. if Par.nFlipsRefresh==0 || ~Stm(1).UsePreDefFlipTime
  82. Par.nFlipsRefresh=1;
  83. end
  84. Par.BG = Stm(1).BackColor; % get from stimulus file
  85. Par.ScrWhite=WhiteIndex(Par.window);
  86. Par.ScrBlack=BlackIndex(Par.window);
  87. %% DAS parameters =========================================================
  88. % Bit/port assignment
  89. Par.ErrorB = 0;
  90. Par.StimB = 1;
  91. %Par.TargetB = 2; % check if they're really not used!
  92. %Par.RewardB = 3; % check if they're really not used!
  93. %Par.SaccadeB = 4; done by DasControl do not use for something else!!
  94. %Par.TrialB = 5; done by DasControl
  95. Par.LED_B = [2 3]; % [1/LEFT 2/RIGHT]
  96. Par.MicroB = 6;
  97. Par.CorrectB = 7;
  98. %% Response box ===========================================================
  99. Par.ResponseBox.Type='Lift'; % 'Beam' or'Lift'
  100. %% Response task ==========================================================
  101. %Par.ResponseBox.Task = 'DetectGoSignal';
  102. Par.ResponseBox.Task = 'Fixate'; % doesn't really matter as long as
  103. % it's not DetectGoSignal
  104. Par.RESP_STATE_WAIT = 1; % Go signal not yet given
  105. Par.RESP_STATE_GO = 2; % Go signal given
  106. Par.RESP_STATE_DONE = 4; % Go signal given and response no longer possible (hit or miss)
  107. % Go-bar (vertical / horizontal target bar) -------------------------------
  108. Gobar_length = 8; % .02
  109. Par.GoBarSize = Gobar_length*[1, .25] + [0, 0.01]; % [length width] in deg
  110. Par.GoBarColor = [0.8 0.8 0.8]; % [R G B] 0-1
  111. % Color of the Response indicator (which hand)
  112. Par.RespLeverMatters = false;
  113. Par.RespIndColor = [Stm(1).BackColor;Stm(1).BackColor]; %0.1*[1 1 1;1 1 1]; % colors for the left and right target
  114. Par.RespIndSize = 3;
  115. Par.RespIndPos = [0 0; 0 0]; % deg
  116. Par.RespLeverGain = [1 1]; % [L R]
  117. Par.RespIndLeds = false;
  118. Par.DrawNeutralWaitInd = false;
  119. Par.DrawDuringWait_SOA = 0; % s
  120. Par.DrawBlockedInd = false; % indicator to draw when a lever is still up
  121. Par.BlockedIndColor = [.7 .7 .7];
  122. Par.SwitchDur = 60000; % (200) duration of alternative orientation
  123. Par.ResponseAllowed = [80 Par.SwitchDur+100]; % [after_onset after_offset] in ms
  124. Par.PostErrorDelay = 0; % extra wait time as punishment for error trials
  125. Par.DelayOnMiss = 0; % extra wait time as punishment for miss trials
  126. Par.PostCorrectDelay = 100;
  127. Par.NoIndicatorDuringPunishDelay=false;
  128. Par.ProbSideRepeatOnCorrect = 0.50;
  129. Par.ProbSideRepeatOnError = 0.50;
  130. Par.ProbSideRepeatOnMiss = 0.50;
  131. Par.ProbSideRepeatOnEarly = 0.50;
  132. Par.CatchBlock.do = true;
  133. Par.CatchBlock.AfterNumberOfTrials = 1;
  134. Par.CatchBlock.NoCorrectPerSideNeeded = 10;
  135. Par.CatchBlock.StartWithCatch = true;
  136. % set time-windows in which something can happen (ms)
  137. % [baseduration_without_switch ...
  138. % period_in_which_switch_randomly_occurs]
  139. Par.EventPeriods = [200 0]; % Determines Go-bar onset (was 600 to 1600)
  140. %% Connection box port assignment =========================================
  141. Par.ConnectBox.PhotoAmp = [4 5 7 8]; % channels for photo-amps
  142. Par.ConnectBox.EyeRecStat = 6; % channel for eye-tracker signal
  143. Par.ConnectBox.PhotoAmp_Levers = 1:2; % indeces to PhotoAmp channels
  144. Par.ConnectBox.PhotoAmp_HandIn = 3:4; % indeces to PhotoAmp channels
  145. %% Reward scheme ==========================================================
  146. Par.Reward = true; %boolean to enable reward stim bit or not
  147. Par.RewardSound = false; % give sound feedback about reward
  148. Par.RewSndPar = [44100 800 1]; % [FS(Hz) TonePitch(Hz) Amplitude]
  149. Par.RewardFixFeedBack = true;
  150. % RESP_CORRECT = 1;
  151. % RESP_FALSE = 2;
  152. % RESP_MISS = 3;
  153. % RESP_EARLY = 4;
  154. % RESP_BREAK_FIX = 5;
  155. Par.FeedbackSound = [false false false false false];
  156. Par.FeedbackSoundPar = [ ...
  157. 44100 800 1 0.03; ... CORRECT
  158. 44100 300 1 0.03; ... FALSE
  159. 44100 200 1 0.03; ... MISS
  160. 44100 300 1 0.03; ... EARLY
  161. 44100 400 1.5 0.03 ... FIXATION BREAK
  162. ];
  163. % [FS(Hz) TonePitch(Hz) Amplitude Duration]
  164. % duration matches 'open duration'
  165. % Create audio buffers for low latency sounds
  166. % (they are closed in runstim cleanup)
  167. if any(Par.FeedbackSound)
  168. try
  169. InitializePsychSound; % init driver
  170. % if no speakers are connected, windows shuts down the snd device and
  171. % this will return an error
  172. catch
  173. fprintf('There were no audio devices detected. Is the output connected?\n');
  174. end
  175. end
  176. for i=1:size(Par.FeedbackSoundPar,1)
  177. Par.FeedbackSoundSnd(i).Wav=nan;
  178. Par.FeedbackSoundSnd(i).Fs=nan;
  179. Par.FeedbackSoundSnd(i).h = nan;
  180. if Par.FeedbackSound(i)
  181. RewT=0:1/Par.FeedbackSoundPar(i,1):Par.FeedbackSoundPar(i,4);
  182. Par.FeedbackSoundSnd(i).Wav=...
  183. Par.FeedbackSoundPar(i,3)*sin(2*pi*Par.FeedbackSoundPar(i,2)*RewT);
  184. Par.FeedbackSoundSnd(i).Fs=Par.FeedbackSoundPar(i,1);
  185. Par.FeedbackSoundSnd(i).h = PsychPortAudio('Open', 1, [], 2,...
  186. Par.FeedbackSoundSnd(i).Fs, 1);
  187. PsychPortAudio('FillBuffer', Par.FeedbackSoundSnd(i).h, Par.FeedbackSoundSnd(i).Wav);
  188. clc;
  189. end
  190. end
  191. Par.RewardTaskMultiplier = 0.0;
  192. Par.RewardFixMultiplier = 1.0;
  193. % duration matches 'open duration'
  194. Par.RewardType = 0; % Duration: 0=fixed reward, 1=progressive, 2=stimulus dependent
  195. switch Par.RewardType
  196. case 0
  197. Par.RewardTimeSet = 0.05;%250;
  198. case 1
  199. % Alternatively use a progressive reward scheme based on the number of
  200. % preceding consecutive correct responses format as
  201. % rows stating: [nCorrectTrials RewardTime]
  202. Par.RewardTimeSet = [...
  203. 0 0.1;...
  204. 5 0.12;...
  205. 10 0.140;...
  206. 15 0.160;...
  207. 20 0.200];
  208. % NB! this will be overruled once you manually set the reward time
  209. % with the slider in the Tracker window
  210. case 2
  211. Par.RewardTimeSet = 0; %no reward
  212. end
  213. Par.RewardTimeManual = 0.100; % amount of reward when given manually
  214. Par.RewardFixHoldTimeProg = true;
  215. if Par.RewardFixHoldTimeProg
  216. Par.RewardFixHoldTime = [...
  217. 0 1000;...
  218. 5 1000;...
  219. 10 900;...
  220. 20 800;...
  221. 30 600;...
  222. ];
  223. else
  224. Par.RewardFixHoldTime =600; %time to maintain fixation for reward
  225. end
  226. Par.RewardTime=Par.RewardTimeSet;
  227. %% Hand requirements ======================================================
  228. % Require hands in the box (reduces movement?)
  229. Par.HandInBothOrEither = 'Either'; % 'Both' or 'Either'
  230. % Needed for initiation of tracker since it's in the gui now
  231. Par.RewNeeds.HandIsIn = false;
  232. Par.StimNeeds.HandIsIn = false;
  233. Par.FixNeeds.HandIsIn = false;
  234. Par.TrialNeeds.HandIsIn = false; % manual response task
  235. Par.TrialNeeds.LeversAreDown = true; % manual response task
  236. Par.HandOutDimsScreen = false;
  237. Par.HandOutDimsScreen_perc = 0.9; %(0-1, fraction dimming)
  238. % set-up function to check whether to draw stimulus
  239. if Par.StimNeeds.HandIsIn && strcmp(Par.HandInBothOrEither,'Both')
  240. Par.HideStim_BasedOnHandIn = @(Par) ~all(Par.HandIsIn);
  241. elseif Par.StimNeeds.HandIsIn && strcmp(Par.HandInBothOrEither,'Either')
  242. Par.HideStim_BasedOnHandIn = @(Par) ~any(Par.HandIsIn);
  243. else
  244. Par.HideStim_BasedOnHandIn = @(Par) false;
  245. end
  246. % set-up function to check whether to draw fixation
  247. if Par.FixNeeds.HandIsIn && strcmp(Par.HandInBothOrEither,'Both')
  248. Par.HideFix_BasedOnHandIn = @(Par) ~all(Par.HandIsIn);
  249. elseif Par.FixNeeds.HandIsIn && strcmp(Par.HandInBothOrEither,'Either')
  250. Par.HideFix_BasedOnHandIn = @(Par) ~any(Par.HandIsIn);
  251. else
  252. Par.HideFix_BasedOnHandIn = @(Par) false;
  253. end
  254. % set-up function to check whether to allow reward
  255. if Par.RewNeeds.HandIsIn && strcmp(Par.HandInBothOrEither,'Both')
  256. Par.Rew_BasedOnHandIn = @(Par) all(Par.HandIsIn);
  257. elseif Par.RewNeeds.HandIsIn && strcmp(Par.HandInBothOrEither,'Either')
  258. Par.Rew_BasedOnHandIn = @(Par) any(Par.HandIsIn);
  259. else
  260. Par.Rew_BasedOnHandIn = @(Par) true;
  261. end
  262. % functions for lever task
  263. if Par.TrialNeeds.HandIsIn && Par.TrialNeeds.LeversAreDown % hands in / levers down
  264. Par.CanStartTrial = @(Par) (all(Par.HandIsIn) && ~any(Par.LeverIsUp));
  265. elseif Par.TrialNeeds.HandIsIn % only hands in
  266. Par.CanStartTrial = @(Par) all(Par.HandIsIn);
  267. elseif Par.TrialNeeds.LeversAreDown % only levers down
  268. Par.CanStartTrial = @(Par) ~any(Par.LeverIsUp);
  269. else % independent of hand and lever position
  270. Par.CanStartTrial = @(Par) true;
  271. end
  272. Par.CorrectResponseGiven = ...
  273. @(Par) Par.ResponseSide > 0 && Par.BeamIsBlocked(Par.ResponseSide);
  274. Par.IncorrectResponseGiven = ...
  275. @(Par) Par.ResponseSide > 0 && Par.BeamIsBlocked(mod(Par.ResponseSide,2)+1);
  276. % Reward for keeping hand in the box
  277. Par.RewardForHandsIn = false;
  278. Par.RewardForHandsIn_Quant = [0.050 0.100]; % 1 hand, both hands
  279. Par.RewardForHandsIn_MultiplierPerHand = [1 1]; % if only one hand in is rewarded [L R]
  280. Par.RewardForHandsIn_Delay = 0.500; %s
  281. Par.RewardForHandIn_MinInterval = 4; %s
  282. Par.RewardForHandIn_ResetIntervalWhenOut = false;
  283. Par.RewardForHandIn_MinIntervalBetween = 1; %s
  284. % resets the timer for the next reward when the hand(s) are taken out
  285. % Fixation rewards are multiplied with this factor when hands are in
  286. Par.FixReward_HandInGain = [2 3]; % one hand , both hands
  287. %% Create Eye-check windows based on stimulus positions ===================
  288. % The code below is preloaded and will be overwritten on stimulus basis
  289. % for every trial individually
  290. %example window types, should be replaced by your own control windows
  291. FIX = 0; %this is the fixation window
  292. TALT = 1; %this is an alternative/erroneous target window
  293. TARG = 2; %this is the correct target window
  294. %Par.WIN = [xpos, ypos, pix width, pix height, window type]
  295. Par.WIN = [...
  296. 0, 0, Par.PixPerDeg*Par.FixWdDeg, Par.PixPerDeg*Par.FixHtDeg, FIX; ...
  297. 200, 0, Par.PixPerDeg*Par.TargWdDeg, Par.PixPerDeg*Par.TargHtDeg, TARG; ...
  298. -200, 0, Par.PixPerDeg*Par.TargWdDeg, Par.PixPerDeg*Par.TargHtDeg, TALT].';
  299. %when target and fixation windows change in position and dimension you will
  300. %have to call two functions. The first is to show their position on the tracker screen.
  301. %The second is to update das routines that detect eye movements entering
  302. %and leaving these windows
  303. % 1. ->refreshtracker( 1) %clear tracker screen and set fixation and target windows
  304. % 2. ->SetWindowDas %set das control thresholds using global parameters : Par
  305. %% Trial count inital =====================================================
  306. Par.Trlcount = [0 0]; %[this_position total]
  307. Par.CorrStreakcount = [0 0];
  308. %% Keyboard initialization ================================================
  309. Par.KeyEscape = KbName('Escape'); % allows breaking out of the experiment
  310. Par.KeyTriggerMR = KbName('t'); % MRI sends a sync pulse as a 't' keypress
  311. Par.KeyJuice = KbName('j'); % Manual juice reward
  312. Par.KeyStim = KbName('s'); % toggle stimulus on/off
  313. Par.KeyFix = KbName('f'); % toggle fix dot on/off
  314. Par.KeyPause = KbName('p'); % switch on/off stimuli & reward
  315. Par.KeyRewTimeSet = KbName('r'); % switch to reward timing as defined in ParSettings
  316. Par.KeyShowRewTime = KbName('w'); % Shows the current reward scheme
  317. % using the slider in tracker window overrules the initialize reward timing
  318. % Change stim position
  319. KbName('UnifyKeyNames');
  320. Par.Key1 = KbName('1!');
  321. Par.Key2 = KbName('2@');
  322. Par.Key3 = KbName('3#');
  323. Par.Key4 = KbName('4$');
  324. Par.Key5 = KbName('5%');
  325. % ARROW KEYS, adn 'Z' ARE USED BY TRACKER WINDOW
  326. % Par.KeyNext = KbName('RightArrow');
  327. % Par.KeyPrevious = KbName('LeftArrow');
  328. Par.KeyNext = KbName('n'); % next position
  329. Par.KeyCyclePos = KbName('0)'); % toggle cycle position automatically
  330. Par.KeyLockPos = KbName('l'); % lock current position (switching keys will have no effect)
  331. Par.PositionLocked=true;
  332. Par.KeyBeam = KbName('b'); % cycle through possible beam requirements
  333. Par.KeyBeamInd = 0;
  334. Par.KeyBeamStates = {...
  335. 'BeamState','Both/Either','TrialNeedsHand','FixNeedsHand';...
  336. '1','Both', 1,1;...
  337. '2','Both', 1,0;...
  338. '3','Both', 0,1;...
  339. '4','Either', 1,1;...
  340. '5','Either', 1,0;...
  341. '6','Either', 0,1;...
  342. '7','None', 0,0};
  343. %% Trial timing information (CvdT) ========================================
  344. % NB: Most of this is not used, but tracker may need it in initialization
  345. Par.Times.ToFix = 0; %time to enter fix window in ms
  346. Par.Times.Fix = 0; %Time in fixation window
  347. Par.Times.Stim = 0; %Stimulus on time
  348. Par.Times.Targ = Par.RewardFixHoldTime; %Time to keep fixating after stim onset
  349. Par.Times.TargCurrent = Par.Times.Targ;
  350. Par.Times.Rt = 0; %Time to make eye movement
  351. Par.Times.InterTrial = 0; %intertrial time
  352. Par.Times.RndFix = 0; %max uniform random time to add to stimulus onset time
  353. Par.Times.RndStim = 0; %max uniform random time to add to stimulus display time
  354. Par.Times.RndTarg = 0; %max uniform random time to add to target onset time
  355. Par.Times.Sacc = 0; %max time to finish saccade
  356. Par.Times.Err = 0; %time to add to in RT-epoch after error
  357. %
  358. Par.Drum = false; %drumming on or off, redoing error trials
  359. Par.DrumType = 1; %1=immediately repeat, 2=append to end, 3=insert randomly
  360. Par.isRunning = false; %stimulus presentation off
  361. %% Tracker window control =================================================
  362. Par.ZOOM = 0.52; %control - cogent window zoom
  363. Par.P1 = 1; Par.P2 = 1;
  364. %% Logging ================================================================
  365. Par.PlotPerformance = false;
  366. % log folder should be defined in stimsettings
  367. Par.LogFolder = Stm(1).LogFolder;