MATLABのコードって忘れやすい・・・

プログラムのコマンドなんて忘れやすいもの・・・いっそのことネット上に保存してシェアしましょう!!
It's easy to forget command for MATLAB in programming.... Let's share small help for Matlab code with you on the web!!



2013年12月2日月曜日

Psychotoolboxを使う

最近使い始めた心理実験やfMRI・EEG実験に用いる視聴覚刺激を作成するMATLABのツールボックス、Psychotoolboxについての防備録。

(DLの方法など詳細については、ググってください)

  1. Screen関数について

    [VBLTimestamp StimulusOnsetTime FlipTimestamp Missed Beampos] = Screen('Flip', windowPtr [, when] [, dontclear] [, dontsync] [, multiflip]);

    事前にセットされた描画情報を表示する。
    windowPtr: window番号を入力する。windowPtr = Screen('Open',0,0)などで得られる。"windowPtr" is the id of the onscreen window whose content should be shown at
    flip time.

    when: "when" specifies when to flip: If set to zero (default), it will flip
    on the next possible video retrace. If set to a value when > 0, it will flip at
    the first video retrace after system time 'when' has been reached.

    dontclear: "dontclear" If set to 1, flip will not clear the framebuffer after Flip - this allows
    incremental drawing of stimuli. The default is zero, which will clear the
    framebuffer to background color after each flip. A value of 2 will prevent Flip
    from doing anything to the framebuffer after flip. This leaves the job of
    setting up the buffer to you - the framebuffer is in an undefined state after
    flip.

    dontsync: "dontsync" If set to zero (default), Flip will sync to the vertical
    retrace and will pause execution of your script until the Flip has happened. If
    set to 1, Flip will still synchronize stimulus onset to the vertical retrace,
    but will *not* wait for the flip to happen: Flip returns immediately and all
    returned timestamps are invalid. A value of 2 will cause Flip to show the
    stimulus *immediately* without waiting/syncing to the vertical retrace.

    multiflip: "multiflip" defaults to zero: If set to a value greater than zero, Flip will
    flip *all* onscreen windows instead of just the specified one. This allows to
    synchronize stimulus onset on multiple displays, e.g., for multidisplay stereo
    setups or haploscopes. You need to (somehow) synchronize all attached displays
    for this to operate tear-free. Flip (optionally) returns a high-precision
    estimate of the system time (in seconds) when the actual flip has happened in
    the return argument


    ex) fixation point と barを表示

    %凝視点の線分座標
    FixationXY =...
          [-20, 20,  0,  0;
             0, 0, -20, 20];

    AttentionBarXY =...
          [-390, -390, 390, 390;
           30,  -30,  30, -30];

    Screen('DrawLines', win, FixationXY, 2, [255 0 0], [centerX, centerY]);
    Screen('DrawLines', win, AttentionBarXY, 3, [255 255 255], [centerX, centerY]);
    Screen('Flip', win);