PennController for IBEX › Forums › Support › Play video based on presentation order
- This topic has 1 reply, 2 voices, and was last updated 2 years, 3 months ago by Jeremy.
-
AuthorPosts
-
September 1, 2022 at 12:14 am #8382yzhu130Participant
I’m programming an experiment and I want to play a short video at the end of each trial based on the presentation order: I have video 1 for the first trial that’s presented, video 2 for the second trial, and so on for a total of 4 trials in a block. Right now I randomize all the trials in this block so I cannot just refer to the videos’ file names in the trial template. Is there any convenient way to achieve what I want to do?
I saw another post about logging running order using code like this
Header( newVar("runningOrder", 0).global().set(v=>v+1) )
but I’m not sure how to use it in my case.
Thank you in advance!
September 1, 2022 at 1:30 pm #8384JeremyKeymasterHi,
This is a little tricky indeed, since ideally you’d like to pre-associate each video with a trial based on its running order, so that the first video starts preloading before the second video and so forth, but the running order is randomized
One trick would consist in randomizing the table itself (the one that contains the stim details for the trials) rather than randomizing the trials in the
Sequence
, so that you outputnewTrial
s generated from the randomized table, but with the video references taken from another, non-randomized tableSay you have two CSV files in your project, one named “stims.csv” and one name “videos.csv” (the latter only lists video references in the order in which they are supposed to play). Then you can do something like this:
// we will store the stim details in an array named 'trials' (which we will randomize) var trials = [] // fill 'trials' with each row from stims.csv Template( "stims.csv", row => [ trials.push(row) ] ) // we will successively retrieve each row from 'trials' in 'row' var row // generate trials from video.csv, where row_w points to each of its lines Template( "videos.csv", row_v => newTrial( "trial" , fisherYates(trials), // randomize the array 'trials' row = trials.pop() // move the last entry of 'trials' into 'row' , // write your trial as usual, with 'row' pointing to a random line from 'stims.csv' newText( row.Sentence ).print() , newText( row.Question ).print() , newScale(7).print().wait() , // row_v points to each lines in videos.csv in a non-randomized order newVideo(row_v.Video).print().play().wait() ) )
NB: you might see errors about not finding a column named
_promises
, you can safely ignore those specific errors (they come from the linerow = trials.pop()
which is not very standard syntax)Let me know if you have questions
Jeremy
-
AuthorPosts
- You must be logged in to reply to this topic.