Creating timelines for blocks with different trial numbers #1810
Replies: 2 comments 4 replies
-
Hi Shengjie, Personally, I prefer to write a separate piece of code that does all of my randomisation etc. and stores everything I need to run the experiment in a huge array (that I usually call TrialDat). Within this array, I can have several variables (e.g., TrailDat.TrialNum, TrialDat.Stimulus, TrialDat.CorResp, etc...) and each variable can itself be an array of data that refers to each trial within each block (e.g., TrialDat.TrialNum[bl][tr]). This way, I can separate out the two main parts of the program - one part organises the trial data into a nice coherent array, and another that then uses the data from the array to piece together the experiment using the timeline variables. It sounds like this might be a good way forward for you. In the code I am working on at the moment, I have 24 blocks, each block is made up of 12 miniblocks, and each miniblock has 2-7 trials in it. By storing all of the relevant data in one place, I can then use for loops to tell jsPsych which timeline variables to use, how many times to use them, and what order to put them in. I am more than happy to share my code with you if you think it woudl help. Cai |
Beta Was this translation helpful? Give feedback.
-
Hi Shengjie, I think you should be able to use variables for your repetitions parameters, as long as each block is defined in its own timeline node. Here's a simplified example: // randomize the assignment of trial numbers to blocks
var block_repetitions = jsPsych.randomization.shuffle([28, 32]);
// define trial objects
// ...
//set up each block with the randomized repetition values
var block1 = {
timeline: [trial],
repetitions: block_repetitions[0]
};
var block2 = {
timeline: [trial],
repetitions: block_repetitions[1]
}; Does that work in your case? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I am working on an jsPsych experiment code where I plan to use blocks with different trial numbers. There will be 4 sessions, each session has 8 blocks and 28-32 trials per block (the mean is 30). So, total trial number in each session is 240, but each block has different length. Besides, the trial number for each block is randomized, which means the difference among blocks is also different among subjects. As I noticed, in timeline variables, the repetitions parameter can't be a function. What I did is, I created a variable containing the trial numbers for each block of the current subjects, then extracted the corresponding value to pass to the repetitions parameter. But the result was, the first block was as expected, the second block would have the same length as the first block. It seems I can't do dynamical assignment to repetitions parameter in timeline variable.
So in my situation, what should I do to realize this design? Should I have to write timeline variables for each block, and then put them together to build a nested timeline variable? If so, I have to build up 32 timeline variables and 4 nested timeline variables and 1 nested nested timeline variable. However, I guess there might be some more elegant way to solve this problem. Thanks in advance!
Best,
Shengjie
Beta Was this translation helpful? Give feedback.
All reactions