第七章按键反应的记录、保存 和数据分析 Key Presses and Data analysis
Key Presses and Data analysis
单个实验试次Tria的流程 01 呈现刺激 Psychtoolbox(PTB)中 的Screen函数 ??? 02 记录(按键)反应
Psychtoolbox(PTB)中 的Screen函数 呈 现 刺 激 ??? 记 录 ( 按 键 ) 反 应
7.1与PTB兼容的按键相关命令 ·新建一个m文件KbPractice ·功能:持续记录键盘上的按键,并在命令窗口显示对应的 按键数字码以及按键时间;按SPACE键结束记录。 1 号bPractice,m 2 Displays the number of seconds that have elapsed when the user presses a key. sa simplified version of KbDemo modified by YW,2022 >KbPractice %在命令窗口运行KbPractice Testing KbCheck and KbName:press a key to see its number Press the 'SPACE'key to exit. You pressed key 87 which is w typed at time 2.4043seconds You pressed key 69 which is e typed at time 3.5383seconds You pressed key 65 which is a typed at time 5.286seconds You pressed key 82 which is r typed at time 5.7581seconds You pressed key 70 which is f typed at time 6.828seconds You pressed key 49 which is 1!typed at time 12.7795seconds You pressed key 50 which is 23 typed at time 13.3814seconds You pressed key 51 which is 3 typed at time 13.8795seconds You pressed key 97 which is 1 typed at time 15.4673seconds You pressed key 98 which is 2 typed at time 15.7394seconds You pressed key 99 which is 3 typed at time 16.1774seconds You pressed key 32 which is space typed at time 18.0832seconds
l 新建一个m文件KbPractice • 功能:持续记录键盘上的按键,并在命令窗口显示对应的 按键数字码以及按键时间;按SPACE键结束记录。 %在命令窗口运行KbPractice
6 bName ('UnifyKevNames); WaitSecs(1.0); 8 disp('Testing KbCheck and KbName:preas a key to see ita number') 9 disp('Preas the 'SPACE''key to exit.'); 10 escapeKey KbName ('SPACE'); ●KbName %在命令窗口测试KbName ·实现键盘按键数字码和所表示的按键名称 之间的转换。 >KbName('a') .KbName('UnifyKeyNames') ans ·可以使程序使用在Windows.系统和Mac系 65 统下通用的按键 >KbName(65) .WaitSecs ans ·等待给定的时间,单位为秒。 a ●disp ·在命令窗口显示字符串
l KbName • 实现键盘按键数字码和所表示的按键名称 之间的转换。 l KbName(‘UnifyKeyNames’) • 可以使程序使用在Windows系统和Mac系 统下通用的按键 l WaitSecs • 等待给定的时间,单位为秒。 l disp • 在命令窗口显示字符串 %在命令窗口测试KbName
11 ListenChar (2); 12 while KbCheck;end Wait until all keys are released. 13 This is a loop that flips around doing anything as long as KbCheck 14 reports back that a key is pressed on the keyboard.Means that the 15s program doesn't continue until all keys have been released. ●ListenChar(2):监听除了Octave/MATLAB命令窗口以 外的按键行为 。m文件运行过程中记录到的按键不会显示在命令窗口 。ListenChar(O):恢复MATLAB命令窗口的监听状态,从 而可以执行命令窗口输入的命令
l ListenChar(2):监听除了Octave/MATLAB命令窗口以 外的按键行为 • m文件运行过程中记录到的按键不会显示在命令窗口 l ListenChar(0):恢复MATLAB命令窗口的监听状态,从 而可以执行命令窗口输入的命令