Saving multiple data lines in a routine

URL of experiment:

Description of the problem:
Hi all!
I am building an online experiment using a PsychoPy builder, and absolutely need your ideas about data saving.

In my experiment, multiple clicks are allowed in a routine (trial), and there’s no limitation on the number of clicks.
I want to save every information whenever the clicks are made, but the default PsychoPy generates only one line per routine.
At first, I put all information in a variable and saved the variable with thisExp.addData() function. Therefore, I had to make an additional processor from external flatform to extract clicks from a cell in the csv file. It works anyway… but I want a more clever way: saving each click data in each line.

Do you have any idea that I can handle the line-by-line data?

Hi @hij113,

the command psychoJS.experiment.nextEntry() makes PsychoJS go to a new row. So you could do something like

Begin routine

lastState = false // this is necessary to prevent one click spanning multiple frames from triggering multiple data entries.

Every frame

currentState = mouse.getPressed()[0] 

if(currentState && !lastState){
    psychoJS.experiment.addData("mousePressTime", t);
    psychoJS.experiment.nextEntry()
}

lastState = currentState

I’ve never used this myself, so please test it carefully to see if all relevant data is saved in a sensible way.

2 Likes

It works well!!! Thanks a lot!!!

1 Like