Problems with adding data to the csv file in online study

URL of experiment: Pavlovia

Description of the problem:
Participants view two images and rate them. The images are drawn from a list. As the csv does not contain the information which images are shown I added the following Python code (see here: Exeriment only partially saves results):

thisExp.addData('bilderle', pictures.image)
thisExp.addData('satzeles', Satze.image)

This works fine, but I don’t know how to translate this into JavaScript for the online version. I tried:

psychoJS.experiment.addData('bilderle', pictures.image.toString());
psychoJS.experiment.addData('satzeles', Satze.image.toString());

I get two additional columns in the csv, but all they say is “[object HTMLImageElement]” instead of showing the names of the images.

I also tried to add psychoJS.experiment.nextEntry();

Any help is appreciated! :slight_smile:

The data saving part auto translates. Your issue is with .image. Can’t you save the variable containing the file name?

Thanks for your reply wakecarter! As mentioned, I read my filenames off a list (using the pop function). If I try

psychoJS.experiment.addData('bilderle', pictures.toString());

I get:

ImageStim( name=pictures, win=Window( name=Window, fullscr=true, color=#000000, ~), autoDraw=null, autoLog=true, units=height, pos=[0,0.1], size=[0.95,0.75], ori=null, opacity=1, depth=-2, clipMask=null, boundingBox={"x":-0.475,"y":-0.275,"width":0.95,"height":0.75,~, image={}, mask=undefined, color=#ffffff, contrast=1, texRes=128, interpolate=true, flipHoriz=null, flipVert=null )

If I try

psychoJS.experiment.addData('bilderle', pictures);

I similarly get:

ImageStim( name=pictures, win=Window( name=Window, fullscr=true, color=#000000, ~), autoDraw=null, autoLog=true, units=height, pos=[0,0.1], size=[0.95,0.75], ori=null, opacity=1, depth=-2, clipMask=null, boundingBox={"x":-0.475,"y":-0.275,"width":0.95,"height":0.75,~, image={}, mask=undefined, color=#ffffff, contrast=1, texRes=128, interpolate=true, flipHoriz=null, flipVert=null )

I think I tried all combinations I could think of :joy: My workaround for now is as follows:

Let’s say the list (or array) I read my pictures off is called “picturelist”. Then I added a code component to “Begin experiment”:

newpicturelist=[...picturelist];
finalpicturelist = newpicturelist.reverse();

Then I add:

psychoJS.experiment.addData('listimages', finalpicturelist.toString());

This is not ideal, but at least I get a list of the pictures.

you say that you read the filenames (I assume you mean the image to be presented) using the pop method. If in every trial you present the first image in the list using the pop method, can’t you just save this to the csv in every trial? Something like:

show_pic = newpicturelist.pop(0)
thisExp.addData(‘image’, show_pic)

1 Like

Yiannis! Thank you! :blush: :blush: This works! Now I can finally run my experiment!

2 Likes