Psychtoolbox固定刺激持续时间

时间:2018-01-10 16:00:37

标签: psychtoolbox

我正在尝试记录参与者对视觉刺激的反应,这些刺激需要在固定的持续时间(500毫秒)内显示。但是,我还希望在刺激开始的1秒时间窗口内,在这个固定的持续时间之后记录他们的反应。以下代码允许我仅在刺激呈现期间按下键时(500ms)记录响应。

public class AcceptForeverCompletionHandler implements CompletionHandler<AsynchronousSocketChannel, Pair<AsynchronousServerSocketChannel, Collection<AsynchronousSocketChannel>>> {

private final ReadForeverCompletionHandler readForeverAndEverAndSoOn = new ReadForeverCompletionHandler();

@Override
public void completed(AsynchronousSocketChannel result, Pair<AsynchronousServerSocketChannel, Collection<AsynchronousSocketChannel>> statefulStuff) {
    statefulStuff.getLeft().accept(statefulStuff, this); //Accept more new connections please as we go
    statefulStuff.getRight().add(result); //Collect these in case we want to for some reason, I don't know
    ByteBuffer buffer = ByteBuffer.allocate(4098); //4k seems a nice number
    result.read(buffer, Pair.of(result, buffer ),readForeverAndEverAndSoOn); //Kick off the read "forever"
}

@Override
public void failed(Throwable exc, Pair<AsynchronousServerSocketChannel, Collection<AsynchronousSocketChannel>> attachment) {
    //Shout fire
}

我是psychoolbox的新手,非常感谢任何帮助!!!

2 个答案:

答案 0 :(得分:0)

我假设picCounter在给定试验的整个1秒时间内保持不变。我认为你可以通过改变循环来实现你所需要的,这样它就可以继续查询键盘1秒钟,但是添加条件以便显示的内容取决于经过了多长时间。

start_time = GetSecs; % stimulus onset
while GetSecs-start_time<1

    % draw stimulus only if elapsed time is < 0.5 sec
    if GetSecs-start_time<0.5
        Screen('DrawTexture', mainwin, pics(picCounter));
    end
    vbl = Screen('Flip',mainwin, vbl + (waitframes - 0.5) * ifi);

    % proceed by querying keyboard, etc.
    [keyIsDown, secs, keyCode] = KbCheck;

    (...)

end

答案 1 :(得分:0)

您目前正在重新绘制并重新翻转每帧的刺激。如果这些是静态图像,则您不需要这样做,因为您只需要在需要更改屏幕上的内容时重新绘制和翻转。这是一个假设静态图像的例子。密钥响应循环在整个t2wait期间运行。在该循环中,条件语句比较分配给刺激的时间是否已经过去,如果是,则将其从屏幕中删除:

@NgModule({
  imports: [...],
  declarations: [CreateAssetModalComponent],
  entryComponents: [CreateAssetModalComponent]
})