Memorandums

知覚・認知心理学の研究と教育をめぐる凡庸な日々の覚書

PsychToolBox 心理実験サンプル

2005-06-22 | PsychToolBox
PsychToolBox 心理実験サンプル

>>help psychdemos
によって、かなりのサンプルを参照できる。基本的なものには*印が付されている。
ただし、刺激作成、提示、反応入力、記録(出力)という実験の全体を概観するにはやや不適かと思われる。
そのためには、

>>help Psychtoolbox:PsychContributed
の中の、
>>edit MinimalExample
>>MinimalExample
を実行してみるとよい。(前者がコード画面表示、後者が実行)
刺激作成、提示(時間制御)、反応記録(RT)が簡単に概観できる。
以下に、その一部を転載(画面を3s 提示)。
%以下はコメントで実行には関係しない。またコピーとペースで改行などの情報が混入することがあり、以下をそのままテキスト編集してm-fileに(拡張子.mで)保存しても、エラーがでることがあるので、実際のサンプルを直接参照、実行してほしい。
-----
clear all;

pixelSize = 8; % You might change to 32 if 8 is not working, depending on OS9 or Windows.
[w, screenRect] = Screen(0,'OpenWindow',[],[],pixelSize); % Define your output screen as your monitor which is screen 0.
black=BlackIndex(w); % Value depends on pixelSize.
white=WhiteIndex(w); % "

scr_one = Screen(w, 'OpenOffscreenWindow',black, screenRect); % Define scr_one, a black screen not yet visible.
screen(scr_one,'FillOval',white,[10,10,90,90]); % Draw a white circle on scr_one.
screen(scr_one,'DrawText','White circle, diameter 80 pixels. Presented for 3 seconds.',10,150,white); % Draw text on scr_one.

scr_two = Screen(w, 'OpenOffscreenWindow',black, screenRect); % Same for scr_two as scr_one.
screen(scr_two,'FillRect',(black+white)/2,centerRect([0 0 100 50],screenRect)); % Draw rectangle to scr_two.
screen(scr_two,'DrawText','Middle-gray rectangle, 100 x 50 pixels. Press any key to continue.',50,200,(black+white)/2);

scr_blank = Screen(w, 'OpenOffscreenWindow',black, screenRect); % scr_blank is just a black screen.

% Scr_one for 3 seconds.
Screen(w,'WaitBlanking'); % Wait for vertical sync signal before copying screen to monitor, not necessary.
Screen('CopyWindow',scr_one,w); % Copy scr_one to monitor.
starttime1 = GetSecs; % Record CPU time at this point.
while GetSecs-starttime1 <3 % Minimal while-loop that lets almost exactly 3 seconds pass. end
finishtime1 = GetSecs;
-----
コメント    この記事についてブログを書く
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする
« MATLAB 0 起動と終了、特徴... | トップ | PsychToolBox  画面制御 »

コメントを投稿

ブログ作成者から承認されるまでコメントは反映されません。

PsychToolBox」カテゴリの最新記事