-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetUp.m
More file actions
106 lines (87 loc) · 3.59 KB
/
setUp.m
File metadata and controls
106 lines (87 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
function [globals] = setUp(globals)
%% Open the PsychToolbox window
[globals.window, globals.windowRect] = PsychImaging(...
'OpenWindow', 0, globals.grey);
%% Default setup
PsychDefaultSetup(2);
%% Retrieve the maximum priority number and set the execution priority
topPriorityLevel = MaxPriority(globals.window);
Priority(topPriorityLevel);
%% Last argument below:
% ... 0: Don't skip the sync-test
% ... 2: Skip the sync-test
Screen('Preference','SkipSyncTests', 0);
%% Set up alpha-blending for smooth (anti-aliased) lines
Screen('BlendFunction', globals.window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
%% Load the stimulus textures
for iStim = 1:size(globals.StimTable,1)
% Typicals
fn = globals.StimTable.imgPath_Typical{iStim};
[Img,~,Alpha] = imread(fn);
Img = imresize(Img,[globals.stimWidth,globals.stimWidth],...
'Method','bicubic','Antialiasing',true);
Alpha = imresize(Alpha,[globals.stimWidth,globals.stimWidth],...
'Method','bicubic','Antialiasing',true);
Img = cat(3, Img, Alpha);
globals.StimTable.textureIdx_Typical(iStim) = Screen('MakeTexture', ...
globals.window, Img);
% Oddballs
fn = globals.StimTable.imgPath_Oddball{iStim};
[Img,~,Alpha] = imread(fn);
Img = imresize(Img,[globals.stimWidth,globals.stimWidth],...
'Method','bicubic','Antialiasing',true);
Alpha = imresize(Alpha,[globals.stimWidth,globals.stimWidth],...
'Method','bicubic','Antialiasing',true);
Img = cat(3, Img, Alpha);
globals.StimTable.textureIdx_Oddball(iStim) = Screen('MakeTexture', ...
globals.window, Img);
end
%% Load the number textures
globals.textures.numbers = nan(100,1);
for ii = 1:numel(globals.textures.numbers)
num = ii - 1;
fn = fullfile('.', 'Imgs', 'CountTask', ...
sprintf('%03d.png', num));
Img = imread(fn);
globals.textures.numbers(ii) = Screen('MakeTexture', ...
globals.window, Img);
end
%% Load the arrow texture
fn = fullfile('.', 'Imgs', 'CountTask', 'Arrow.png');
Img = imread(fn);
globals.textures.arrow = Screen('MakeTexture', globals.window, Img);
%% Set the xy co-ords
% Get the screen dimensions
[nX, nY] = Screen('WindowSize', globals.window);
globals.dimScrn = [nX, nY];
% Get the centre + edge coordinates for the window
[x,y] = RectCenter(globals.windowRect);
globals.xyCentreScrn = [x;y];
globals.xyEdgesScrn = Screen('Rect', globals.window);
% Get the edge coordinates for the stimuli
globals.xyEdgesStim = CenterRectOnPoint(...
[0, 0, globals.stimWidth, globals.stimWidth],...
globals.xyCentreScrn(1), globals.xyCentreScrn(2));
% Get the edge coordinates for centrally presented numbers
globals.xyEdgesNumMid = CenterRectOnPoint(...
[0, 0, globals.numMidWidth, globals.numMidWidth],...
globals.xyCentreScrn(1), globals.xyCentreScrn(2));
% Get the edge coordinates for a centrally presented number frame
globals.xyEdgesFrameMid = globals.xyEdgesNumMid + ...
globals.frameMarginNumMid;
% Get the edge coordinates for the flanking numbers
globals.xyEdgesNumLeft = CenterRectOnPoint(...
[0, 0, globals.numFlankWidth, globals.numFlankWidth],...
globals.xyCentreScrn(1) - globals.numFlankOffset, ...
globals.xyCentreScrn(2));
globals.xyEdgesNumRight = CenterRectOnPoint(...
[0, 0, globals.numFlankWidth, globals.numFlankWidth],...
globals.xyCentreScrn(1) + globals.numFlankOffset, ...
globals.xyCentreScrn(2));
%% Hide cursor from screen
HideCursor(globals.window);
%% Set the inter-frame interval
globals.ifi = Screen('GetFlipInterval', globals.window);
%% Get an initial screen flip for timing
globals.t = Screen('Flip', globals.window);
return