psychopy.org | Reference | Downloads | Github

How to save file including presented stimuli list

Hi, I’m not used to using code, so I’m having a lot of problems. I would really appreciate it if you could help me.

In my experiment, I used the following code so that the stimuli could be printed on the monitor.
However, I don’t know how to save the list of stimuli presented like this to a file.

I’d like to add a code to the data file (.csv) of Psychoppy, and I’d really appreciate it if you could help me with what to do.

In summary, I would like to know the code that the stimuli printed on the screen can be saved as a list in each of this trial.

======
def replace_str_index(text,index=0,replacement=’’):
return ‘%s%s%s’%(text[:index],replacement,text[index+1:])

divPath = feedback_21.split(’/’)

dotIdx = divPath[2].index(".")
udbIdx = divPath[2].index("_")

if int(divPath[2][dotIdx-1]) == 1: #L/R check side
side = leftTrial.pop()
else:
side = rightTrial.pop()

print("divPath: "+divPath[2])
checkPth = ‘Check.png’
if len(divPath[1]) == 2: #S1
imgFile = divPath[2][:udbIdx+1] + “S” + divPath[2][udbIdx+1:]
imgFile = replace_str_index(imgFile, dotIdx, str(side))
checkPth = divPath[0] + “/Check/” + imgFile

elif len(divPath[1]) == 3: #S1R
imgFile = divPath[2][:udbIdx+1] + “S” + divPath[2][udbIdx+1:]
imgFile = replace_str_index(imgFile, dotIdx, str(side))
checkPth = divPath[0] + “/Check_R/” + imgFile

print("chkPath: "+checkPth)

=======

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): MacOS 10.15 +
PsychoPy version (e.g. 1.84.x): 2021.1.2
Standard Standalone? (y/n) y

To save this to the data file put

thisExp.addData('chkPath',checkPth)
1 Like

@wakecarter Thank you so much

Few seconds ago, I’ve written in line to “thisExp.addData(‘img’,checkPth)”

There’s still a lot to learn.

Thank you again.