Data from trials loop not saved online

I have a typical experiment with a “trials” loop. Within this loop are a few routines: one for presenting a fixation cross, then one for presenting stimuli, then one for entering a response, then one to present feedback. All pretty standard, I should think. In case it matters: the timing of most elements (e.g. stimuli) in these loops is variable across trials, and the loop is advanced to the next trial by a key press (i.e. not on a timer).

I want to save some important data about the events in the ‘trials’ loop, including the start and end times of the stimuli, the response times, etc. Accordingly, I’ve checked the “save onset/offset times” boxes and so forth in the Builder, and when I run the experiment locally, it works fine: the resulting CSV files include all the variables that I want (e.g. digit0.started & digit0.stopped, for the presentation times of a stimulus called ‘digit0’).

However, when I run the experiment online, all of the information about stuff from the ‘trials’ loop disappears. The only data that is saved is from the start and end routines that come before and after this loop, plus the data that was in the conditions file. Columns like ‘digit0.started’ are no longer present.

I’m really puzzled, since I figured this is nothing to do with custom code components or anything “exotic” like that. These seem like standard features handled through the Builder so I’d expect them to work pretty painlessly (and not be subject to my own dumb errors…).

Any ideas about what might be causing this? This post seemed similar, but adding a .nextEntry statement to my code didn’t solve the issue for me (unless it put it in the wrong place? I added it to the end of the ‘trials’ loop). I also verified that the ‘is trials’ box was checked for my loop. Changing the name to something more distinct (‘trials_loop’) didn’t help either.

Edit: I did notice that the .py code generated by the Builder has a bunch of .addData statements for the variables I want (e.g. ‘digit0.started’), whereas the .js code doesn’t have any such code. So I guess the question is: why doesn’t it? Is this normal - am I supposed to add these statements manually in order to save data online?

Edit2: I replicated the problem in a much simpler dummy experiment that only contains a trial loop with two polygons being presented on each trial, with fixed timing. Locally, stimulus presentation times are saved. Online, again nothing.

After more searching I finally found the answer in this previous thread:

The short of it is that indeed, all of these variables are not automatically saved online, even if you tell the Builder to save them. So, you have to add additional lines in your JS code to make sure that they are.
I’ll leave this thread up to improve findability.

(To clarify, it turns out my issue wasn’t really caused by these components being inside a loop. Stimuli presented outside of a loop will have the same problem. Responses normally do appear to be saved automatically (if you ask Builder to do so), but not in my case as I’m using a less standard way to collect them, not implemented through a simple ‘keyboard’ component.)

I don’t mind that this is the case - we’re lucky that PsychoJS even exists and that people are willing to develop and maintain it for us, and I am grateful to everyone who contributes to this. I’m just wondering: was this explained somewhere and I just missed it? I totally understand that this is a missing feature, but maybe it would be good to just add a brief warning about this in the Builder GUI (e.g. in the ‘data’ tab for the affected components)?

Hi There,

In theory this should be possible to discuss integrating storing of component onset/offset times (infact I think that info is in the log file of each experiment anyway just not the csv as it is locally) - so I’ve added is to the github issues list to flag it to the developers for discussion. Start/Stop times of components not saved to data files (difference with PsychoPy) · Issue #462 · psychopy/psychojs · GitHub

Becca

Hi Becca,

Thanks for your reply. I hadn’t considered that they would show up in the log file. I’ve only been running in pilot mode so far, and so I didn’t get log files online. In my local pilots I can indeed see them show up in the logs.

If they’re in the logs online too, then I guess the issue is less severe (as data won’t be lost when actually running the experiment), but I guess in an ideal world the behavior would be the same between local/PsychoPy and online/PsychoJS execution (or, barring that, if users are aware that it’s not, then they can adjust their code accordingly). So thanks for flagging this with the developers!

Ruben