Dear Inquisiters,
I am trying to build a sort of psychophisics in Inquisit. The experiment works like this: subjects have to press the spacebar everytime a circle (red_circle) appears on the screen. Within a trial I have 43 circles appearing, and a certain number of keypresses per subject.
Then, at the end of the trial the accuracy is calculated: a keypress is considered accurate if the subjects responded in an interval comprised between 125 milliseconds before AND 750 milliseconds after the real appearance of the circle.
My only problem is that, within this calculation, ONE AND ONLY response/keypress could be associated *and then considered accurate* compared to ONE AND ONLY interval around the appearance of each circle.
For example: imagine that the first appearance of the circle is at 1000 milliseconds, so that I will consider a response accurate if that response was given in the interval between 875 milliseconds (1000-125) and 1750 (1000+750) milliseconds. But now, imagine that in that interval I gave a response at 900 milliseconds, another at 1200 milliseconds and another one at 1400 milliseconds. Three responses would be counted as accurate, but, actually, in that interval only ONE circle appeared: so, only one of these responses can be considered *accurate/correct*
I would like to calculate as *accurate* only one of these multiple responses, as each interval could be associated to one and only response. To do that, I thought of creating a temporary values variable which increments of 1 for ANY accurate response (values.sum_counted): then, within the loop, a second value (values.sum_acc_latencies) increment of ONE if the variable values.sum.counted is = or > 1. Then, values.sum_counted should be reset to zero at the end of the loop and re-increment of one (or more) again according to the number of correct responses.
However, something is not working in this code.
I hope that everything was clear and that someone could help me, thank you very much!
Eleonora
Here is the code:
<shape red_circle>
/ color = (180,180,180)
/ position = (50%,50%)
/ shape = circle
/size=(10%, 10%)
</shape>
<shape black_circle>
/ color = (185,185,185)
/ position = (50%,50%)
/ shape = circle
/ size=(10%, 10%)
</shape>
<shape blank>
/ color = (192,192,192)
/ position = (50%,50%)
/ shape = rectangle
/size=(30%, 30%)
</shape>
<trial blank>
/stimulusframes=[1=blank]
/ trialduration = 3000
</trial>
<text cross>
/items=("+")
/position = (50%, 50%)
</text>
<picture checker>
/items=("scacchieracc.png")
/ position = (50%, 50%)
/ size = (30%, 30%)
</picture>
<trial fixate>
/ stimulusframes = [1=cross]
/ trialduration = 2000
</trial>
<values>
/timeofresponse=""
/spacebarpresscount =""
/accuracy = ""
</values>
<trial acc>
/ ontrialbegin = [
values.spacebarpresscount = "";
values.timeofresponse = "";
values.accuracy = "";
values.current_onset = "";
values.current_max = "";
values.current_min = "";
values.current_latency = "";
values.sum_acc_latencies = 0;
values.bucketcount = 0;
values.latencycount = 0;
values.sum_counted = 0;
list.acc.reset();
list.latencies.reset();
list.onsets.reset();
]
/pretrialpause = 1000
/stimulustimes=[
0=red_circle, checker;
1007=red_circle, checker;
2082=red_circle, checker;
3220=red_circle, checker;
4399=red_circle, checker;
5570=red_circle, checker;
6708=red_circle, checker;
7936=red_circle, checker;
9059=red_circle, checker;
10259=red_circle, checker;
11460=red_circle, checker;
12633=red_circle, checker;
13893=red_circle, checker;
15069=red_circle, checker;
16284=red_circle, checker;
17449=red_circle, checker;
18591=red_circle, checker;
19795=red_circle, checker;
20915=red_circle, checker;
22149=red_circle, checker;
23244=red_circle, checker;
24398=red_circle, checker;
25567=red_circle, checker;
26690=red_circle, checker;
27885=red_circle, checker;
28998=red_circle, checker;
30208=red_circle, checker;
31421=red_circle, checker;
32539=red_circle, checker;
33702=red_circle, checker;
34789=red_circle, checker;
35849=red_circle, checker;
36972=red_circle, checker;
38018=red_circle, checker;
39172=red_circle, checker;
40341=red_circle, checker;
41437=red_circle, checker;
42572=red_circle, checker;
43681=red_circle, checker;
44758=red_circle, checker;
45918=red_circle, checker;
46995=red_circle, checker;
48090=red_circle, checker;
50=black_circle, checker;
1057=black_circle, checker;
2132=black_circle, checker;
3270=black_circle, checker;
4449=black_circle, checker;
5620=black_circle, checker;
6758=black_circle, checker;
7986=black_circle, checker;
9109=black_circle, checker;
10309=black_circle, checker;
11510=black_circle, checker;
12683=black_circle, checker;
13943=black_circle, checker;
15119=black_circle, checker;
16334=black_circle, checker;
17499=black_circle, checker;
18641=black_circle, checker;
19845=black_circle, checker;
20965=black_circle, checker;
22199=black_circle, checker;
23294=black_circle, checker;
24448=black_circle, checker;
25617=black_circle, checker;
26740=black_circle, checker;
27935=black_circle, checker;
29048=black_circle, checker;
30258=black_circle, checker;
31471=black_circle, checker;
32589=black_circle, checker;
33752=black_circle, checker;
34839=black_circle, checker;
35899=black_circle, checker;
37022=black_circle, checker;
38068=black_circle, checker;
39222=black_circle, checker;
40391=black_circle, checker;
41487=black_circle, checker;
42622=black_circle, checker;
43731=black_circle, checker;
44808=black_circle, checker;
45968=black_circle, checker;
47045=black_circle, checker;
48140=black_circle, checker;
]
/ trialduration = 48140+1000
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ isvalidresponse = [if(trial.acc.response==57){
values.spacebarpresscount += 1;
values.timeofresponse=concat(concat(values.timeofresponse, trial.acc.latency),",");
list.latencies.appenditem(trial.acc.latency);
false}
;
]
/ ontrialend = [
list.onsets.appenditem(shape.red_circle.stimulusonset.1);
list.onsets.appenditem(shape.red_circle.stimulusonset.2);
list.onsets.appenditem(shape.red_circle.stimulusonset.3);
list.onsets.appenditem(shape.red_circle.stimulusonset.4);
list.onsets.appenditem(shape.red_circle.stimulusonset.5);
list.onsets.appenditem(shape.red_circle.stimulusonset.6);
list.onsets.appenditem(shape.red_circle.stimulusonset.7);
list.onsets.appenditem(shape.red_circle.stimulusonset.8);
list.onsets.appenditem(shape.red_circle.stimulusonset.9);
list.onsets.appenditem(shape.red_circle.stimulusonset.10);
list.onsets.appenditem(shape.red_circle.stimulusonset.11);
list.onsets.appenditem(shape.red_circle.stimulusonset.12);
list.onsets.appenditem(shape.red_circle.stimulusonset.13);
list.onsets.appenditem(shape.red_circle.stimulusonset.14);
list.onsets.appenditem(shape.red_circle.stimulusonset.15);
list.onsets.appenditem(shape.red_circle.stimulusonset.16);
list.onsets.appenditem(shape.red_circle.stimulusonset.17);
list.onsets.appenditem(shape.red_circle.stimulusonset.18);
list.onsets.appenditem(shape.red_circle.stimulusonset.19);
list.onsets.appenditem(shape.red_circle.stimulusonset.20);
list.onsets.appenditem(shape.red_circle.stimulusonset.21);
list.onsets.appenditem(shape.red_circle.stimulusonset.22);
list.onsets.appenditem(shape.red_circle.stimulusonset.23);
list.onsets.appenditem(shape.red_circle.stimulusonset.24);
list.onsets.appenditem(shape.red_circle.stimulusonset.25);
list.onsets.appenditem(shape.red_circle.stimulusonset.26);
list.onsets.appenditem(shape.red_circle.stimulusonset.27);
list.onsets.appenditem(shape.red_circle.stimulusonset.28);
list.onsets.appenditem(shape.red_circle.stimulusonset.29);
list.onsets.appenditem(shape.red_circle.stimulusonset.30);
list.onsets.appenditem(shape.red_circle.stimulusonset.31);
list.onsets.appenditem(shape.red_circle.stimulusonset.32);
list.onsets.appenditem(shape.red_circle.stimulusonset.33);
list.onsets.appenditem(shape.red_circle.stimulusonset.34);
list.onsets.appenditem(shape.red_circle.stimulusonset.35);
list.onsets.appenditem(shape.red_circle.stimulusonset.36);
list.onsets.appenditem(shape.red_circle.stimulusonset.37);
list.onsets.appenditem(shape.red_circle.stimulusonset.38);
list.onsets.appenditem(shape.red_circle.stimulusonset.39);
list.onsets.appenditem(shape.red_circle.stimulusonset.40);
list.onsets.appenditem(shape.red_circle.stimulusonset.41);
list.onsets.appenditem(shape.red_circle.stimulusonset.42);
list.onsets.appenditem(shape.red_circle.stimulusonset.43);
]
/ branch = [
trial.construct_bucket;
]
</trial>
<list latencies>
/ select = sequence
</list>
<list onsets>
/ select = sequence
</list>
<list acc>
</list>
<values>
/ current_onset = 0
/ current_min = 0
/ current_max = 0
/ current_latency = ""
/ bucketcount = 0
/ latencycount = 0
/ sum_acc_latencies = 0
/sum_counted = 0
</values>
<trial construct_bucket>
/ ontrialbegin = [
values.bucketcount += 1;
values.latencycount = 0;
values.current_onset = list.onsets.nextvalue;
values.current_min = values.current_onset - 125;
values.current_max = values.current_onset + 750;
]
/ stimulusframes = [1=clearscreen, debug]
/ branch = [
trial.check_latencies;
]
/ trialduration = 0
/ recorddata = false
</trial>
<trial check_latencies>
/ ontrialbegin = [
values.sum_counted = 0;
values.latencycount += 1;
values.current_latency = list.latencies.nextvalue;
if (values.current_latency >= values.current_min && values.current_latency <= values.current_max){
values.sum_counted += 1;}
if (values.sum_counted >=1) {values.sum_acc_latencies +=1}
]
/ stimulusframes = [1=clearscreen, debug]
/ branch = [
if (values.latencycount < list.latencies.itemcount) {
trial.check_latencies;
} else if (values.bucketcount < list.onsets.itemcount) {
trial.construct_bucket;
} else {
trial.score_result;
}
]
/ trialduration = 0
/ recorddata = false
</trial>
<trial score_result>
/ ontrialbegin = [
values.accuracy = 1-(abs(list.onsets.itemcount-values.sum_acc_latencies)/list.onsets.itemcount)]
/ stimulusframes = [1=clearscreen, debug]
/ validresponse = (57)
</trial>
<text debug>
/ items = ("Bucket <%values.bucketcount%> of <%list.onsets.itemcount%>
Latency <%values.latencycount%> of <%list.latencies.itemcount%>
Onset: <%values.current_onset%>| Min Latency: <%values.current_min%> | Max Latency: <%values.current_max%>
Current Latency: <%values.current_latency%>
Accurate Latencies: <%values.sum_acc_latencies%> of <%list.latencies.itemcount%>
Final Accuracy: <%values.accuracy%>%")
/ erase = false
/ size = (60%, 40%)
</text>
<block pre>
/ trials = [1=fixate; 2=blank]
</block>
<block acc>
/ trials = [1=acc]
</block>
<expt >
/blocks=[
1=pre;2=acc;
]
</expt>
<data>
/ columns = [date,time,group,subject, display.refreshrate, values.sum_counted, display.canvaswidth, display.canvasheight, trialduration, values.sum_acc_latencies, values.accuracy, values.timeofresponse,values.spacebarpresscount,
shape.black_circle.stimulusonset.1
shape.black_circle.stimulusonset.2
shape.black_circle.stimulusonset.3
shape.black_circle.stimulusonset.4
shape.black_circle.stimulusonset.5
shape.black_circle.stimulusonset.6
shape.black_circle.stimulusonset.7
shape.black_circle.stimulusonset.8
shape.black_circle.stimulusonset.9
shape.black_circle.stimulusonset.10
shape.black_circle.stimulusonset.11
shape.black_circle.stimulusonset.12
shape.black_circle.stimulusonset.13
shape.black_circle.stimulusonset.14
shape.black_circle.stimulusonset.15
shape.black_circle.stimulusonset.16
shape.black_circle.stimulusonset.17
shape.black_circle.stimulusonset.18
shape.black_circle.stimulusonset.19
shape.black_circle.stimulusonset.20
shape.black_circle.stimulusonset.21
shape.black_circle.stimulusonset.22
shape.black_circle.stimulusonset.23
shape.black_circle.stimulusonset.24
shape.black_circle.stimulusonset.25
shape.black_circle.stimulusonset.26
shape.black_circle.stimulusonset.27
shape.black_circle.stimulusonset.28
shape.black_circle.stimulusonset.29
shape.black_circle.stimulusonset.30
shape.black_circle.stimulusonset.31
shape.black_circle.stimulusonset.32
shape.black_circle.stimulusonset.33
shape.black_circle.stimulusonset.34
shape.black_circle.stimulusonset.35
shape.black_circle.stimulusonset.36
shape.black_circle.stimulusonset.37
shape.black_circle.stimulusonset.38
shape.black_circle.stimulusonset.39
shape.black_circle.stimulusonset.40
shape.black_circle.stimulusonset.41
shape.black_circle.stimulusonset.42
shape.black_circle.stimulusonset.43
shape.red_circle.stimulusonset.1
shape.red_circle.stimulusonset.2
shape.red_circle.stimulusonset.3
shape.red_circle.stimulusonset.4
shape.red_circle.stimulusonset.5
shape.red_circle.stimulusonset.6
shape.red_circle.stimulusonset.7
shape.red_circle.stimulusonset.8
shape.red_circle.stimulusonset.9
shape.red_circle.stimulusonset.10
shape.red_circle.stimulusonset.11
shape.red_circle.stimulusonset.12
shape.red_circle.stimulusonset.13
shape.red_circle.stimulusonset.14
shape.red_circle.stimulusonset.15
shape.red_circle.stimulusonset.16
shape.red_circle.stimulusonset.17
shape.red_circle.stimulusonset.18
shape.red_circle.stimulusonset.19
shape.red_circle.stimulusonset.20
shape.red_circle.stimulusonset.21
shape.red_circle.stimulusonset.22
shape.red_circle.stimulusonset.23
shape.red_circle.stimulusonset.24
shape.red_circle.stimulusonset.25
shape.red_circle.stimulusonset.26
shape.red_circle.stimulusonset.27
shape.red_circle.stimulusonset.28
shape.red_circle.stimulusonset.29
shape.red_circle.stimulusonset.30
shape.red_circle.stimulusonset.31
shape.red_circle.stimulusonset.32
shape.red_circle.stimulusonset.33
shape.red_circle.stimulusonset.34
shape.red_circle.stimulusonset.35
shape.red_circle.stimulusonset.36
shape.red_circle.stimulusonset.37
shape.red_circle.stimulusonset.38
shape.red_circle.stimulusonset.39
shape.red_circle.stimulusonset.40
shape.red_circle.stimulusonset.41
shape.red_circle.stimulusonset.42
shape.red_circle.stimulusonset.43
]
</data>
<defaults>
/ screencolor = (192,192,192)
/ txbgcolor = (192,192,192)
/ txcolor = white
/ fontstyle = ("Trebuchet MS", 3.11%, false, false, false, false, 5, 1)
</defaults>