My question concerns using continue from python within a code component (see screenshot).
My position of ‘continue’ seems almost correct because its close to doing what I want (repeat the actions of the for loop if the position value is too large and so prevents it from producing an x position that is off the screen).
However it means that for the current trial, no value is returned (leaving None in my data file where the x position should be- see screen shot) and uses the reselected value for the next trial.
Is there a way to code the loop so that it repeats and returns a reselected value for the current trial.
Nice implementation. So it essentially sounds like you want to not add data to your data file on that trial if a value has been selected is that correct?
if so, can you make use of the trials.addData() method to only save certain values if specific conditions are met?
Thanks for responding so quickly. That’s not quite what I am trying to do. I have created a list for my x positions (cue_coin_positions) and because I am using a gaussian distribution to create that list, the value selected by the for loop is sometimes greater than the screen’s x axis (> 0.6 height units) and so it is either partially or entirely off the screen (e.g x = 1.3).
On any given trial, if an ‘off the screen’ value is picked I would like it to repeat the steps of the loop to pick out another value for the x position from the list for that trial.
For the position in my stimulus builder component I have (cue_coin_position_rounded, 0) because I am only using the x axis.
So I am wanting to save all of the positions from this variable (for which I have used the addData() method) but I am only wanting to use them as stimulus positions if they are on the screen.
Let me know if you need any more info.
ok sounds like you might want a ‘while’ loop around your for loop.
for ...#the things you do in your for loop
This would mean that the for loop is repeated until a value that meets the criteria of the while loop is met - does that sound a bit closer to what you want?
Yes thank you Becca, that’s perfect