OS (e.g. Win10): MacOS Sonoma 14.0
PsychoPy version (e.g. 1.84.x): v2023.2.1
Standard Standalone? (y/n) Yes
What are you trying to achieve?:
Over the course of many trials, my routine estimates the participant’s point of subjective and stores the per-trial value in the two variables that follow: 1) BG_PSE_estimate; and 2)noBG_PSE_estimate. The values for both variables are stored in the .csv file logged once the experiment is over. But is there a way to access these values while the experiment is still running?
Ideally, I’d like to average the values of BG_PSE_estimate and noBG_PSE_estimate so that I can obtain both values without having to halt the experiment. To that end, is there a way to reference the row-by-row values stored for each trial?
Any value you have access to during an experiment can be saved into a variable, list or dictionary so that it can be used again later. Saving values into the expInfo dictionary will also add the value to every row of your data file.
Thank you for your response.
If I elaborate what I’ve already achieved with my code, could ask for your insight on the part where I’m stuck? (Although my question ultimately boils down to the final paragraph marked in bold, the intervening paragraphs provide potentially useful context for what I’m trying to achieve).
For the sake of simplicity, I’ll refer to both variables I’m collecting as “PSE_Estimate.”
In my experiment, once a participant completes a trial, their “PSE_estimate” is calculated by the code I’ve got already. The part I’m stuck on is how to store each trial’s corresponding “PSE_estimate” so that, across all trials, I can calculate the total average.
One idea I had was to initiate a variable called “trial_counter.” Using “trial_counter” as a list index, I wanted to store each trial’s “PSE_estimate”. However, I seem to be running into trouble with initiating the empty list.
Thus, concerning list initiation, if I don’t yet know how many trials I want, is there a way to initiate an empty list that will contain as many entries as there are trials?
The following should might help.
PSE_List = 
End Routine (when calculated)
Begin Routine (after loop)
PSE_Average = sum(PSE_List)/len(PSE_List)