-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfindOffset_nonius_fixation.m
206 lines (167 loc) · 6.49 KB
/
findOffset_nonius_fixation.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
function [vertOffsets,horiOffsets] = findOffset_nonius_fixation(subject, session, debug)
%%%%%%%%%%%%%%%%%%%
% BASIC SETTINGS
%%%%%%%%%%%%%%%%%%%
%%%% resolution
if debug == 1
SetResolution(max(Screen('Screens')), 1280,1024,85);
else
SetResolution(max(Screen('Screens')),1280,1024,85);
end
experiment.runNum = input('Run number :');
%%%% keyboards
[keyboardIndices, productNames, ~] = GetKeyboardIndices ;
deviceNumber = keyboardIndices(1);
%%%% input this at the beginning of the scan session for 7T
ex.vertOffsetL = 0; % vertical offset
ex.horiOffsetL = 0;
ex.vertOffsetR = 0; % vertical offset
ex.horiOffsetR = 0;
% scSize.screenDeg = 14; % pRF screen size
ex.screenDegY = 8; %figSizeDeg;
ex.screenDegX = 16; %figSizeDeg*3;%9; % pRF screen size
% scSize.centerDeg = 4; % center circle size in diameter
% scSize.surroundDeg = 12; % surround circle size in diameter
%%%% scales all of the stimuli in DVA to the screensize
ex.screenWidth = 40; % in cm; laptop=27.5, office=43, 3Tb=19, 7T=17, miniHelm=39;
ex.viewingDist = 46; % in cm; 3Tb/office=43, 7T=48, miniHelm=57;
ex.backgroundColor = [128 128 128]; % color
ex.boxColor = ex.backgroundColor * .7;
%%%% Fixation
ex.littleFixDeg = .2; % in degrees, the size of the biggest white dot in the fixation
ex.bigFixSizeDeg = 0.5;
ex.outerFixPixels = 2; % in pixels, the black ring around fixation
%%%% Nonius lines
ex.lineHdeg = 0.4;
ex.lineWdeg = 0.06;
%%% horizontal line
ex.horiLineWdeg = 0.7;
%%%% response listening - so we don't read in scanner triggers!
responseKeys = zeros(1,256);
responseKeys(KbName('1'))=1; % button box 1
responseKeys(KbName('2'))=1; % button box 2
responseKeys(KbName('3'))=1; % button box 3
responseKeys(KbName('4'))=1; % button box 3
responseKeys(KbName('Enter'))=1; % button box 3
%%%%%%%%%%%%%%%%
% OPEN SCREEN
%%%%%%%%%%%%%%%%
HideCursor;
Priority(9); % highest priority
%%%% open screen
Screen('Preference', 'SkipSyncTests', 1);
screen=max(Screen('Screens'));
[w, rect]=Screen('OpenWindow',screen,180,[],[],[],[],[],kPsychNeed32BPCFloat);
Screen(w, 'TextSize', 32);
% xc = rect(3)/2;
% yc = rect(4)/2;
%Load the gamma table of the specified screen
load("phase2_photometry.mat");
Screen('LoadNormalizedGammaTable', w, inverseCLUT);
%%%% scale the stims for the screen
ex.ppd = pi* rect(3) / (atan(ex.screenWidth/ex.viewingDist/2)) / 360;
ex.fixSize = round(ex.littleFixDeg*ex.ppd);
ex.screenX = ex.screenDegX*ex.ppd;
ex.screenY = ex.screenDegY*ex.ppd;
%%%% Fixation dot
% ex.yFixOffset = 3*ex.ppd;
KbQueueCreate(deviceNumber,responseKeys);
%%%% find center Y
Screen('FillRect',w,ex.backgroundColor)
text = 'Find CENTER Y. \n\n 1 = Left Up, 2 = Left Down, \n\n 3 = Right Up, 4: Right Down, \n\n Enter: Accept\n\nPress any button to start';
width = RectWidth(Screen('TextBounds',w,text));
DrawFormattedText(w, text, 'center', 'center');
Screen(w, 'Flip', 0);
WaitSecs(1); KbPressWait; KbQueueFlush();
%%%%%%%%
% RUN
%%%%%%%%
while 1
% xS = rect(3)/2+ex.horiOffset;
% yS = rect(4)/2+ex.vertOffset;
xcL = rect(3)/2+ex.horiOffsetL;
xcR = rect(3)/2+ex.horiOffsetR;
ycL = rect(4)/2+ex.vertOffsetL;
ycR = rect(4)/2+ex.vertOffsetR;
KbQueueStart();
Screen('DrawDots', w, [xcR*3/2 ycR], ex.fixSize, [255 255 255], [], 2); %Right dot
% Screen('DrawLines', w, [xlineLl, xlineLr; ylineLBot, ylineLTop], ex.lineW, [255 255 255]);
% Screen('DrawLines', w, [xlineRl, xlineRr; ylineRBot, ylineRTop], ex.lineW, [255 255 255]);
% Screen('DrawLines', w, [xhorilineLl, xhorilineLr; yhoriline, yhoriline],ex.lineW, [255 255 255]);
% Screen('DrawLines', w, [xhorilineRl, xhorilineRr; yhoriline, yhoriline], ex.lineW, [255 255 255]);
%%%% FLIP
Screen(w, 'Flip', 0);
%%%% check for responses
[pressed, firstPress]= KbQueueCheck();
if find(firstPress,1) == KbName('1')
ex.vertOffsetL = ex.vertOffsetL - 5;
KbQueueFlush();
Screen('DrawDots', w, [xcL/2 ycL], ex.fixSize, [255 255 255], [], 2); %Left dot
elseif find(firstPress,1) == KbName('2')
ex.vertOffsetL = ex.vertOffsetL + 5;
KbQueueFlush();
Screen('DrawDots', w, [xcL/2 ycL], ex.fixSize, [255 255 255], [], 2); %Left dot
elseif find(firstPress,1) == KbName('3')
ex.vertOffsetR = ex.vertOffsetR - 5;
KbQueueFlush();
elseif find(firstPress,1) == KbName('4')
ex.vertOffsetR = ex.vertOffsetR + 5;
KbQueueFlush();
elseif find(firstPress,1) == KbName('Enter')
break;
KbQueueFlush();
end
end
vertOffsets = [ex.vertOffsetL; ex.vertOffsetR];
Screen('FillRect',w,ex.backgroundColor)
text = 'Find CENTER X. \n\n 1 = Left left, 2 = Left right, \n\n 3 = Right left, 4: Right right,\n\n Enter: Accept\n\nPress any button to start';
width = RectWidth(Screen('TextBounds',w,text));
DrawFormattedText(w, text, 'center', 'center');
Screen(w, 'Flip', 0);
WaitSecs(1); KbPressWait; KbQueueFlush();
while 1
xcL = rect(3)/2+ex.horiOffsetL;
ycL = rect(4)/2+ex.vertOffsetL;
xcR = rect(3)/2+ex.horiOffsetR;
ycR = rect(4)/2+ex.vertOffsetR;
KbQueueStart();
%%%% draw screen square
Screen('DrawDots', w, [xcR*3/2 ycR], ex.fixSize, [255 255 255], [], 2);
%%%% FLIP
Screen(w, 'Flip', 0);
%%%% check for responses
[pressed, firstPress]= KbQueueCheck();
if find(firstPress,1) == KbName('1')
ex.horiOffsetL = ex.horiOffsetL - 5;
KbQueueFlush();
Screen('DrawDots', w, [xcL/2 ycL], ex.fixSize, [255 255 255], [], 2);
elseif find(firstPress,1) == KbName('2')
ex.horiOffsetL = ex.horiOffsetL + 5;
KbQueueFlush();
Screen('DrawDots', w, [xcL/2 ycL], ex.fixSize, [255 255 255], [], 2);
elseif find(firstPress,1) == KbName('3')
ex.horiOffsetR = ex.horiOffsetR - 5;
KbQueueFlush();
elseif find(firstPress,1) == KbName('4')
ex.horiOffsetR = ex.horiOffsetR + 5;
KbQueueFlush();
elseif find(firstPress,1) == KbName('Enter')
break;
KbQueueFlush();
end
end
horiOffsets = [ex.horiOffsetL; ex.horiOffsetR];
%%%%%%%%%%%%%%%%%%
% DONE! WRAP UP
%%%%%%%%%%%%%%%%%%
KbQueueRelease();
ShowCursor;
Screen('Close');
Screen('CloseAll');
% save
% savedir = fullfile(pwd,'data',subject,session,'findOffset_figureGround');
% if ~exist(savedir); mkdir(savedir); end
% savename=fullfile(savedir, strcat(subject,'_screenSize.mat'));
% save(savename,'ex')
%
% end