BCIduino整理|psychtoolbox的最小demo案例

  • Psychtoolbox-3(PTB-3)是一个为MATLAB或GNU octave提供的免费函数集合,供神经科学和视觉研究人员使用。它合成并显示精确控制的视觉和听觉刺激,并与使用者进行交互。

  • 它目前至少有12000个活跃用户,不仅有一个活跃的论坛,而且有许多文章应用了它。

  • PTB-3基于PTB-2进一步研发完善成的,但是它的MATLAB扩展(在C中)被重写为更模块化的工具,并使用了OpenGL。 Psychtoolbox与许多用于编写心理学实验的备选工具箱一起提供,比如Python的psychy或JavaScript的jsPsych.

  • PTB-3是免费软件。它的大部分是在麻省理工学院的许可下发布的,但是其中的一部分是在其他开源和自由软件许可下发布的。

  • 这个demo是psychtoolbox的一个最小案例。它会打开一个屏幕并将其涂成灰色,它展示了使用者在启动程序时经常使用的步骤,即打开屏幕窗口。后续将会把psychtoolbox的其他内容也进行梳理并发出来。

% Clear the workspace and the screen
sca;
close all;
clearvars;

% Here we call some default settings for setting up Psychtoolbox
PsychDefaultSetup(2);

% Get the screen numbers. This gives us a number for each of the screens
% attached to our computer.
screens = Screen('Screens');

% To draw we select the maximum of these numbers. So in a situation where we
% have two screens attached to our monitor we will draw to the external
% screen.
screenNumber = max(screens);

% Define black and white (white will be 1 and black 0). This is because in general luminace values are defined between 0 and 1 with 255 steps in between. All values in Psychtoolbox are defined between 0 and 1

white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);

% Do a simply calculation to calculate the luminance value for grey. This will be half the luminace values for white
grey = white / 2;

% Open an on screen window using PsychImaging and color it grey.
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, grey);

% Now we have drawn to the screen we wait for a keyboard button press (any key) to terminate the demo.
KbStrokeWait;

% Clear the screen.
sca;

效果如下:
在这里插入图片描述

#本篇由BCIduino脑机接口开源社区整理(公众号“BCIduino脑机接口社区”)。BCIduino脑机接口社区由来自北京航空航天大学、康奈尔大学、北京大学、首都医科大学等硕博发起成立,欢迎扫下面码加入社群(如果码过期了,可以添加wechat:cheitech,要求加入),也欢迎采购BCIduino脑电模块(某宝搜索即可)。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/nvsirgn/article/details/108588206
今日推荐