Skip to content

Commit

Permalink
try to limit behaviouralRecord log as MATLAB has a real performance i…
Browse files Browse the repository at this point in the history
…ssue wit uitextfield, update spotStimulus to use inline functions and some small fixes for robustness
  • Loading branch information
iandol committed Nov 16, 2022
1 parent 3ae3736 commit 76ffcf1
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 182 deletions.
6 changes: 3 additions & 3 deletions CoreProtocols/Saccade_AntiSaccadeStateInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@
%--------------------fix within
fixWithin = {
@()draw(stims); %draw stimulus
@()trackerDrawEyePosition(eT);
@()trackerFlip(eT, 1);
@()trackerDrawEyePosition(eT); % for tobii
@()trackerFlip(eT, 1); % for tobii
};

%--------------------test we are fixated for a certain length of time
Expand Down Expand Up @@ -383,7 +383,7 @@
@()updateExclusionZones(me, tS.useTask, tS.exclusionRadius);
@()trackerMessage(eT,'END_FIX');
@()hide(stims, 3);
};
};
if strcmpi(tS.type,'saccade')
fsExit = [ fsExit; { @()edit(stims,1,'alphaOut',tS.targetAlpha2) } ];
else
Expand Down
68 changes: 37 additions & 31 deletions runExperiment.m
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ function runTask(me)
else
run(me.userFunctionsFile)
end
me.userFunctions = ans;
me.userFunctions = ans; %#ok<NOANS>
uF = me.userFunctions;
uF.rE = me; uF.s = s; uF.task = task; uF.eT = eT;
uF.stims = stims; uF.io = io; uF.rM = rM;
Expand Down Expand Up @@ -795,18 +795,17 @@ function runTask(me)
warning('We had to reopen the labJackT to ensure a stable connection...')
end

%---------set up our behavioural plot
createPlot(bR, eT); drawnow;

%-----take over the keyboard + bump priority
KbReleaseWait; %make sure keyboard keys are all released
if ~isdeployed; commandwindow; end
if me.debug == false
%warning('off'); %#ok<*WNOFF>
ListenChar(-1); %2=capture all keystrokes
end
drawnow;
Priority(MaxPriority(s.win)); %bump our priority to maximum allowed

%---------set up our behavioural plot
createPlot(bR, eT);

%-----profiling starts here if uncommented
%profile clear; profile on;
Expand Down Expand Up @@ -837,18 +836,18 @@ function runTask(me)
if me.doFlip; s.finishDrawing(); end % potential optimisation, but note stateMachine may run non-drawing tasks in update()

%------check eye position manually. Also potentially log
% this retrieved value, but REMEMBER eyelink will save
% the properly sampled eye data in the EDF; this is just
% a backup sampled at the GPU FPS wrapped in the PTB
% loop.
% this retrieved value, but REMEMBER eyetracker will save
% the properly sampled eye data in the EDF; this is
% just a backup sampled at the GPU FPS wrapped in the
% PTB loop.
if me.needSample; getSample(eT); end
if tS.recordEyePosition && me.useEyeLink
saveEyeInfo(me, sM, eT, tS);
end

%------Check keyboard for commands (remember we can turn
% this off using either tS.keyExclusionPattern [per-state
% toggle] or tS.checkKeysDuringStimulus).
% this off using either tS.keyExclusionPattern
% [per-state toggle] or tS.checkKeysDuringStimulus).
if tS.checkKeysDuringStimulus || ~contains(sM.currentName,tS.keyExclusionPattern)
tS = checkKeys(me,tS);
end
Expand Down Expand Up @@ -905,17 +904,22 @@ function runTask(me)
tL.screenLog.trackerEndTime = getTrackerTime(eT);
tL.screenLog.trackerEndOffset = getTimeOffset(eT);

updatePlot(bR, me); %update our behavioural plot for final state
show(stims); %make all stimuli visible again, useful for editing
drawBackground(s);
trackerClearScreen(eT);
trackerDrawText(eT,['FINISHED TASK:' me.name]);
Screen('Flip', s.win);
Priority(0);
ListenChar(0);
RestrictKeysForKbCheck([]);
ShowCursor;
warning('on');
try %#ok<*TRYNC>
drawBackground(s);
trackerClearScreen(eT);
trackerDrawText(eT,['FINISHED TASK:' me.name]);
Screen('Flip', s.win);
Priority(0);
ListenChar(0);
RestrictKeysForKbCheck([]);
ShowCursor;
warning('on');
end

try
updatePlot(bR, me); %update our behavioural plot for final state
show(stims); %make all stimuli visible again, useful for editing
end

%notify(me,'endAllRuns');
me.isRunning = false;
Expand All @@ -931,13 +935,13 @@ function runTask(me)
close(io);
end

close(s); %screen
close(io); % I/O system
close(eT); % eyetracker, should save the data for us we've already given it our name and folder
WaitSecs(0.25);
close(aM); % audio manager
close(rM); % reward manager
try close(s); end %screen
try close(io); end % I/O system
try close(eT); end % eyetracker, should save the data for us we've already given it our name and folder
try close(aM); end % audio manager
try close(rM); end % reward manager

WaitSecs(0.25);
fprintf('\n\n======>>> Total ticks: %g | stateMachine ticks: %g\n', tS.totalTicks, sM.totalTicks);
fprintf('======>>> Tracker Time: %g | PTB time: %g | Drift Offset: %g\n', ...
tL.screenLog.trackerEndTime-tL.screenLog.trackerStartTime, ...
Expand Down Expand Up @@ -978,9 +982,11 @@ function runTask(me)
if me.diaryMode; diary off; end

me.stateInfo = [];
if isa(me.stateMachine,'stateMachine'); me.stateMachine.reset; end
if isa(me.stimuli,'metaStimulus'); me.stimuli.reset; end

try
if isa(me.stateMachine,'stateMachine'); me.stateMachine.reset; end
if isa(me.stimuli,'metaStimulus'); me.stimuli.reset; end
end

clear rE tL s tS bR rM eT io sM task

catch ME
Expand Down
2 changes: 1 addition & 1 deletion screenManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ function close(me)
end
me.isInAsync = false;
if me.isPlusPlus
BitsPlusPlus('Close');
try BitsPlusPlus('Close'); end
end
me.finaliseMovie(); me.moviePtr = [];
kind = Screen(me.win, 'WindowKind');
Expand Down
14 changes: 7 additions & 7 deletions stimuli/discStimulus.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
%> type can be "simple" or "flash"
type = 'simple'
%> colour for flash, empty to inherit from screen background with 0 alpha
flashColour = []
flashColour double = []
%> time to flash on and off in seconds
flashTime = [0.25 0.25]
flashTime double {mustBeVector(flashTime)} = [0.25 0.25]
%> is the ON flash the first flash we see?
flashOn = true
flashOn logical = true
%> contrast scales from foreground to screen background colour
contrast = 1
contrast double {mustBeInRange(contrast,0,1)} = 1
%> cosine smoothing sigma in pixels for mask
sigma = 31.0
sigma double = 31.0
%> use colour or alpha [default] channel for smoothing?
useAlpha = true
useAlpha logical = true
%> use cosine (0), hermite (1, default), or inverse hermite (2)
smoothMethod = 1
smoothMethod double = 1
end

properties (SetAccess = protected, GetAccess = public)
Expand Down
Loading

0 comments on commit 76ffcf1

Please sign in to comment.