OS : Windows 10
PsychoPy version : 2022.1.1
Standard Standalone? (y/n) Yes
I have several stimuli to present, and I am going to set three different duration for these stimuli. I know I can create a corresponding variable in conditions file if I want to set three certain duration(like 1s, 2s, 3s).
However, I am going to set these three different duration depending on the information I enter in the dialog box. For example, if I input 2.5 for the variable ‘MRT’ in the dialog box, these three duration will be (MRT-0.1) seconds, (MRT+0.1) seconds and MRT seconds.
How can I achieve this?
Is it possible to let conditions file know the expinfo I entered in the dialog box?
Maybe, but I think is easier to just create different condition files and then choose the right one based on the expinfo. For example if you have three condition files “duration_1.xlsx”, “duration_2.xlsx”, “duration_3.xlsx” and an infobox called “group”, you can write in the “Conditions” loop box:
$“duration_” + expInfo[‘group’] + “.xlsx”.
Thank you so much, Tandy!
I didn’t fully understand your advice. Maybe I should further explain my situation.
Before the experiment, I will enter the value of ‘MRT’ in the dialog box. And all the stimuli’s duration depends on the value of ‘MRT’.
So, based on the solution you gave, I think we still need to put duration information into condition files, right? But I cannot just set the value of duration like ‘expInfo[‘MRT’]’, psychopy will regard it as a string but not a function.
Images below may help for my explanation!
Based on your situation this is my proposed solution. Create three differenr condition files, with different names (e.g., file1.xlsx, file2.xlsl, file3.xlsl), which are identical but have different value in the imageDuration column (e.g., all 1 in file1, all 2 in file 2 etc.).
Then, when you have to specify wich condition file a loop has to use you can write $“file_” + expInfo[‘MRT’] + “.xlsx”. And in the stop duration for the component $imageDuration.
Basically you choose the duration of the stimuli based on what you write on the MRT box at the beginning of the experiment, just as you wanted
Alright, it surely makes sense to me this time!
Actually I want to randomize all these stimuli. If I follow this way, I think I cannot randomize all of them. But only randomize the stimuli with same duration(or within the same loop set by the corresponding duration file).
Is there anyway for me to use variables in condition files? I think I can just set three variables in advance(see in my pic.1), and then write them in my condition files(pic.2). But unfortunately psychopy didn’t recognize them(pic.3).
Thanks for your help and patience!
Hi, Tandy, I just worked through it by myself. And I’d like to share this solution with you.
Because psychopy recognized my variables as strings, I just use eval() function in python to solve it. So I write $eval(imageduration) for image duration. And it finally run successfully!