/
PSICAT.pcl
313 lines (272 loc) · 10.6 KB
/
PSICAT.pcl
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
# -------------------------------------------------------------------
# THIS PCL PROGRAM RUNS A BLOCKED EXPERIMENT OF PRIMED KANIZSA SHAPES
# -------------------------------------------------------------------
logfile.add_event_entry( date_time("ddmmyyyyhhnnsszz"));
include_once "Localise.pcl"
include_once "Shapes.pcl"
include_once "Randomness.pcl"
### MUST MIRROR THE TIMING AND COLOR CONSTANTS FROM THE SCE FILE!
## COLOR GLOBALS - PASSED TO polyfilla() AND kanizsaShape()
rgb_color BCOL = rgb_color(0, 0, 0, 0); # background color
rgb_color FCOL = rgb_color(255, 255, 255, 0); # foreground, i.e. shape color
rgb_color LCOL = rgb_color(255, 0, 0, 0); # primer line color
## TIMING GLOBALS - USED IN kanizsaBlock()
int KNZA_DUR = forever;
int INTF_DUR = 150;
int SOA_LOWER_DUR = 400;
int SOA_UPPER_DUR = 600;
## VISUAL DIMENSIONS GLOBALS - PASSED TO kanizsaShape() AND randCS()
# display_device.width seems to return an int (not what documentation suggests?)
int screen_width = display_device.width();
int screen_height = display_device.height();
# Diameter of the Pac-Man shapes
double PAC_DIAM = double(screen_height) / 6.0;
if screen_height > screen_width then
PAC_DIAM = double(screen_width) / 6.0;
end;
# highest absolute value of y-coordinate on the screen
double total_max_y = double(display_device.height() / 2);
# highest absolute value of x-coordinate
double total_max_x = double(display_device.width() / 2);
# define highest acceptable x- or y-coordinate absolute value for quadrangle
int MAX_Y = int(total_max_y - 2.0 * PAC_DIAM);
int MAX_X = int(total_max_x - 2.0 * PAC_DIAM);
# define lowest acceptable x- or y-coordinate absolute value for quadrangle
int MIN_Y = int(PAC_DIAM + 20.0);
int MIN_X = int(PAC_DIAM + 20.0);
#######-------#######-------#######-------#######-------#######-------#######---
# Subroutine to present each block of the PSICAT task:
# Generates randomized kanizsa stimuli and primers.
#
# regPoly : BOOLEAN, true = regular, false = irregular primers & Kanizsa shapes
# pactype : STRING, defines Pac-Man shapes as "annulus" or "ellipse"
# blockN : INTEGER, block number, increasing in increments of 10 from 0
# trialN : INTEGER, the number of trials in this block
#
sub
kanizsaBlock( bool regPoly, string pactype, int blockN, int trialN )
begin
# Handy random number for making choices
double random_num = random();
# Control the number of vertices
int vtx = random(3, 4);
# COORDINATE ARRAY
array <double> rd_cs[vtx][2];
# Random rotation angles array
array< double > rnd[vtx];
# Rotation angles constraints, min, mux (= max - min)
double min = 20.0;
double mux = 320.0;
# Set which trial type we have : congruent or incongruent
string trialtype;
# TRIAL GENERATING LOOP
loop
int i = trialN
until
i == 0
begin
#fixation period
fixation_trial.present();
/**
Get random num vertices for primer/Kanizsa, then resize arrays to current size
(comment next 3 lines for a fixed vertex count (triangles or quandrangles))
*/
vtx = random(3, 4);
rd_cs.resize( vtx );
rnd.resize( vtx );
/**/
# first randomize the coordinates for both stimuli
rd_cs = randCS( regPoly, vtx, MIN_X, MIN_Y, MAX_X, MAX_Y );
# save coordinates in a string "log_coors" for the log file
string log_coors = " [";
loop
int k = 1
until
k == vtx + 1
begin
log_coors = log_coors + " " + string(rd_cs[k][1]) + ",";
log_coors = log_coors + " " + string(rd_cs[k][2]) + ",";
k = k + 1;
end;
log_coors = log_coors + ",";
log_coors = log_coors + "]";
#randomize trialtype (congruent vs. incongruent)
random_num = random();
if random_num > 0.5 then
trialtype = "congruent";
else
trialtype = "incongruent";
end;
# IF statement sets target as shape or nonshape
#
# TARGET IS A SHAPE
if random() > 0.5 then
if trialtype == "congruent" then
#SHAPE PRIMER
# fix the rotations at zero to draw a shape
rnd = randR( vtx, 0.0, 0.0 );
#show subjective shape primer
kanizsaShape(rd_cs, PAC_DIAM, true, pactype, rnd, BCOL, FCOL, LCOL);
ev.set_event_code( log_coors + ";" + string(151 + blockN) + ";Congruent;shape;primer;" + string(vtx) ); ev.set_port_code( 151+blockN ); ev.set_target_button( 0 ); # NO RESPONSE
Kanizsa.set_duration( INTF_DUR );
Kanizsa.set_type( fixed );
Kanizsa.present();
#SHAPE TARGET
polyfilla(rd_cs, PAC_DIAM, false, pactype, BCOL, FCOL);
ev.set_event_code( log_coors + ";" + string(152 + blockN) + ";Congruent;shape;target;" + string(vtx) ); ev.set_port_code( 152+blockN ); ev.set_target_button( 2 ); # RIGHT-HAND RESPONSE
Kanizsa.set_duration( KNZA_DUR );
Kanizsa.set_type( first_response );
Kanizsa.present();
end;
if trialtype == "incongruent" then #primer is a nonshape
#NONSHAPE PRIMER
rnd = randR( vtx, min, mux );
# show nonshape primer
kanizsaShape(rd_cs, PAC_DIAM, true, pactype, rnd, BCOL, FCOL, LCOL);
ev.set_event_code( log_coors + ";" + string(153 + blockN) + ";InCon;nonShape;primer;" + string(vtx) ); ev.set_port_code( 153+blockN ); ev.set_target_button( 0 ); # NO RESPONSE
Kanizsa.set_duration( INTF_DUR );
Kanizsa.set_type( fixed );
Kanizsa.present();
#SHAPE TARGET
polyfilla(rd_cs, PAC_DIAM, false, pactype, BCOL, FCOL);
ev.set_event_code( log_coors + ";" + string(154 + blockN) + ";InCon;shape;target;" + string(vtx) ); ev.set_port_code( 154+blockN ); ev.set_target_button( 2 ); # RIGHT-HAND RESPONSE
Kanizsa.set_duration( KNZA_DUR );
Kanizsa.set_type( first_response );
Kanizsa.present();
end;
# TARGET IS A NON-SHAPE
else
if trialtype == "congruent" then #primer is a nonshape
# randomize the rotations, same for both
rnd = randR( vtx, min, mux );
#NONSHAPE PRIMER
# show nonshape primer
kanizsaShape(rd_cs, PAC_DIAM, true, pactype, rnd, BCOL, FCOL, LCOL);
ev.set_event_code( log_coors + ";" + string(155 + blockN) + ";Congruent;nonShape;primer;" + string(vtx) ); ev.set_port_code( 155+blockN ); ev.set_target_button( 0 ); # NO RESPONSE
Kanizsa.set_duration( INTF_DUR );
Kanizsa.set_type( fixed );
Kanizsa.present();
#NONSHAPE TARGET
kanizsaShape(rd_cs, PAC_DIAM, false, pactype, rnd, BCOL, FCOL, LCOL);
ev.set_event_code( log_coors + ";" + string(156 + blockN) + ";Congruent;nonShape;target;" + string(vtx) ); ev.set_port_code( 156+blockN ); ev.set_target_button( 1 ); # LEFT-HAND RESPONSE
Kanizsa.set_duration( KNZA_DUR );
Kanizsa.set_type( first_response );
Kanizsa.present();
end;
if trialtype == "incongruent" then #primer is a shape
#SHAPE PRIMER
# fix the rotations at zero to draw a shape
rnd = randR( vtx, 0.0, 0.0 );
# show subjective shape primer
kanizsaShape(rd_cs, PAC_DIAM, true, pactype, rnd, BCOL, FCOL, LCOL);
ev.set_event_code( log_coors + ";" + string(157 + blockN) + ";InCon;shape;primer;" + string(vtx) ); ev.set_port_code( 157+blockN ); ev.set_target_button( 0 ); # NO RESPONSE
Kanizsa.set_duration( INTF_DUR );
Kanizsa.set_type( fixed );
Kanizsa.present();
#NONSHAPE TARGET
# randomize the rotations
rnd = randR( vtx, min, mux );
# show nonshape primer
kanizsaShape(rd_cs, PAC_DIAM, false, pactype, rnd, BCOL, FCOL, LCOL);
ev.set_event_code( log_coors + ";" + string(158 + blockN) + ";InCon;nonShape;target;" + string(vtx) ); ev.set_port_code( 158+blockN ); ev.set_target_button( 1 ); # LEFT-HAND RESPONSE
Kanizsa.set_duration( KNZA_DUR );
Kanizsa.set_type( first_response );
Kanizsa.present();
end;
end;
i = i-1;
#intertrial interval
SOA_trial.set_duration( random(SOA_LOWER_DUR, SOA_UPPER_DUR) );
SOA_trial.present();
end;
end;
#######-------#######-------#######-------#######-------#######-------#######---
# A subroutine to present the whole PSICAT task.
sub
PSICATprotocol
begin
# Call this function to localise instructions to preferred language
# localise( "english" );
# Number of trials per block
int t = 110;
# Instructions to begin the protocol
/**/
PSIC_instr_trial.present();
PSIC_resp_trial.present();
# Instructions for each break between blocks in the protocol
PSIC_respPic.clear();
PSIC_respPic.add_part( PSIC_text_2, 0, 220 );
PSIC_respPic.add_part( rPadPic, 0, 0 );
PSIC_respAud_ev.set_stimulus( sound2_relax );
/**/
stev.set_event_code( "Start block; ;1;irreg;" + string(t) );
stev.set_port_code( 145 );
startAll.present();
# 1st block
# Block of irregular, elliptical Kanizsas
kanizsaBlock( false, "ellipse", 0, t );
# Have a break
PSIC_respPic.add_part( PSIC_text_2a, 0, -150 );
PSIC_resp_trial.present();
# Save this and prior blocks
save_trial.present();
stev.set_event_code( "Start block; ;2;irreg;" + string(t) );
stev.set_port_code( 146 );
startAll.present();
#2nd block
# Block of irregular, elliptical Kanizsas
kanizsaBlock( false, "ellipse", 10, t );
# Have a break
PSIC_respPic.remove_part( 3 );
PSIC_respPic.add_part( PSIC_text_2b, 0, -150 );
PSIC_resp_trial.present();
# Save this and prior blocks
save_trial.present();
stev.set_event_code( "Start block; ;3;irreg;" + string(t) );
stev.set_port_code( 147 );
startAll.present();
# Block of irregular, elliptical Kanizsas
kanizsaBlock( false, "ellipse", 20, t );
# Have a break
PSIC_respPic.remove_part( 3 );
PSIC_respPic.add_part( PSIC_text_2c, 0, -150 );
PSIC_resp_trial.present();
# Save this and prior blocks
save_trial.present();
stev.set_event_code( "Start block; ;4;irreg;" + string(t) );
stev.set_port_code( 148 );
startAll.present();
# Block of irregular, elliptical Kanizsas
kanizsaBlock( false, "ellipse", 30, t );
# Have a break
PSIC_respPic.remove_part( 3 );
PSIC_respPic.add_part( PSIC_text_2d, 0, -150 );
PSIC_resp_trial.present();
# Save this and prior blocks
save_trial.present();
stev.set_event_code( "Start block; ;5;irreg;" + string(t) );
stev.set_port_code( 149 );
startAll.present();
# Block of irregular, elliptical Kanizsas
kanizsaBlock( false, "ellipse", 40, t );
/** DEBUG LOOP RANDOMISES THE REGULARITY OF EACH KANIZSA SHAPE
loop
int i = 1;
until
i > t
begin
if random() > 0.5 then
kanizsaBlock( false, "ellipse", 40, 1 );
else
kanizsaBlock( true, "ellipse", 40, 1 );
end;
i = i + 1 ;
end;
/**/
end;
#######-------#######-------#######-------#######-------#######-------#######---
# Record that PSICAT.
startAll.present();
startAll.present();
PSICATprotocol();
endAll.present();