Question:
Can I put something in a code snippet that makes the loop jump to another point (e.g. ahead) in the index other than just the next trial in line?
Here’s the context:
I’m working on an experiment in which I need to dynamically be able to repeat certain trials. I’ve read that jumping back is very ugly and quirky in builder.
Therefore, I doubled the the trials in the excel file and added a code snippet to always run the first copies (continueRoutine = False for the second), unless there’s need for repetition, in which case the second copies are also displayed.
This works. However, it slows down my experiment too much (it has to skip around 10-15 copies to get to the ones it needs display), which is sensitive to timing. Therefore, I need a more direct way to tell the loop what the next trial is instead of just skipping my way through lots and lots of routines.
Repeating trials: this is relatively simple in Builder, if the trial to be repeated is the current one. Just nest the trial routine(s) within another loop within the main trial loop.
Jumping ahead to other trials. As you note, this isn’t something Builder is really designed for and so solutions may be messy. You might want to look into calling thisExp.nextEntry() as many times as required, but I have no idea if this will actually work for you or not, or what the implications will be in the data output file.
Custom requirements like this are probably the best case for writing experiments directly in Python rather than using Builder-generated code, which is inherently less flexible.
I thought about that too, but that would be a huge pain, as the trials are all unique. The experiment presents a story one word at a time on the screen. Nevertheless, if nothing else works I will nest a word-per-sentence-loop (which means a separate conditions file for each sentence if I’m not mistaken) in a sentence-loop.
I tried thisExp.nextEntry()but it didn’t seem to do anything. I added it to the ‘Begin Routine’ tab. I looks something like this:
if repeat_mode == 0: # if repeat mode is off -> rep1
if repetition == 2: # skip repeat sentence words
thisExp.nextEntry()
Do I need to put something in the brackets? I looked at the documentation, but I did not learn more there.
OK, I think we have a classic XY problem here. How about you start by describing exactly what you want to do in terms of your task, rather than the software details of how you are trying to implement it.
i.e. describe your task as you would in a methods section. Then describe what aspect of that you aren’t currently able to achieve.
sorry it took me so long to respond. I was on a deadline to finish the experiment. I ended up using a somewhat crude method, but it worked. I will share it here in case someone has the same problem I had.
As I mentioned above, my desired outcome was to have a loop structure, that allows for skipping back in the index.The context is that participants are reading a story word for word. That means only one word appears on the screen at a time and they can see the next word by pressing the space bar. Sometimes it is necessary to repeat the sentence that they are reading at the moment (error detected by the participant). Given that the sentences are unique and are of different lengths nesting a word loop in a sentence loop didn’t make any sense. Or let’s say it would’ve been a lot of work to implement (The way I see it I would have needed a seperate spreadsheet for every sentence).
People kept telling me that if I wanted a loop that allowed for jumping back in the index, I needed to drop the builder and directly write the psychopy script. I ended up doing a bit of that. Basically, I created a loop through the code junk that I could directly control. This way I could still work with the builder and have a custom loop.