Loading Psydat Files Generated from Older PsychoPy Versions

Hi,

I am working on the standalone PsychoPy3 platform and I have been trying to load psydat files generated from PsychoPy version 1.85.1. Running “fromFile(filename)” gives me the following error:

Exception ignored in: <bound method ExperimentHandler.del of <psychopy.data.experiment.ExperimentHandler object at 0x10a9010b8>>
Traceback (most recent call last):
File “/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/data/experiment.py”, line 109, in del
self.close()
File “/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/data/experiment.py”, line 391, in close
if self.dataFileName not in [’’, None]:
AttributeError: ‘ExperimentHandler’ object has no attribute ‘dataFileName’
Traceback (most recent call last):
File path_to_script, line 21, in
datFile = fromFile(filename)
File “/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/tools/filetools.py”, line 55, in fromFile
contents = pickle.load(f)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xd5 in position 0: ordinal not in range(128)

I then tried opening the psydat files after unpickling them using the following:
with open(filename, ‘rb’) as f:
datFile = pickle.load(f, encoding = “latin1”)

However, it seems that this opens the psydat files as an ExperimenterHandler object, rather than a TrialHandler object, so I cannot use commands such as datFile.data to extract the data conveniently. Instead, I have been looping through each trial as a dictionary and appending the trial information to lists, but I would ideally want to avoid this to make sure the code is not skipping through any trials.

I would appreciate your help resolving this issue.

Thank you!

a psydat file is literally just a pickle file of either a TrialHandler or an ExperimentHandler. Iit used to be just a TrialHandler but then ExperimentHandler objects became more important (because they can save data from multiple loops or from objects outside a loop) and now all Builder experiments create those instead.

ExperimentHandlers have an attribute loops each of which is a TrialHandler (or StairHandler etc) and you can carry on as before, but there’s also an attribute called entries that provides a list of dicts, one dict for each trial, and this is what is used for ExperimentHandler’s own methods e.g. to save data

Hi Jon,

Thank you for explaining about ExperimentHandler objects. I have been using entries but I wanted to avoid manually looping through each trial to extract the relevant information. But with the loops attribute, I started pulling out the information from all trials together. Thank you for pointing it out.

I appreciate your help!