I posted a couple of days ago about a code component for getting spacebar duration (Hold Time) and RT to key press from trial onset (Response Time). Thanks to Jonathan, these both work when run in the builder and the data file adds the variables correctly. See my last post here: Keyboard press response time from trial onset with coding component
However when uploading to Pavlovia, neither the Hold Time or Response Time (the two additional variables added to the data file) are not pulled through. Hold Time shows a , and response time does not even exist as a column in the data file.
The code I have used is belowā¦experiment also attached if it helpsā¦
Not sure about all the other auto-translated code, but the command to add data to the output in PsychoJS is psychoJS.experiment.addData('columnname', value).
Thank you. I made this amendment (and a couple others which I have mentioned below) and unfortunately its not fully working, however both Hold Time and Response Time are both now showing in the data csv file but both with a instead of the data.
Perhaps the JS code from the code component would help:
Begin Routine
duration = ;
rt = ;
trialClock = new util.Clock();
kb = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
Each Frame
keys2 = kb.getKeys();
for (var key, _pj_c = 0, _pj_a = keys2, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
key = _pj_a[_pj_c];
if (key.duration) {
duration.push(key.duration);
}
if (key.rt) {
rt.push(key.rt);
}
}
End Routine
psychoJS.experiment.addData(āHold Timesā, duration);
psychoJS.experiment.addData(āResponse Timeā, rt)
Also posting the other changes I made - I hope this helps someone else!
I changed from trialClock = new core.Clock(); to trialClock = new util.Clock(); in Begin Routine in the JS code as pointed out on this post by wakecarter who says this needs to be manually changed as I got a core.Clock error when running in pavlovia - Thanks: Error: code1Clock = new util.Clock() - #2 by wakecarter
I also changed from kb = new keyboard.Keyboard({āclockā: trialClock}) to kb = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true}); in the JS code to remove a keyboard undefined error in pavlovia as mentioned in this post here: Failing to use Keyboard in Pavlovia - #2 by dvbridges
There is still no data showing in the csv files when downloading from pavlovia.
But with the amendments I made above, both Hold Times and Response Time are showing as columns in the data file, whereas before only Hold Times was. The issue is the missing data.
Thank you for your help and suggestions, but unfortunately there is still no data for Hold Times and Response Time showing in the data file, and instead a
I am measuring just one key press duration RT per trial (using the space bar) as its a time reproduction experiment.
I have managed to successfully get key press duration RT of the space bar (which I have called Hold Times), and I currently have this working on pavlovia, with Hold Times showing in the csv. linked here Pavlovia
However I have needed to make some amendments to the code to also try to get the RT from trial onset to start of the key press to work on pavlovia but without much luckā¦now neither Hold Times or Response Times are showing in the data file. Note that the experiment I am enquiring about is the same as the linked one above, but I just have one āmasterā copy (which is Pavlovia linked above), and then almost a āworking experimentā to mess around with to get RT from trial onset to start of the key press to work!