-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwoItemGARP.m
517 lines (482 loc) · 17.5 KB
/
twoItemGARP.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
function [ output_args ] = twoItemGARP( item1, item2, item3, item4, amountOfItem1, amountOfItem2, amountOfItem3, amountOfItem4, w )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
screenNumber = max(Screen('Screens'));
[width height] = Screen('WindowSize', screenNumber);
%% Defaults --- If input arguments are not provided, these gives the default values
if exist('item1','var') == 0;
item1 = imread('vjuice.jpg');
end
if exist('item2','var') == 0;
item2 = imread('icedtea.jpg');
end
if exist('item3','var') == 0;
item3 = imread('pretzel.jpg');
end
if exist('item4','var') == 0;
item4 = imread('milk.jpg');
end
if exist('amountOfItem1','var') == 0; % If 'amountOfItem1' doesn't exist . . .
amountOfItem1 = 1; % Create it and set it equal to 1 (default)
end
if exist('amountOfItem2','var') == 0;
amountOfItem2 = 5;
end
if exist('amountOfItem3','var') == 0;
amountOfItem3 = 5;
end
if exist('amountOfItem4','var') == 0;
amountOfItem4 = 6;
end
if exist('w','var') == 0;
w = Screen(screenNumber, 'OpenWindow',[],[],[],[]);
end
black = imread('black.jpg');
grey = imread('grey.jpg');
%% Make all of the tesxtures
item1t = Screen('MakeTexture',w,item1);
item2t = Screen('MakeTexture',w,item2);
item3t = Screen('MakeTexture',w,item3);
item4t = Screen('MakeTexture',w,item4);
blackt = Screen('MakeTexture',w,black);
greyt = Screen('MakeTexture',w,grey);
%% These are all of the position constants
centerw = width/2; % This the center width of the screen
centerh = height/2; % THe center of the height of the screen
eccen = 150; % This is the eccentricity. Distance from the center to the right edge of the array
itemw = 70; % The width of one item in the array
itemh = 1.5*itemw;% The hight of one item in the array
gutterw = 20; % The width of the gutters between the items
gutterh = 20; % The hight of the gutters between the items
devLineHeight = height*.9; % The height of the black box inthe middle of the screen
devLineWidth = 1; % The width of the black box in the middle of the screen
% EVerything below here is codded in terms of the numbers above
pwl1= centerw - eccen;
pwl2= pwl1 - itemw;
pwl3= pwl2 - gutterw;
pwl4= pwl3 - itemw;
pwl5= pwl4 - gutterw;
pwl6= pwl5 - itemw;
pwl7= pwl6 - gutterw;
pwl8= pwl7 - itemw;
pwr1= centerw + eccen;
pwr2= pwr1 + itemw;
pwr3= pwr2 + gutterw;
pwr4= pwr3 + itemw;
pwr5= pwr4 + gutterw;
pwr6= pwr5 + itemw;
pwr7= pwr6 + gutterw;
pwr8= pwr7 + itemw;
ph1= centerh - (gutterh + 1.5*itemh);
ph2= ph1 + itemh;
ph3= ph2 + gutterh;
ph4= ph3 + itemh;
ph5= ph4 + gutterh;
ph6= ph5 + itemh;
% These are here so that the cat()'s will have something to grab on to.
draw = [];
leftPositions = [];
topPositions = [];
rightPositions = [];
bottomPositions = [];
% The line that devides the the screen in half
draw = cat(1,draw,blackt);
leftPositions = cat(2,leftPositions, centerw - devLineWidth);
topPositions = cat(2,topPositions, centerh - devLineHeight/2);
rightPositions = cat(2,rightPositions, centerw + devLineWidth);
bottomPositions = cat(2,bottomPositions,centerh + devLineHeight/2);
% Left
% Box 1l
if amountOfItem1 >= 1; %If there is suposed to be one or more item(s) on the left, Add all on the numbers that we need to add so that a image will be drawn in the 1 position
draw = cat(1,draw,item1t);
leftPositions = cat(2,leftPositions, pwl4);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwl3);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 2L
if amountOfItem1 >= 2;
draw = cat(1,draw,item1t);
leftPositions = cat(2,leftPositions, pwl2);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwl1);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 3L
if amountOfItem1 >= 3;
draw = cat(1,draw,item1t);
leftPositions = cat(2,leftPositions, pwl4);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwl3);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box 4L
if amountOfItem1 >= 4;
draw = cat(1,draw,item1t);
leftPositions = cat(2,leftPositions, pwl2);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwl1);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box 5L
if amountOfItem1 >= 5;
draw = cat(1,draw,item1t);
leftPositions = cat(2,leftPositions, pwl4);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwl3);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box 6L
if amountOfItem1 >= 6;
draw = cat(1,draw,item1t);
leftPositions = cat(2,leftPositions, pwl2);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwl1);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box 7L
if amountOfItem2 >= 1;
draw = cat(1,draw,item2t);
leftPositions = cat(2,leftPositions, pwl6);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwl5);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 8L
if amountOfItem2 >= 2;
draw = cat(1,draw,item2t);
leftPositions = cat(2,leftPositions, pwl8);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwl7);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 9L
if amountOfItem2 >= 3;
draw = cat(1,draw,item2t);
leftPositions = cat(2,leftPositions, pwl6);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwl5);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box10L
if amountOfItem2 >= 4;
draw = cat(1,draw,item2t);
leftPositions = cat(2,leftPositions, pwl8);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwl7);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box11L
if amountOfItem2 >= 5;
draw = cat(1,draw,item2t);
leftPositions = cat(2,leftPositions, pwl6);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwl5);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box12L
if amountOfItem2 >= 6;
draw = cat(1,draw,item2t);
leftPositions = cat(2,leftPositions, pwl8);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwl7);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Right
% Box 1r
if amountOfItem3 >= 1;
draw = cat(1,draw,item3t);
leftPositions = cat(2,leftPositions, pwr3);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwr4);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 2r
if amountOfItem3 >= 2;
draw = cat(1,draw,item3t);
leftPositions = cat(2,leftPositions, pwr1);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwr2);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 3r
if amountOfItem3 >= 3;
draw = cat(1,draw,item3t);
leftPositions = cat(2,leftPositions, pwr3);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwr4);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box 4r
if amountOfItem3 >= 4;
draw = cat(1,draw,item3t);
leftPositions = cat(2,leftPositions, pwr1);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwr2);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box 5r
if amountOfItem3 >= 5;
draw = cat(1,draw,item3t);
leftPositions = cat(2,leftPositions, pwr3);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwr4);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box 6r
if amountOfItem3 >= 6;
draw = cat(1,draw,item3t);
leftPositions = cat(2,leftPositions, pwr1);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwr2);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box 7r
if amountOfItem4 >= 1;
draw = cat(1,draw,item4t);
leftPositions = cat(2,leftPositions, pwr5);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwr6);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 8r
if amountOfItem4 >= 2;
draw = cat(1,draw,item4t);
leftPositions = cat(2,leftPositions, pwr7);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwr8);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 9r
if amountOfItem4 >= 3;
draw = cat(1,draw,item4t);
leftPositions = cat(2,leftPositions, pwr5);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwr6);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box10r
if amountOfItem4 >= 4;
draw = cat(1,draw,item4t);
leftPositions = cat(2,leftPositions, pwr7);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwr8);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box11r
if amountOfItem4 >= 5;
draw = cat(1,draw,item4t);
leftPositions = cat(2,leftPositions, pwr5);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwr6);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box12r
if amountOfItem4 >= 6;
draw = cat(1,draw,item4t);
leftPositions = cat(2,leftPositions, pwr7);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwr8);
bottomPositions = cat(2,bottomPositions, ph6);
end
%Greys
% Left
% Box 1l
if amountOfItem1 < 1; %If there is suposed to be one or more item(s) on the left, Add all on the numbers that we need to add so that a image will be drawn in the 1 position
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl4);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwl3);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 2L
if amountOfItem1 < 2;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl2);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwl1);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 3L
if amountOfItem1 < 3;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl4);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwl3);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box 4L
if amountOfItem1 < 4;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl2);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwl1);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box 5L
if amountOfItem1 < 5;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl4);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwl3);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box 6L
if amountOfItem1 < 6;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl2);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwl1);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box 7L
if amountOfItem2 < 1;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl6);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwl5);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 8L
if amountOfItem2 < 2;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl8);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwl7);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 9L
if amountOfItem2 < 3;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl6);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwl5);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box10L
if amountOfItem2 < 4;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl8);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwl7);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box11L
if amountOfItem2 < 5;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl6);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwl5);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box12L
if amountOfItem2 < 6;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwl8);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwl7);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Right
% Box 1r
if amountOfItem3 < 1;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr3);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwr4);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 2r
if amountOfItem3 < 2;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr1);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwr2);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 3r
if amountOfItem3 < 3;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr3);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwr4);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box 4r
if amountOfItem3 < 4;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr1);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwr2);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box 5r
if amountOfItem3 < 5;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr3);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwr4);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box 6r
if amountOfItem3 < 6;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr1);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwr2);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box 7r
if amountOfItem4 < 1;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr5);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwr6);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 8r
if amountOfItem4 < 2;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr7);
topPositions = cat(2,topPositions, ph3);
rightPositions = cat(2,rightPositions, pwr8);
bottomPositions = cat(2,bottomPositions, ph4);
end
% Box 9r
if amountOfItem4 < 3;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr5);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwr6);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box10r
if amountOfItem4 < 4;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr7);
topPositions = cat(2,topPositions, ph1);
rightPositions = cat(2,rightPositions, pwr8);
bottomPositions = cat(2,bottomPositions, ph2);
end
% Box11r
if amountOfItem4 < 5;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr5);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwr6);
bottomPositions = cat(2,bottomPositions, ph6);
end
% Box12r
if amountOfItem4 < 6;
draw = cat(1,draw,greyt);
leftPositions = cat(2,leftPositions, pwr7);
topPositions = cat(2,topPositions, ph5);
rightPositions = cat(2,rightPositions, pwr8);
bottomPositions = cat(2,bottomPositions, ph6);
end
v = cat(1,leftPositions,topPositions,rightPositions,bottomPositions);
Screen('DrawTextures',w,draw,[],v)
Screen('Flip',w);
KbWait
Screen('CloseAll');
end