Skip to content

Commit

Permalink
Timingfixes (#3)
Browse files Browse the repository at this point in the history
* wip

* refactoring

* wip

* add polar grating stimulus

* some small tweaks

* more tobii tweaks

* add anaglyph stereo option to screenManager

* tweaks

* rename drawPhotoDiode to drawPhotoDiodeSquare

* Fix RFLocaliser

* tweaks

* Enable descriptions in stimulus GUI panel

* tweaks

* Add useVulkan option to GUI

* vulkan gui tweaks

* tweak

* FIX broken pause for runTask

* improve tracker stimulus drawing

* reset the matrix2 data in barStimulus

* tweak

---------

Co-authored-by: iandol <[email protected]>
Co-authored-by: iandol <[email protected]>
Co-authored-by: iandol <iandol@cog5>
Co-authored-by: iandol <iandol@psychlab>
  • Loading branch information
5 people authored Jun 15, 2023
1 parent 8c5bb8f commit 5be2341
Show file tree
Hide file tree
Showing 40 changed files with 1,431 additions and 714 deletions.
12 changes: 6 additions & 6 deletions CoreProtocols/AreaSummationStateInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
pauseEntryFcn = {
@()hide(stims);
@()drawBackground(s); %blank the subject display
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
@()drawTextNow(s,'PAUSED, press [p] to resume...');
@()disp('PAUSED, press [p] to resume...');
@()trackerClearScreen(eT); % blank the eyelink screen
Expand All @@ -200,7 +200,7 @@
};

prefixFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

prefixExitFcn = {
Expand All @@ -226,7 +226,7 @@

%--------------------fix within
fixFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
@()draw(stims); %draw stimulus
};

Expand All @@ -252,7 +252,7 @@
%--------------------what to run when we are showing stimuli
stimFcn = {
@()draw(stims);
@()drawPhotoDiode(s,[1 1 1]);
@()drawPhotoDiodeSquare(s,[1 1 1]);
@()animate(stims); % animate stimuli for subsequent draw
};

Expand Down Expand Up @@ -282,7 +282,7 @@

%--------------------correct stimulus
correctFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%--------------------when we exit the correct state
Expand Down Expand Up @@ -328,7 +328,7 @@

%--------------------our incorrect stimulus
incFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%--------------------incorrect / break exit
Expand Down
12 changes: 6 additions & 6 deletions CoreProtocols/Back_PropagationStateInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
pauseEntryFn = {
@()hide(stims);
@()drawBackground(s); %blank the subject display
@()drawPhotoDiode(s,[0 0 0]); %draw black photodiode
@()drawPhotoDiodeSquare(s,[0 0 0]); %draw black photodiode
@()drawTextNow(s,'PAUSED, press [p] to resume...');
@()disp('PAUSED, press [p] to resume...');
@()trackerDrawStatus(eT,'PAUSED, press [p] to resume', stims.stimulusPositions);
Expand Down Expand Up @@ -260,7 +260,7 @@

%--------------------prefixate within
prefixFn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

prefixExitFn = {
Expand All @@ -279,7 +279,7 @@
%--------------------fix within
fixFn = {
@()draw(stims); %draw stimuli
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%--------------------test we are fixated for a certain length of time
Expand Down Expand Up @@ -317,7 +317,7 @@
%--------------------what to run when we are showing stimuli
stimFn = {
@()draw(stims);
@()drawPhotoDiode(s,[1 1 1]);
@()drawPhotoDiodeSquare(s,[1 1 1]);
@()animate(stims); % animate stimuli for subsequent draw
};

Expand Down Expand Up @@ -359,7 +359,7 @@

%--------------------correct stimulus
correctFn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%--------------------when we exit the correct state
Expand Down Expand Up @@ -392,7 +392,7 @@

%--------------------our incorrect/breakfix stimulus
incFn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%--------------------incorrect exit
Expand Down
Binary file modified CoreProtocols/Back_Propagation_Mapping.mat
Binary file not shown.
46 changes: 23 additions & 23 deletions CoreProtocols/ColourGratingStateInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
% then the state will finish before the fixation time was completed!
tS.fixX = 0; % X position in degrees
tS.fixY = 0; % X position in degrees
tS.firstFixInit = 1; % time to search and enter fixation window
tS.firstFixInit = 3; % time to search and enter fixation window
tS.firstFixTime = 0.25; % time to maintain fixation within windo
tS.firstFixRadius = 2; % radius in degrees
tS.strict = true; % do we forbid eye to enter-exit-reenter fixation window?
tS.stimulusFixTime = 2; % time to maintain fixation within windo
tS.stimulusFixTime = 1; % time to maintain fixation within windo
%Initialise the eyeTracker object with X, Y, FixInitTime, FixTime, Radius, StrictFix
eT.updateFixationValues(tS.fixX, tS.fixY, tS.firstFixInit, tS.firstFixTime, tS.firstFixRadius, tS.strict);

Expand Down Expand Up @@ -111,15 +111,15 @@
pauseEntryFcn = {
@()hide(stims); % hide all stimuli
@()drawBackground(s); % blank the subject display
@()drawPhotoDiode(s,[0 0 0]); % draw black photodiode
@()drawPhotoDiodeSquare(s,[0 0 0]); % draw black photodiode
@()drawTextNow(s,'PAUSED, press [p] to resume...');
@()disp('PAUSED, press [p] to resume...');
@()trackerDrawStatus(eT,'PAUSED, press [p] to resume', stims.stimulusPositions);
@()trackerMessage(eT,'TRIAL_RESULT -100'); %store message in EDF
@()resetAll(eT); % reset all fixation markers to initial state
@()setOffline(eT); % set eyelink offline [tobii ignores this]
@()stopRecording(eT, true); %stop recording eye position data, true=both eyelink & tobii
@()needFlip(me, false); % no need to flip the PTB screen
@()needFlip(me, false, 0); % no need to flip the PTB screen
@()needEyeSample(me, false); % no need to check eye position
};

Expand All @@ -136,11 +136,12 @@
%====================================================PRE-FIXATION
%==============================================================
%--------------------prefixate entry
prefixEntryFcn = {
@()needFlip(me, true, 1); % enable the screen and trackerscreen flip
prefixEntryFcn = {
@()needFlip(me, true); % enable the screen and trackerscreen flip
@()needEyeSample(me, true); % make sure we start measuring eye position
@()hide(stims); % hide all stimuli
% update the fixation window to initial values
@()resetFixationHistory(eT);
@()updateFixationValues(eT,tS.fixX,tS.fixY,[],tS.firstFixTime); %reset fixation window
@()startRecording(eT); % start eyelink recording for this trial (tobii ignores this)
% tracker messages that define a trial start
Expand All @@ -151,12 +152,12 @@

%--------------------prefixate within
prefixFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%--------------------prefixate exit
prefixExitFcn = {
@()trackerDrawStatus(eT,'Init Fix...', stims.stimulusPositions);
@()trackerDrawStatus(eT,'Start...', stims.stimulusPositions);
};

%==============================================================
Expand All @@ -171,7 +172,7 @@
%--------------------fix within
fixFcn = {
@()draw(stims); %draw stimuli
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%--------------------test we are fixated for a certain length of time
Expand All @@ -182,8 +183,8 @@
% is returned and the state machine will jump to the correct state,
% otherwise 'breakfix' is returned and the state machine will jump to the
% breakfix state. If neither condition matches, then the state table below
% defines that after 5 seconds we will switch to the incorrect state.
@()testSearchHoldFixation(eT,'stimulus','incorrect')
% defines that after 15 seconds we will switch to the breakfix state.
@()testSearchHoldFixation(eT,'stimulus','breakfix')
};

%--------------------exit fixation phase
Expand All @@ -207,7 +208,7 @@
%--------------------what to run when we are showing stimuli
stimFcn = {
@()draw(stims);
@()drawPhotoDiode(s,[1 1 1]);
@()drawPhotoDiodeSquare(s,[1 1 1]);
@()animate(stims); % animate stimuli for subsequent draw
};

Expand All @@ -220,7 +221,7 @@
% otherwise 'breakfix' is returned and the state machine will jump to the
% breakfix state. If neither condition matches, then the state table below
% defines that after 5 seconds we will switch to the incorrect state.
@()testHoldFixation(eT,'correct','breakfix');
@()testHoldFixation(eT,'correct','incorrect');
};

%as we exit stim presentation state
Expand Down Expand Up @@ -250,7 +251,7 @@

%--------------------correct stimulus
correctFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%--------------------when we exit the correct state
Expand All @@ -270,7 +271,6 @@
%====================================================INCORRECT/BREAKFIX
%--------------------incorrect entry
incEntryFcn = {
@()beep(aM, tS.errorSound);
@()trackerMessage(eT,'END_RT');
@()trackerMessage(eT,sprintf('TRIAL_RESULT %i',tS.INCORRECT));
@()trackerDrawStatus(eT,'Incorrect! :-(',stims.stimulusPositions);
Expand All @@ -283,7 +283,6 @@

%--------------------break entry
breakEntryFcn = {
@()beep(aM, tS.errorSound);
@()trackerMessage(eT,'END_RT');
@()trackerMessage(eT,sprintf('TRIAL_RESULT %i',tS.BREAKFIX));
@()trackerDrawStatus(eT,'Broke Fixation! :-(',stims.stimulusPositions);
Expand All @@ -296,11 +295,12 @@

%--------------------our incorrect stimulus
incFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%--------------------incorrect / break exit
incExitFcn = {
@()beep(aM, tS.errorSound);
@()sendStrobe(io,251);
@()updatePlot(bR, me); % update our behavioural plot;
@()resetRun(task); % we randomise the run within this block to make it harder to guess next trial
Expand All @@ -310,7 +310,7 @@
@()trackerClearScreen(eT);
@()resetAll(eT); % resets the fixation state timers
@()checkTaskEnded(me); % check if task is finished
@()needFlip(me, false);
@()needFlip(me, false, 0);
@()plot(bR, 1); % actually do our behaviour record drawing
};

Expand Down Expand Up @@ -360,11 +360,11 @@
'pause' 'prefix' inf pauseEntryFcn [] [] pauseExitFcn;
%---------------------------------------------------------------------------------------------
'prefix' 'fixate' 1 prefixEntryFcn prefixFcn [] prefixExitFcn;
'fixate' 'incorrect' 5 fixEntryFcn fixFcn inFixFcn fixExitFcn;
'stimulus' 'incorrect' 5 stimEntryFcn stimFcn maintainFixFcn stimExitFcn;
'incorrect' 'timeout' 0.5 incEntryFcn incFcn [] incExitFcn;
'breakfix' 'timeout' 0.5 breakEntryFcn incFcn [] incExitFcn;
'correct' 'prefix' 0.5 correctEntryFcn correctFcn [] correctExitFcn;
'fixate' 'breakfix' 15 fixEntryFcn fixFcn inFixFcn fixExitFcn;
'stimulus' 'incorrect' 15 stimEntryFcn stimFcn maintainFixFcn stimExitFcn;
'incorrect' 'timeout' 0.1 incEntryFcn incFcn [] incExitFcn;
'breakfix' 'timeout' 0.1 breakEntryFcn incFcn [] incExitFcn;
'correct' 'prefix' 0.1 correctEntryFcn correctFcn [] correctExitFcn;
'timeout' 'prefix' tS.tOut [] [] [] [];
%---------------------------------------------------------------------------------------------
'calibrate' 'pause' 0.5 calibrateFcn [] [] [];
Expand Down
10 changes: 5 additions & 5 deletions CoreProtocols/DotColourStateInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@

prefixFcn = {
@()drawBackground(s);
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

prefixExitFcn = {
Expand All @@ -188,7 +188,7 @@
%fix within
fixFcn = {
@()draw(stims); %draw stimulus
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%test we are fixated for a certain length of time
Expand All @@ -213,7 +213,7 @@
%what to run when we are showing stimuli
stimFcn = {
@()draw(stims);
@()drawPhotoDiode(s,[1 1 1]);
@()drawPhotoDiodeSquare(s,[1 1 1]);
@()animate(stims); % animate stimuli for subsequent draw
};

Expand Down Expand Up @@ -245,7 +245,7 @@

%correct stimulus
correctFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%when we exit the correct state
Expand Down Expand Up @@ -277,7 +277,7 @@

%our incorrect stimulus
incFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%incorrect / break exit
Expand Down
10 changes: 5 additions & 5 deletions CoreProtocols/DotDirectionStateInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@

prefixFcn = {
@()drawBackground(s);
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

prefixExitFcn = {
Expand All @@ -187,7 +187,7 @@
%fix within
fixFcn = {
@()draw(stims); %draw stimulus
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%test we are fixated for a certain length of time
Expand All @@ -212,7 +212,7 @@
%what to run when we are showing stimuli
stimFcn = {
@()draw(stims);
@()drawPhotoDiode(s,[1 1 1]);
@()drawPhotoDiodeSquare(s,[1 1 1]);
@()animate(stims); % animate stimuli for subsequent draw
};

Expand Down Expand Up @@ -244,7 +244,7 @@

%correct stimulus
correctFcn = {
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%when we exit the correct state
Expand Down Expand Up @@ -277,7 +277,7 @@
%our incorrect stimulus
incFcn = {
@()drawBackground(s);
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
};

%incorrect / break exit
Expand Down
4 changes: 2 additions & 2 deletions CoreProtocols/FigureGroundStateInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
%--------------------fix within
fixFcn = {
@()draw(stims);
@()drawPhotoDiode(s,[0 0 0])
@()drawPhotoDiodeSquare(s,[0 0 0])
};

%--------------------test we are fixated for a certain length of time
Expand Down Expand Up @@ -299,7 +299,7 @@
%--------------------what to run when we are showing stimuli
stimFcn = {
@()draw(stims);
@()drawPhotoDiode(s,[1 1 1]);
@()drawPhotoDiodeSquare(s,[1 1 1]);
@()animate(stims); % animate stimuli for subsequent draw
};

Expand Down
4 changes: 2 additions & 2 deletions CoreProtocols/Isoluminant_Colours_StateInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
%--------------------fix within
fixFcn = {
@()draw(stims); %draw stimuli
@()drawPhotoDiode(s,[0 0 0]);
@()drawPhotoDiodeSquare(s,[0 0 0]);
@()animate(stims); % animate stimuli for subsequent draw
};

Expand All @@ -313,7 +313,7 @@
%--------------------what to run when we are showing stimuli
stimFcn = {
@()draw(stims);
@()drawPhotoDiode(s,[1 1 1]);
@()drawPhotoDiodeSquare(s,[1 1 1]);
@()animate(stims); % animate stimuli for subsequent draw
};

Expand Down
Loading

0 comments on commit 5be2341

Please sign in to comment.