forked from martina-p/volleyball-task
-
Notifications
You must be signed in to change notification settings - Fork 0
/
psychExpInit.m
87 lines (69 loc) · 3.16 KB
/
psychExpInit.m
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
%% PTB parameters
% Screen Preferences
Screen('Preference', 'VBLTimestampingMode', 3);%Add this to avoid timestamping problems
Screen('Preference', 'DefaultFontName', 'Geneva');
Screen('Preference', 'DefaultFontSize', 20); %fontsize
Screen('Preference', 'DefaultFontStyle', 0); % 0=normal,1=bold,2=italic,4=underline,8=outline,32=condense,64=extend,1+2=bold and italic.
Screen('Preference', 'DefaultTextYPositionIsBaseline', 1); % align text on a line
% Colors definition
white = [255 255 255];
black = [0 0 0];
red= [255 0 0];
% Keyboard parameters
KbName('UnifyKeyNames');
keyLeft=KbName('leftArrow');
keyRight=KbName('rightArrow');
% Start PTB
screens=Screen('Screens');
Screen('Preference', 'SkipSyncTests', 2);
screenNumber=max(screens); % Main screen
[win,winRect] = Screen('OpenWindow',screenNumber,black);
HideCursor;
%% Load instruction slides
slide1=imread(fullfile('Stimfiles', 'Slide1.bmp'));
texslide1 = Screen('MakeTexture', win, slide1);
%% Load stimuli
Lose=imread(fullfile('Stimfiles', 'Lose.png'));
texLose = Screen('MakeTexture', win, Lose);
Win=imread(fullfile('Stimfiles', 'Win.png'));
texWin = Screen('MakeTexture', win, Win);
Play=imread(fullfile('Stimfiles', 'Play.png'));
texPlay = Screen('MakeTexture', win, Play);
Pause=imread(fullfile('Stimfiles', 'Pause.png'));
texPause = Screen('MakeTexture', win, Pause);
%% Stimuli size & positions
%Play
[imageHeight, imageWidth, colorChannels] = size(Play);
imagePlay = [0 0 imageWidth imageHeight];
imagePlay = [0 0 imageWidth./15 imageHeight./15];
%Pause
[imageHeight, imageWidth, colorChannels] = size(Pause);
imagePause = [0 0 imageWidth./15 imageHeight./15];
%Win
[imageHeight, imageWidth, colorChannels] = size(Win);
imageWin = [0 0 imageWidth./10 imageHeight./10];
%Lose
[imageHeight, imageWidth, colorChannels] = size(Win);
imageLose = [0 0 imageWidth imageHeight];
imageLose = [0 0 imageWidth./10 imageHeight./10];
%xc = winRect(3)/2;
%yc = winRect(4)/2;
[xc, yc] = RectCenterd(winRect); %get center coordinates
xcOffsetLeft = xc-150; %position left image
xcOffsetRight = xc+150; %position right image
%Play on the left, Pause on the right
imageRectPlayLeft = [xcOffsetLeft, yc, xcOffsetLeft+(imagePlay(:,3)) yc+(imagePlay(:,4))];
imageRectPauseRight = [xcOffsetRight, yc, xcOffsetRight+(imagePause(:,3)), yc+(imagePause(:,3))];
%Pause on the left, Play on the right
imageRectPlayRight = [xcOffsetRight, yc, xcOffsetRight+(imagePlay(:,3)), yc+(imagePlay(:,3))];
imageRectPauseLeft = [xcOffsetLeft, yc, xcOffsetLeft+(imagePause(:,3)), yc+(imagePause(:,3))];
%Win Center position
imageWin = [xc, yc, xc+imageWin(:,3), yc+imageWin(:,4)];
%Lose Center position
imageLose = [xc, yc, xc+imageLose(:,3), yc+imageLose(:,4)];
%Fixation cross
crossLength=10;
crossColor=white;
crossWidth=3;
crossLines=[-crossLength, 0; crossLength, 0; 0, -crossLength; 0, crossLength];
crossLines=crossLines';