|
1 | 1 | function devSandbox |
2 | 2 |
|
| 3 | +% This script is a stand-alone function that can be useful as a sandbox to |
| 4 | +% develop the PTB audio/visual stimulation of your experiment. No input/output |
| 5 | +% recquired. |
| 6 | +% |
| 7 | +% Here, a tutorial from https://peterscarfe.com/contrastgratingdemo.html is |
| 8 | +% provided for illustrative purpose (notice that some vars' name are updated |
| 9 | +% to our code style). |
| 10 | +% |
| 11 | +% It is composed of two parts: |
| 12 | +% - a fixed structure that will initialize and close PTB in 'debug mode' |
| 13 | +% (`PsychDebugWindowConfiguration`, `SkipSyncTests`) |
| 14 | +% - the actual sandbox where to set your dynamic vars (the stimualtion |
| 15 | +% parameters) and the 'playground' where to develop the stimulation code |
| 16 | +% |
| 17 | +% When you are happy with it, ideally you will move the vars in `setParameters.m` |
| 18 | +% and the stimulation code in a separate function in `my-experiment-folder/subfun`. |
| 19 | +% The code style and vars name is the same used in `cpp-lln-lab/CPP_PTB` |
| 20 | +% github repo, therefore it should be easy to move everything in your experiment |
| 21 | +% scripts (see the template that is annexed in `cpp-lln-lab/CPP_PTB`) |
| 22 | + |
| 23 | + |
3 | 24 | cfg = struct; |
4 | 25 |
|
5 | 26 | cfg.backgroundColor = [ 127 127 127 ]; |
6 | 27 |
|
7 | 28 | cfg = devSandbox_initPTB(cfg); |
8 | 29 |
|
9 | | - |
| 30 | +%% |
10 | 31 | % ------------------------------------------------------------------------- |
11 | 32 | % -------------------------- SET YOUR VARS HERE --------------------------- |
12 | 33 | % ------------------------------------------------------------------------- |
|
35 | 56 | waitframes = 1; |
36 | 57 |
|
37 | 58 | % ------------------------------------------------------------------------- |
| 59 | +%% |
38 | 60 |
|
39 | 61 | try |
40 | | - |
| 62 | + |
| 63 | +%% |
41 | 64 | % ------------------------------------------------------------------------- |
42 | 65 | % ------------------------------ PLAYGROUND ------------------------------- |
43 | 66 | % ------------------------------------------------------------------------- |
|
60 | 83 |
|
61 | 84 | % Make a two layer mask filled with the background colour |
62 | 85 | mask = ones(1, numel(x), 2) * grey; |
63 | | - |
| 86 | + |
64 | 87 | % Place the grating in the 'alpha' channel of the mask |
65 | 88 | mask(:, :, 2)= grating .* contrast; |
66 | 89 |
|
|
123 | 146 | end |
124 | 147 |
|
125 | 148 |
|
126 | | - |
| 149 | + |
127 | 150 | % ------------------------------------------------------------------------- |
128 | | - |
| 151 | +%% |
129 | 152 |
|
130 | 153 | devSandbox_cleanUp |
131 | | - |
| 154 | + |
132 | 155 | catch |
133 | | - |
| 156 | + |
134 | 157 | devSandbox_cleanUp |
135 | 158 | psychrethrow(psychlasterror); |
136 | | - |
| 159 | + |
137 | 160 | end |
138 | 161 |
|
139 | 162 |
|
|
156 | 179 | cfg.screenNumber = max(cfg.screens); |
157 | 180 |
|
158 | 181 | % Open an on screen window |
159 | | -[cfg.window, cfg.windowRect] = PsychImaging('OpenWindow', cfg.screenNumber, cfg.backgroundColor); |
| 182 | +[cfg.window, cfg.windowRect] = Screen('OpenWindow', cfg.screenNumber, cfg.backgroundColor); |
160 | 183 |
|
161 | 184 | % Get the size of the on screen window |
162 | 185 | [cfg.screenXpixels, cfg.screenYpixels] = Screen('WindowSize', cfg.window); |
|
0 commit comments