psychopy.org | Reference | Downloads | Github

Psychojs - Inner Loop pattern

In psychopy, some attributes of a loop (I’m looking primarily at selected rows right now) are checked just-in-time (conceptually every repeat, though builder treats it differently from most “set every repeat” attributes), before the loop is begun and not during initial instantiation. In psychojs, the selection indices behave similar to “set constant” as everything is added to the scheduler before running (I think? please correct me if I’m wrong!).

One common pattern for outer-loop/inner-loop is to specify a set of trial indices to use for the inner loop in each pass of the outer loop (e.g. show a bunch of condition A trials together, maybe randomizing between condition A blocks and condition B blocks). A common way I do that is to set the row indices to a variable, e.g:

Since the selection indices of TrialHandler.importConditions is only occurring in trialsLoopBegin, and running code via a component in a routine in the outer loop happens after scheduling, I’m not sure how to pass selection indices the best way. It looks like there may soon be a workaround to make trial attributes accessible with a snapshot but this also doesn’t seem quite like it fixes the problem.

Is there a recommended pattern for this in psychojs? I prefer to stay within the builder’s semantic description but would be find using a manual stopgap until we can add it.

Thanks for any suggestions @apitiot and @dvbridges ,
Erik

1 Like