PsychoPy experiment doesn't load

I made a new experiment using the Builder view, but when I try to load it, it fails and I get the following error message

Failed to load C:\Users\adrian\Insync\Work\Projects\SoL\Pic viewing 1.psyexp. Please send the following to the PsychoPy user list
Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1473, in fileOpen
    self.exp.loadFromXML(filename)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\experiment.py", line 596, in loadFromXML
    self.flow.append(self.routines[elementNode.get('name')])
KeyError: 'trial'
Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1634, in OnFileHistory
    self.fileOpen(filename=path)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1485, in fileOpen
    self.updateAllViews()  # if frozen effect will be visible on thaw
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1718, in updateAllViews
    self.flowPanel.draw()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\flow.py", line 644, in draw
    thisTerm = self.loops[thisLoop]['term']
KeyError: 'term'

Iā€™m using the latest version of PsychoPy on Windows 10.

Adrian

Edit - very limited investigation suggests it might be something to do with trying to preload an image during an ISI period. Possibly an avenue for investigation?

One way to corrupt an experiment file is certainly to set a stimulus to update during a static period (e.g. ISI) and then delete that static period. Iā€™m not sure if thatā€™s what youā€™ve done though. Could you post the experiment file so we can take a look, but also post any hints about what you did before the problem started happening? The error message is complaining about a missing object ā€œtrialā€ and a missing object ā€œtermā€ so itā€™s probably related to those objects/variables

cheers

I donā€™t ā€˜thinkā€™ I created and then deleted a static period (but I might be wrong). Although, I might have deleted/modified the default ā€˜trialā€™ routine that might have contained a static period. Iā€™m also displaying a fixation cross during the static period (but itā€™s onset and offset are not within the static period). I donā€™t remember naming anything ā€˜termā€™ though. Iā€™ve uploaded the troublesome psyexp file.

Thanks for your help with this,

AdrianPic viewing 1.psyexp (12.2 KB)

OK, hereā€™s your fixed experiment:
Pic viewing 1.psyexp (12.2 KB)

I believe you found a new way to break the static period, by renaming a routine that contained one. Weā€™ll have to add that to the list of static component errors.

But the fix was actually easy when you know how: your experiment was complaining that it couldnā€™t find the ā€˜trialā€™ routine so I opened the experiment in a text editor and removed the line where it tried to use the ā€˜trialā€™. Then the experiment would load again, just with a gap in your flow where the ā€˜trialā€™ had been.

Thanks for the help!

Iā€™m pleased my incompetence has proved at least slightly useful for once.

I had a similar issue yesterday (just as I was about to demonstrate a practical prototype to a lecturer :-S) - it looks like when routines are renamed they are not removed from the namespace immediately (for instance, if you rename a trial called trial as trial, the routine is named trial_2.

Interestingly been getting some weird flow errors too - for instance in the replication below all the flow representations have vanished but the experiment still worksā€¦

Might need to add this to general issues

We think this was caused by renaming a Routine; this was a new feature and apparently not working correctly as of 1.84.1. The bug that led to this issue is now fixed and will be included in next release (1.84.2).

For anyone else having this issue you can fix your file manually like this (make a copy of your experiment first in case you really mess it up!):

  • open your .psyexp file in a text editor (e.g. notepad+ on windows, textwrangler on mac)
  • near the bottom of the file youā€™ll see a section describing the Flow
  • find the line referring to the Routine name that you changed (no longer exists) and simply change it to the name you changed it to (exactly, with matching capitals)
  • For example, if you changed the trial routine to be called presentPics then you find/need to change the like this:
  • <Routine name="trial"/> :arrow_right: <Routine name="presentPics"/>

If you canā€™t make that work then post a copy of your experiment here for us to change for you (folks you can ā€œunwatchā€ this thread if you donā€™t want updates!)

Hi Jon

I dont think we changed any of the routine names. Here is the file below:

beTaskedit.psyexp (21.4 KB)

If I replace
<Routine name="response_2"/>
with
<Routine name="confidence_2"/>
the experiment works, and confidence_2 was otherwise not on the Flow, so Iā€™ve got a strong suspicion there was a ā€œrenameā€ performed at some stage :wink:

Which is fine - you did the right thing - itā€™s just that we had a bug in the renaming.

If Iā€™m right then this is fixed:
beTaskedit.psyexp (21.4 KB)

I was having a similar problem, but wasnā€™t able to figure out the solution. I have attached my psychoPy experiment here if anyone wants to take a look and help me out. Thank you in advance.

MentalRotation.psyexp (50.7 KB)

As explained in the rest of this thread, these errors are coming about from Routines that have been renamed and they can be fixed in a text editor.

In your case you created a routine called InsterStimInt and then renamed it to InterStimInt so you needed to find the line that said
<Routine name="InsterStimInt"/>
and replace it with
<Routine name="InterStimInt"/>

MentalRotation.psyexp (50.7 KB)

Thanks Jonā€¦ Very helpful as always!!! Hope you are well. :slight_smile:

1 Like

Hi!

We have the same problems with our experiment :frowning:
We get the following error message:

  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1718, in updateAllViews
    self.flowPanel.draw()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\flow.py", line 644, in draw
    thisTerm = self.loops[thisLoop]['term']
KeyError: 'term'

This is the experiment file:
TatataSuono.psyexp (66.8 KB)

Thank you for your help!!

Martina

Hi Martina - the solution to this is detailed above (see the post with the green tick) and the underlying issue has been resolved as of 1.84.2.
BW

Oli

Also, in the new release (1.84.2) Iā€™ve set it to at least load the experiment when this has gone wrong and all youā€™ll need to do is re-insert any missing Routines (ones that have been renamed) back into your Flow.

I am running into this same bug with version 3.05 (Mac 10.13.6). Further, when I open my experiment, no flow appears in the builder. When I try to run the experiment anyways, it does not result in an error either-it just exits out of the experiment before it can start and returns me back to the builder. I know it has to do with the fact that I renamed ISI and sound components. Therefore, I have been looking really closely through the file in a Text Editor to see if there is a mismatch among component names. Unfortunately, I cannot find anything that is misnamed (I may have not seen something). The only thing I see is that the ā€œflowā€ segment of the code is missing in the text editor file. It does not show any information pertaining to the flow of the experiment.

I have attached a screenshot of the builder without the flow diagram and have uploaded my experiment (the experiment is a second version as i have already created a copy in accordance with your suggestion above). I really appreciate your help!

TestP3B1MR_v2.psyexp (27.6 KB)