matlab - 脚本适用于键盘,但仅与响应按钮不一致
问题描述
在我的脚本中,我想在显示不同的刺激 ( , )r时记录响应(键盘或响应按钮单击)。循环(试用)总是显示,然后存储我们需要的响应时间记录的点击时间。可以在试用期间或每次试用中单击一次。image1
image2
image1
image2
image1
image2
使用键盘按下两个图像期间的记录工作。但是,它只记录在 期间的按钮按下image1
,而不是image2
。因此,问题不在于没有记录响应,而是按钮实际工作。
我试过:使用不同的响应按钮,使用鼠标作为响应按钮。当我单击响应按钮时,它会r
在命令行中写入,也在image1
收集期间。
显示时如何使响应按钮起作用image2
?
startOfTrial = GetSecs;
% Stimulus presentation
Screen('DrawTexture', myScreen, image1)
[VBLTimestamp StimulusOnsetTime1] = Screen('Flip', myScreen);
% Response recording
[keyIsDown, responseTime1, keyCode] = KbCheck; % saves whether a key has been pressed, seconds and the key which has been pressed.
while keyCode(BUTTON) == 0
[keyIsDown, responseTime1, keyCode] = KbCheck;
if responseTime1 - StimulusOnsetTime1 >= stimDuration
Screen('DrawTexture', myScreen, image2);
[VBLTimestamp StimulusEndTime1] = Screen('Flip', myScreen);
if responseTime1 - StimulusOnsetTime1 >= stimDuration + ISI
break
end
end
end
if responseTime1 - StimulusOnsetTime1 < stimDuration
WaitSecs(stimDuration - (responseTime1 - StimulusOnsetTime1));
[VBLTimestamp StimulusEndTime1] = Screen('Flip', myScreen);
end
% Checking correctness
if keyCode(BUTTON) == 1
RT(trial) = (responseTime1 - StimulusOnsetTime1)*1000; % Converts to milliseconds
response(trial) = 1;
if trialList(2, trial) == 1
correctness(trial) = 1; % Hit
else
correctness(trial) = 2; % False Alarm
end
else
response(trial) = 0;
if trialList(2, trial) == 1
correctness(trial) = 3; % Miss
else
correctness(trial) = 4; % Correct rejection
end
end
c = correctness(trial)
t2 = GetSecs;
% Presenting blank screen for remaining time
if t2 - StimulusEndTime1 < ISI
Screen('DrawTexture', myScreen, image2);
Screen('Flip', myScreen);
WaitSecs(ISI - (t2 - StimulusEndTime1));
end
解决方案
推荐阅读
- c# - LINQ 将数组与 DataRow 中的另一个数组匹配
- javascript - 我可以使用 javascript 在我的 html 文档中抓取其他网站吗?
- javascript - 简单的香草 JS 游戏
- python - 具有嵌套循环的理解列表中的迭代计数器
- javascript - Puppeteer 无法拦截 xhr 响应 json
- javascript - 触摸图像时如何使用javascript检测右键单击
- java - 合并多个 SDK
- node.js - 具有其他模式数组字段的猫鼬模式
- python - 通过腌制文件在python中加载模型的特征重要性
- build - 如何将依赖的第三方库复制到目标文件夹