1 / 12

Psychtoolbox Stimulus presentation for psychophsyical experiments

Psychtoolbox Stimulus presentation for psychophsyical experiments. What is PTB? Getting started with PTB Why use PTB? Questions. What is Psychtoolbox?. Just like Cogent, PTB is a toolbox inside Matlab for programming stimulus presentation and psychophysical experiments.

pelham
Download Presentation

Psychtoolbox Stimulus presentation for psychophsyical experiments

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Psychtoolbox Stimulus presentation for psychophsyical experiments What is PTB? Getting started with PTB Why use PTB? Questions

  2. What is Psychtoolbox? Just like Cogent, PTB is a toolbox inside Matlab for programming stimulus presentation and psychophysical experiments. In a way, it is just a different language from Cogent, so you will need to learn different commands. PTB is very widely used, especially in the field of visual psychophysics, and there is a lot of documentation and knowledge around. http://psychtoolbox.org

  3. Getting started with PTB In PTB, almost all commands pertaining to what is happening on the computer screen are called through the command Screen. Basically, it works in this way: Screen('SomeCommand', Parameters, ...) There is an extensive help documentation for most commands. You can find that by typing Screen followed by the command name and a question mark: Screen Flip? Will give you a detailed explanation of how to use the 'Flip' command.

  4. Opening a window Before you can do anything else on the display, you have to open a main window. This way you can also define parameters like the background colour or resolution. [Win, Rect] = Screen('OpenWindow', 0, [127 127 127], [0 0 800 600]) Window and texture dimensions are defined as a 1 x 4 vector: [X Y Width Height] PTB's coordinate system has 0,0 in the upper left-hand corner. Screen number Background colour Window dimensions

  5. Drawing geometric shapes etc Once PTB has opened its main window you can draw into it. There is a back buffer onto which everything is drawn, so that things will only become visible when you flip the buffers: Screen('FillOval', Win, [255 0 0], [0 0 10 10]); Screen('Flip', Win); Colours are defined by a 1 x 3 vector (for red, green and blue), with numbers in the range between 0-255. So [255 0 0] is bright red. Other commands for drawing are: FillRect, FillPoly, FillArc, DrawLine, DrawText, ...

  6. Centring something in the middle of the window Because the 0,0 coordinate is in the corner, but we usually want to draw things in the centre of the screen, there is a helpful function for calculating the centre: CentralRect = CenterRect([0 0 800 600], [0 0 1440 900]) Since you normally want the centre of the screen you can use the Rect of your main window: CentralRect = CenterRect([0 0 800 600], Rect)

  7. Using textures You can make full use of graphics accelerators by loading your images into “textures”: img = imread('Picture.jpg'); Texture = Screen('MakeTexture', Win, img); This texture can then be drawn very quickly, even while applying serious transformations to it, such as resizing or rotations: Screen('DrawTexture', Win, Texture); Screen('DrawTexture', Win, Texture, imgRect, CenterRect(imgRect*2, Rect)); (The latter command draws the image at twice its size in the centre of the screen.)

  8. Closing the window etc Finally, when your program is finished you need to shut down the window: Screen('CloseAll') As a side note, you can switch on and off the mouse pointed by using: ShowCursor HideCursor

  9. Keyboard input You can read key presses by using the command: [KeyDown, Time, Keys] = KbCheck; This will return in Keys a 1 x 256 vector containing whether the various keys (labelled 0-255) have been pressed or not. If you want the program to wait until a key press you need to use: KbWait; [KeyDown, Time, Keys] = KbCheck;

  10. Time & Delays You can ask the computer to wait for a number of seconds by using: WaitSecs(5); You can ask it for the current time on the computer's internal clock with: CurrentTime = GetSecs;

  11. Why use Psychtoolbox? PTB is very anal about timing, so if accurate timing is important in your experiment PTB is good for that. Because PTB using graphics acceleration you can use very fast drawing without any pixelation and other image processing artifacts. Lots of people in the world use it so it's easy to get help.

  12. Why not to use Psychtoolbox? If you are running fMRI experiments, you will need to program how the stimuli are triggered by the scanner by setting up the ports etc yourself. Cogent has convenient scripts built in for counting slices. Moreover, if you are scanning at the FIL, support staff can only help you with Cogent. However, it is possible to use both toolboxes in parallel, so for example you could use Cogent for triggering the experiment, but PTB for the actual stimulus presentation and keyboard input.

More Related