psychopy.org | Reference | Downloads | Github

Assign in Builder to trialHandler.trialList some generated in code list

Hi.

Is it possible in Builder assign to instance of TrialHandler as a value of parameter trialList some list, generated in code Component?
I know only that in Flow in Loop properties I can assign to conditions properties some existing or right there generated file.

OS (Linux):
PsychoPy version (e.g. 3.1.3):

I don’t think this is possible directly, because the loop is instantiated in code before any custom code component within that loop gets to run. i.e. the loop already exists before you can attempt to set its conditions.

The best solution would be to insert some custom code on a routine that occurs before the loop on the flow panel. In that code component, save your generated conditions to a file on disk. Then your loop can just have a hard-coded reference to that newly-created file in its “Conditions” field.

Exactly, only this way I saw. But in the same script, first save to a file on disk, than read from this file: I didn’t like it, so I decided to ask at forum.
Anyway, thanks.

If coding one’s own experiment from scratch, you could pass the conditions as an object (e.g. a list) to the TrialHandler when it is created. Needing to go via a file on disk is just a limitation of the way Builder experiments are structured.