|
4 | 4 |
|
5 | 5 | % as it is, it presents two example videos in succession |
6 | 6 |
|
7 | | - |
8 | 7 | % add parent directory to matlab path (so we can access the CPP_PTB functions) |
9 | 8 | addpath(fullfile(pwd, '..')); |
10 | 9 |
|
11 | 10 | %% start with a clean slate |
12 | 11 | clear; |
13 | 12 | clc; |
14 | 13 |
|
15 | | - |
16 | 14 | %% initialize PTB % This can def be improved by using other CPP_PTB functions% |
17 | 15 |
|
18 | | - % Skip the PTB sync test |
19 | | - Screen('Preference', 'SkipSyncTests', 2); |
| 16 | +% Skip the PTB sync test |
| 17 | +Screen('Preference', 'SkipSyncTests', 2); |
| 18 | + |
| 19 | +% Get the screen numbers and draw to the external screen if avaliable |
| 20 | +cfg.screen.idx = max(Screen('Screens')); |
20 | 21 |
|
21 | | - % Get the screen numbers and draw to the external screen if avaliable |
22 | | - cfg.screen.idx = max(Screen('Screens')); |
| 22 | +% Set the PTB window background manually |
| 23 | +cfg.color.background = [127 127 127]; |
23 | 24 |
|
24 | | - % Set the PTB window background manually |
25 | | - cfg.color.background = [127 127 127]; |
| 25 | +% Get the screen numbers and draw to the external screen if avaliable |
| 26 | +cfg.screen.idx = max(Screen('Screens')); |
26 | 27 |
|
27 | | - % Get the screen numbers and draw to the external screen if avaliable |
28 | | - cfg.screen.idx = max(Screen('Screens')); |
| 28 | +% Open an on screen window |
| 29 | +[cfg.screen.win, cfg.screen.winRect] = Screen('OpenWindow', cfg.screen.idx, cfg.color.background); |
29 | 30 |
|
30 | | - % Open an on screen window |
31 | | - [cfg.screen.win, cfg.screen.winRect] = Screen('OpenWindow', cfg.screen.idx, cfg.color.background); |
32 | | - |
33 | | - |
34 | 31 | %% Strcuture for video related info |
35 | 32 |
|
36 | | - % The name of your "video" and its images format |
37 | | - video.names = {'coffee','leaves'}; |
38 | | - |
39 | | - % The number of frames of your video you want to present |
40 | | - % If left empty, all available frames are taken |
41 | | - video.frame.numbers = []; |
42 | | - % video.frame.numbers = 30; |
43 | | - % video.frame.numbers = [30,15]; |
| 33 | +% The name of your "video" and its images format |
| 34 | +video.names = {'coffee', 'leaves'}; |
44 | 35 |
|
45 | | - % The format fo the images |
46 | | - video.frame.format = '.jpeg'; % can be any img format compatible with the "imread" function |
| 36 | +% The number of frames of your video you want to present |
| 37 | +% If left empty, all available frames are taken |
| 38 | +video.frame.numbers = []; |
| 39 | +% video.frame.numbers = 30; |
| 40 | +% video.frame.numbers = [30,15]; |
47 | 41 |
|
48 | | - % the folder where the images are (from the current folder) |
49 | | - video.stimuli.folder = 'stimuli/'; |
| 42 | +% The format fo the images |
| 43 | +video.frame.format = '.jpeg'; % can be any img format compatible with the "imread" function |
50 | 44 |
|
51 | | - % The frame rate at which you want to present your video |
52 | | - video.frame.rate = 29.97; |
| 45 | +% the folder where the images are (from the current folder) |
| 46 | +video.stimuli.folder = 'stimuli/'; |
53 | 47 |
|
54 | | - % Time bw videos in s |
55 | | - video.isi = 1; |
| 48 | +% The frame rate at which you want to present your video |
| 49 | +video.frame.rate = 29.97; |
| 50 | + |
| 51 | +% Time bw videos in s |
| 52 | +video.isi = 1; |
56 | 53 |
|
57 | | - |
58 | 54 | %% present the videos in a loop |
59 | 55 |
|
60 | | - for trial = 1:length(video.names) |
61 | | - |
| 56 | +for trial = 1:length(video.names) |
| 57 | + |
62 | 58 | % select name and folder where current video is |
63 | 59 | video.name = video.names{trial}; |
64 | | - video.path = fullfile(video.stimuli.folder,video.name); |
65 | | - |
66 | | - |
| 60 | + video.path = fullfile(video.stimuli.folder, video.name); |
| 61 | + |
67 | 62 | % how many frames are going to be presented |
68 | 63 | if numel(video.frame.numbers) < 1 |
69 | | - video.frame.number = size(dir([video.path,'/*',video.frame.format]),1); |
70 | | - |
| 64 | + video.frame.number = size(dir([video.path, '/*', video.frame.format]), 1); |
| 65 | + |
71 | 66 | elseif numel(video.frame.numbers) > 1 |
72 | 67 | video.frame.number = video.frame.numbers(trial); |
73 | | - |
| 68 | + |
74 | 69 | else |
75 | 70 | video.frame.number = video.frame.numbers; |
76 | 71 | end |
77 | | - |
78 | | - |
| 72 | + |
79 | 73 | % Read the images and create the stucture with their textures |
80 | 74 | [video, cfg] = createFramesTextureStructure(video, cfg); |
81 | 75 |
|
82 | 76 | % Play the video |
83 | 77 | playVideoFrames(video, cfg); |
84 | | - |
| 78 | + |
85 | 79 | % ISI (better would be to use Flip) |
86 | 80 | WaitSecs(video.isi); |
87 | | - |
88 | | - end |
89 | 81 |
|
| 82 | +end |
90 | 83 |
|
91 | | - % The end |
92 | | - sca; |
| 84 | +% The end |
| 85 | +sca; |
0 commit comments