Skip to content

Commit

Permalink
update dotStimulus to use procedural mask instead of filtered texture…
Browse files Browse the repository at this point in the history
… by default
  • Loading branch information
ian committed Sep 11, 2019
1 parent 1253ccd commit 6ff6bcd
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 220 deletions.
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.gitattributes text eol=lf
.gitignore text eol=lf
*.build text eol=lf
*.c text eol=lf
*.cmake text eol=lf
*.cpp text eol=lf
*.csv text eol=lf
*.h text eol=lf
*.m text eol=lf
*.md text eol=lf
*.py text eol=lf
*.rst text eol=lf
*.sh text eol=lf
*.txt text eol=lf
*.yml text eol=lf
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Junk
.DS_Store
.idea
.bzrignore
.vscode
.vscode
58 changes: 36 additions & 22 deletions communication/tobiiManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ function initialise(me,sM)
me.settings.freq = me.sampleRate;
me.settings.cal.bgColor = floor(me.screen.backgroundColour*255);
me.settings.UI.setup.bgColor = me.settings.cal.bgColor;
if IsLinux
settings.UI.setup.instruct.font = 'Liberation Sans';
settings.UI.button.setup.text.font = 'Liberation Sans';
settings.UI.button.val.text.font = 'Liberation Sans';
settings.UI.val.avg.text.font = 'Liberation Mono';
settings.UI.val.hover.text.font = 'Liberation Mono';
settings.UI.val.menu.text.font = 'Liberation Mono';
settings.UI.val.avg.text.color = 200;
end
updateDefaults(me);
me.tobii.init();
me.isConnected = true;
Expand Down Expand Up @@ -693,20 +702,21 @@ function runDemo(me,forcescreen)
if exist('forcescreen','var'); s.screen = forcescreen; end
s.backgroundColour = [0.5 0.5 0.5 0];
o = dotsStimulus('size',me.fixation.Radius*2,'speed',2,'mask',true,'density',50); %test stimulus
open(s); %open our screen
sv=open(s); %open our screen
setup(o,s); %setup our stimulus with open screen

ListenChar(1);
initialise(me,s); %initialise tobii with our screen
calViz = AnimatedCalibrationDisplay();
calViz = AnimatedCalibrationDisplay();
me.settings.cal.drawFunction = @(a,b,c,d,e,f) calViz.doDraw(a,b,c,d,e,f);
calViz.bgColor = 127;
calViz.bgColor = round(s.backgroundColour .* 255);
calViz.fixBackColor = 0;
calViz.fixFrontColor = 255;
calViz.fixFrontColor = 255;
me.settings.cal.bgColor = calViz.bgColor;
me.settings.cal.autoPace = 1;
me.settings.cal.doRandomPointOrder = false;
me.settings.val.pointPos = [.15 .15; .15 .85; .5 .5; .85 .15; .85 .85];
%me.settings.val.pointPos = [.1 .1;.1 .9;.5 .5;.9 .1;.9 .9];
me.settings.val.pointPos = [.15 .15; .15 .85; .5 .5; .85 .15; .85 .85];
%me.settings.val.pointPos = [.1 .1;.1 .9;.5 .5;.9 .1;.9 .9];
me.settings.UI.setup.eyeClr = 255;
me.settings.cal.pointNotifyFunction = @demoCalCompletionFun;
me.settings.val.pointNotifyFunction = @demoCalCompletionFun;
Expand All @@ -723,27 +733,31 @@ function runDemo(me,forcescreen)
Priority(MaxPriority(s.win));
endExp = 0;
trialn = 1;
maxTrials = 10;
maxTrials = 5;
m=1; n=1;
methods={'median','heuristic1','heuristic2','sg','simple'};
eyes={'both','left','right'};
Screen('TextFont',s.win,'Consolas');
fprintf('\n===>>> Warming up the GPU, Eyetracker etc... <<<===\n')
for i = 1:s.screenVals.fps*1
draw(o);
drawBackground(s);
s.drawPhotoDiodeSquare([0 0 0 1]);
Screen('DrawText',s.win,'Warming up...',65,10);
finishDrawing(s);
animate(o);
sgolayfilt(rand(10,1),1,3); %warm it up
me.heuristicFilter(rand(10,1), 2);
getSample(me);
flip(s);
end
sgolayfilt(rand(10,1),1,3); %warm it up
me.heuristicFilter(rand(10,1), 2);
startRecording(me);
WaitSecs(0.5);
mc = true;
for i = 1 : s.screenVals.fps
draw(o);
drawBackground(s);
s.drawPhotoDiodeSquare([double(mc) double(mc) double(mc) 1]);
Screen('DrawText',s.win,['Warming up frame ' num2str(i)],65,10);
finishDrawing(s);
animate(o);
getSample(me);
flip(s);
if mod(i,6)==0; mc = ~mc; end
end
s.drawPhotoDiodeSquare([0 0 0 1]);
update(o); %make sure stimuli are set back to their start state
flip(s);
startRecording(me);
trackerMessage(me,'Starting Demo...')

while trialn <= maxTrials && endExp == 0
Expand All @@ -757,7 +771,7 @@ function runDemo(me,forcescreen)
vbl = flip(s); tstart=vbl;
trackerMessage(me,'STARTING');
trackerMessage(me,'STARTVBL',vbl);
while vbl < tstart + 4
while vbl < tstart + 2
draw(o);
drawGrid(s);
drawCross(s,0.5,[1 1 0],me.fixation.X,me.fixation.Y);
Expand Down Expand Up @@ -806,7 +820,7 @@ function runDemo(me,forcescreen)
drawPhotoDiodeSquare(s,[0 0 0 1]);
vbl = flip(s);
trackerMessage(me,'END_RT',vbl);
trackerMessage(me,'TRIAL_RESULT 0 ABORT')
trackerMessage(me,'TRIAL_RESULT -10 ABORT')
trackerMessage(me,sprintf('Aborting %i @ %i', trialn, int64(round(vbl*1e6))))
end
end
Expand Down
42 changes: 24 additions & 18 deletions stimuli/baseStimulus.m
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ function run(me, benchmark, runtime, s, forceScreen, showVBL)
s = me.sM;
s.blend = true;
s.disableSyncTests = false;
s.visualDebug = true;
s.bitDepth = '8bit';
end
if ~exist('forceScreen','var') || isempty(forceScreen); forceScreen = -1; end
if ~exist('showVBL','var') || isempty(showVBL); showVBL = false; end
Expand All @@ -340,7 +342,7 @@ function run(me, benchmark, runtime, s, forceScreen, showVBL)
end

if ~s.isOpen
open(s); %open PTB screen
sv=open(s); %open PTB screen
end
setup(me,s); %setup our stimulus object

Expand All @@ -360,43 +362,47 @@ function run(me, benchmark, runtime, s, forceScreen, showVBL)

flip(s);
WaitSecs('YieldSecs',2);
a = 1;
vbl(a) = flip(s); b = vbl(a);
nFrames = 0;
notFinished = true;
benchmarkFrames = sv.fps * runtime;
vbl(1) = flip(s); startT = vbl(1);

while vbl(end) <= b + runtime
while notFinished
nFrames = nFrames + 1;
draw(me); %draw stimulus
if ~benchmark&&s.visualDebug;drawGrid(s);end
finishDrawing(s); %tell PTB/GPU to draw
animate(me); %animate stimulus, will be seen on next draw
if benchmark
vbl(a) = flip(s,0,2,2);
Screen('Flip',s.win,0,2,2);
else
vbl(a) = flip(s, vbl(end)); %flip the buffer
vbl(nFrames) = flip(s, vbl(end)); %flip the buffer
end
a = a + 1;
if benchmark
notFinished = nFrames <= benchmarkFrames;
else
notFinished = vbl(end) <= startT + runtime;
end
end

if benchmark; bb=GetSecs; end
flip(s);
WaitSecs(1);
endT = flip(s);
WaitSecs(0.5);
if showVBL
figure;
plot(diff(vbl)*1e3);
title(sprintf('VBL Times, should be ~%.2f ms',s.screenVals.ifi*1e3));
line([0 length(vbl-1)],[sv.ifi*1e3 sv.ifi*1e3]);
title(sprintf('VBL Times, should be ~%.2f ms',sv.ifi*1e3));
ylabel('Time (ms)')
xlabel('Frames')
end
Priority(0);
ShowCursor;
ListenChar(0);
Priority(0); ShowCursor; ListenChar(0);
reset(me); %reset our stimulus ready for use again
close(s); %close screen
s.screen = oldscreen;
s.windowed = oldwindowed;
s.bitDepth = oldbitdepth;
if benchmark
fps = (s.screenVals.fps*runtime) / (bb-b);
fprintf('\n\n======> SPEED = %g fps <=======\n', fps);
end
fps = nFrames / (endT-startT);
fprintf('\n\n======>>> <strong>SPEED</strong> (%i frames in %.2f secs) = <strong>%g</strong> fps <<<=======\n\n',nFrames, endT-startT, fps);
clear fps benchmark runtime b bb i; %clear up a bit
warning on
catch ME
Expand Down
Loading

0 comments on commit 6ff6bcd

Please sign in to comment.