Progressively worsening lag in inner loop overshadows routines in outer loop

58 views
Skip to first unread message

Ben Cline

unread,
Sep 20, 2015, 5:14:45 PM9/20/15
to psychopy-users
Hello all,

I'm almost done programming an experiment in PsychoPy. Unfortunately, an earlier problem resurfaced recently. I have an inner loop that is in charge of running one part of the experiment before kicking out to the outer loop. The inner loop is lagging. I have included two screenshots--One of the "counter" routine (with the code component included) and one of the "trial" routine. Note the relevant sections of the flow shown.


Screenshot of counter Screenshot of flow


After 5 iterations through the outer loop (which runs through 10 conditions), the inner loop begins to lag. The 1 second-long "Ready" routine becomes shorter and shorter as the "Fix" component of the "trial" routine sticks and lingers through the end of the routine. After several more trials, the "Ready" routine is entirely swallowed up, and the one-second "Question" routine starts to get eaten away.


At this point, I'm at a total loss as to why this is happening and how to solve it. The code component I added is simple and should not have an effect on the computer. The "trial" routine is not very complex either. The "X" and "O" components both pull their x,y coordinates from an excel sheet (attached). The programming of this experiment is almost complete, and this bug completely derails my ability to use it. If you have any thoughts or suggestions, please feel free to let me know. I have included the compiled script and the experiment as well as a couple of the excel files being used.


Thank you,


-Ben

ImplicitReward.psyexp
ImplicitReward.py
Lists_10_days.xlsx
Trials_20_10.xlsx

Michael MacAskill

unread,
Sep 20, 2015, 7:04:53 PM9/20/15
to psychop...@googlegroups.com
Hi Ben,

In your Experiment Settings, on the Data tab, de-select the "Save Excel" checkbox and let us know what happens.

Regards,

Michael

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/8f21684f-7ea5-404c-b6a1-4c632df34b0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<ImplicitReward.psyexp><ImplicitReward.py><Lists_10_days.xlsx><Trials_20_10.xlsx>

Ben Cline

unread,
Sep 21, 2015, 8:47:28 PM9/21/15
to psychopy-users
Michael,

It appears that has done the trick. Thank you very much! Out of curiosity, do you know why saving an excel file caused such lag?

-Ben

Michael MacAskill

unread,
Sep 21, 2015, 9:42:06 PM9/21/15
to psychop...@googlegroups.com
Hi Ben,

It is best to avoid the Excel data file output entirely and stick with the simple .csv format. 

PsychoPy uses a third-party library for writing Excel files (i.e. it isn't code that the PsychoPy developers have created themselves). I guess it works pretty well for many purposes, but a new spreadsheet tab is created for each PsychoPy loop. In your sort of design in particular, with multiple nested loops, that leads to a lot of tabs, and that process of appending tabs gets slower and slower progressively.

The standard .csv format is a simple text file and each trial's data is just appended as a new row to the end of a single tabular structure. It doesn't really get slower as it is such a simple process.

Perhaps the option to export to Excel needs to be removed, as it can lead to these unexpected problems (naturally, you would have been looking at the actual stimulus presentation aspects rather than the data saving process as being the root of the problem). And having data split across multiple sheet tabs could be seen as a bug rather than a feature… 

Regards,

Michael


On 22/09/2015, at 12:47, Ben Cline <bec6...@bethel.edu> wrote:

It appears that has done the trick. Thank you very much! Out of curiosity, do you know why saving an excel file caused such lag?

-- 
Michael R. MacAskill, PhD 66 Stewart St
Research Director, Christchurch 8011
New Zealand Brain Research Institute NEW ZEALAND

Senior Research Fellow, michael....@nzbri.org
Te Whare Wānanga o Otāgo, Otautahi Ph:   +64 3 3786 072
University of Otago, Christchurch http://www.nzbri.org/macaskill

Jon Peirce

unread,
Sep 24, 2015, 11:37:17 AM9/24/15
to psychop...@googlegroups.com
Picking up on Mike's suggestion, maybe it is time to remove that option from the experiment settings so that people don't select it accidentally. Actually there is another solution, if you  which is to check the box

For non-nested loops it was kinda neat - you would have a loop for practice and a loop for main and they would get a worksheet each, but I think that feature should probably bite the dust in the graphical interface. Users would still be able to use it from code if they so desired (Code Component with trials.saveAsExcel(filename) at the end of the loop).

Any strong objections to getting rid of it?

best wishes
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

-- 
Jon Peirce
http://www.peirce.org.uk

Michael MacAskill

unread,
Sep 24, 2015, 6:03:32 PM9/24/15
to psychop...@googlegroups.com

On 25/09/2015, at 03:37, Jon Peirce <jon.p...@gmail.com> wrote:

Any strong objections to getting rid of it?

Sounds good to me, particularly as the option remains for anyone who wants to insert a single line of code.

Regards,

Mike
Reply all
Reply to author
Forward
0 new messages