Is there any way the PsychoJS code can be amended to capture the onset times for stimuli? I am aware the onset times are captured in the log files but i am having trouble accessing the log files for pilot data and it would be easier for analysis purposes to capture them in the main CSV (or database) output.
I’m pretty sure that, by default, the time of each stimulus’s onset (relative to the trial start) is saved as stimulusName.tStart. So, you should be able to save this information to your data file by including a code component that has something like psychoJS.experiment.addData(‘variableName’, stimulusName.tStart) under the “End Routine” tab.
Thank you, i will give that a try in the end routine tab and work from there, awesome thank you. Will let you know how it goes.
Your help is greatly appreciated.
so if i have 5 images per conditions file line, 272 lines on the conditions file (so 272 trials in the routine)…would i do something like the below (image1 etc are representations of the image names)
psychoJS.experiment.addData(‘Image1’, stimulusName.tStart) ;
would this need to be in the each frame tab of the code component rather than end routine, because i need to see the onset time for each image each loop (trial) in the csv data file…
It would depend on exactly how your experiment is set up, but usually to save data at the end of each trial it would be sufficient to have it in the “End routine” tab. (If it’s in the “Each frame” tab you will get a new line in your data file every time the screen refreshes, I think.)
@ps2 ahhh ok that makes sense. Thank you I will be testing today so all being well everything goes smoothly.
hello @ps2 apologies for the delay, i had macbook troubles so couldn’t run the experiment.
Having added the code component into the image routine (see attached) i am now getting the error 88744.1796 ERROR Line 527: Unexpected token ILLEGAL in Pavlovia8-legacy-browsers.js
so i guess somewhere in the end routine code component code i have got a character maybe that shouldn’t be there?
Looks like you’ve closed the quotation marks for ResponseImg with a different character than you’ve used to open them—that’s why the text at the end is displaying in purple. Actually, I think all of the names you have in quotation marks there (Img1, Img2, MaskImg, FixCross, and ResponseImg) should be in purple like that, whereas the xxx.tStart should be in black.
(Note also that the “stimulusName” I suggested was just a placeholder—you’ll need to replace this with the actual name of each stimulus you want to record the onset time of. That is, for Img1, I guess it should be Img1.tStart, etc.)
oh dear, my apologies, i completely misunderstood. I will go again. As you can see, code is not my forte
That just makes learning more fun though… right?
it does indeed only way to learn - fail fast, go again.
I’m afraid I’m not sure what’s going on there. If you can upload a sample data file, I’m happy to take a look at it; that might be more informative than trying to work off screenshots.
I’m pretty sure that including the command in the “Each frame” tab will just give you the same values repeated numerous times in your data file, so I recommend against that.
As far as I’m aware, when in pilot mode, the data files are only saved locally (i.e., to the user’s computer) rather than on the server. So, that would be why nothing is showing up in the zip file.
Unfortunately I’m still none the wiser. I’ve never seen data saved across rows rather than in columns like that. My only idea is that something is still wrong with the quotation marks you’re using to name the variables in the code component, so it’s (a) not realising that they have names, and (b) not realising that the values that are saved should go in the same columns each time.
hmmm ok, thank you. I will see what changes i can make to capture them as headers. I think i must have got the code component wrong again. I will send a shot of what i have once i get home, hopefully i haven’t made another error, but you never know.
thank you again for persevering with this.
please see code inserted in the code component below.
Ah yep, that’s the problem then. Each time you use the addData method, you need to include both the variable you want to save, and a string indicating what you want to call it in the data file. At the moment you just have the former. So, it should look something like this:
psychoJS.experiment.addData("Img1", Img1.tStart); psychoJS.experiment.addData("Img2", Img2.tStart); psychoJS.experiment.addData("MaskImg", MaskImg.tStart); psychoJS.experiment.addData("FixCross", FixCross.tStart); psychoJS.experiment.addData("ResponseImg", ResponseImg.tStart);
You may want to play around with some different types of quotation marks if that exact code doesn’t work (I remember that being a problem earlier), but that’s the general idea.
Yes, so if the data does not appear in the data file after this, then you need to add a call to nextEntry after the calls to addData e.g.,
// all your calls to psychoJs.experiment.addData... psychoJS.experiment.nextEntry()
amazing, thank you, i thought when you mentioned the quotations yesterday i must have got the code incorrect. I will retry again today.
Thank you for your continued advice.
thank you, i will add this to the backlog to resolve the data issue if needed, much appreciated