Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab PTB中的闪烁频率_Matlab_Frequency_Flicker_Psychtoolbox - Fatal编程技术网

Matlab PTB中的闪烁频率

Matlab PTB中的闪烁频率,matlab,frequency,flicker,psychtoolbox,Matlab,Frequency,Flicker,Psychtoolbox,我试图在PsychToolbox中呈现一个4Hz的闪烁刺激,持续5秒,然后是一个500Hz的音调。有人知道怎么做吗?我一直在使用vbl或屏幕刷新率来计算闪烁频率,但我不确定我是否在正确的轨道上。我也不知道如何在PTB中呈现听觉刺激(我已经尝试了声音功能)。非常感谢您的帮助 我不确定PTB中的声音演示(我从来没有这样做过),但对于闪烁频率,您似乎走在了正确的轨道上。 我这样做的方式是确定屏幕刷新率,将你想要的刺激呈现的总时间长度除以这个刷新率(这将给你在这段时间内绘制的帧数),然后有一个帧计数器,

我试图在PsychToolbox中呈现一个4Hz的闪烁刺激,持续5秒,然后是一个500Hz的音调。有人知道怎么做吗?我一直在使用vbl或屏幕刷新率来计算闪烁频率,但我不确定我是否在正确的轨道上。我也不知道如何在PTB中呈现听觉刺激(我已经尝试了声音功能)。非常感谢您的帮助

我不确定PTB中的声音演示(我从来没有这样做过),但对于闪烁频率,您似乎走在了正确的轨道上。 我这样做的方式是确定屏幕刷新率,将你想要的刺激呈现的总时间长度除以这个刷新率(这将给你在这段时间内绘制的帧数),然后有一个帧计数器,在每次翻转后增加1。然后可以使用此帧计数器打开或关闭命令

最简单的示例(在4Hz下随机更改背景颜色5秒):

定时精度将取决于您的特定刷新率

希望这有帮助

[w, wRect]=Screen('OpenWindow', 0);
MaxTime = 5; %Set maximum time for all stimuli to be presented in seconds
Hz = 4; %Set Hz for stimulus flicker
Screen('Flip',w);
Frametime=Screen('GetFlipInterval',w); %Find refresh rate in seconds

FramesPerFull = round(5/Frametime); % Number of frames for all stimuli
FramesPerStim = round((1/Hz)/Frametime); %Number of frames for each stimulus

StartT = GetSecs; %Measure start time of session
Framecounter = 0; %Frame counter begins at 0
while 1

    if Framecounter==FramesPerFull
        break; %End session
    end

    if ~mod(Framecounter,FramesPerStim)
        randomcolour = rand(1, 3)*255; %Change background stimulus colour
    end

    Screen('FillRect', w, randomcolour, wRect);
    Screen('Flip',w);

    Framecounter = Framecounter + 1; %Increase frame counter
end

EndT = GetSecs; %Measure end time of session
Screen('CloseAll');

EndT - StartT %Shows full length of time all stimuli were presented