Hello fellow Psychtoolbox users,
I am a new masters student in vision science at Ohio Sate University and am working on a project involving visually evoked potentials in the occipital lobe. I have used the psychtoolbox to code a simple VEP that is just a monitor that flashes black and white at a specific frequency. I have some decent previous matlab experience, but I am new to psychtoolbox. I am looking for a way to code a control over screen luminance into my VEP script. Essentially, we want to be able to select a value for the luminance, plug that into the function, and have the code adjust the screen brightness as the VEP is running to maintain the average luminance. Does anyone know how this might be possible?
Here is my code - it’s about 60 lines of text. Sorry I couldn’t figure out how to attach the .txt file.
function bwssvep(freq)
if ~exist('freq','var') || isempty(freq)
freq = 11;
end
if ~exist('baseColor1','var') || isempty(baseColor1)
baseColor1 = [0 0 0 1];
end
if ~exist('baseColor2','var') || isempty(baseColor2)
baseColor2 = [1 1 1 1];
end
% Setup defaults and unit color range:
PsychDefaultSetup(2);
oldSyncLevel = Screen('Preference', 'SkipSyncTests', 2);
screenid = max(Screen('Screens'));
PsychImaging('PrepareConfiguration');
PsychImaging('AddTask', 'General', 'FloatingPoint32BitIfPossible');
[win, winRect] = PsychImaging('OpenWindow', screenid, baseColor1);
ifi = Screen('GetFlipInterval', win);
% Preperatory flip
time = 1/freq;
total_iterations=10/time;
for n=1:total_iterations
vbl = Screen('Flip', win);
tstart = vbl + ifi; %start is on the next frame
while vbl < tstart + time
Screen('FillRect',win, baseColor1);
vbl = Screen('Flip', win, vbl + 0.5 * ifi);
end
% Preperatory flip
vbl = Screen('Flip', win);
tstart = vbl + ifi; %start is on the next frame
while vbl < tstart + time
Screen('FillRect',win, baseColor2);
vbl = Screen('Flip', win, vbl + 0.5 * ifi);
end
n;
end
% Close onscreen window, release all resources:
sca;
% Restore old settings for sync-tests:
Screen('Preference', 'SkipSyncTests', oldSyncLevel);