| Reference | Downloads | Github

Crashes after 30 mins/ wavs have clicks/ can't use MIDI files



I’m using psychopy for a pitch to melody association training task, which collects data as it goes.

My coding ability is much better than it used to be, but still pretty terrible really. It’s got to the point where I can usually get python (and matlab) to do what I want it to do, but in an incredibly inelegant and verbose kind of way, with lots of room for stupid mistakes along the way… As such if you could pitch any responses at the level of dribbling idiot then that would be greatly appreciated… thanks!


I have a huge while loop that I intend people to use for long periods of time (e.g. an hour). It works basically fine until about 30 mins in when it crashes my computer… I’m thinking this might be because the experiment is saving so much data by this point that it can’t handle it anymore… is there any way in which I can save the data to the logfile/excel file etc as I go, and routinely flush out the saved data from psychopy as I do so?


The .wav files play with weird clicks in them - has anyone else had this issue? I’ve checked the files themselves and they seem to be fine.


I’m using 4350 .wav files, from which a function I’ve created picks a few semi-random ones (between 12 and 24, depending on the progression through the training) on each time through the loop. These files unsurprisingly take up a pretty ridiculous amount of space… (I intuitively wonder if the sheer quantity of files is responsible for some of the performance issues previously mentioned, although I’d have thought it isn’t as conditions are replaced on each iteration of the loop - so it should only be having to handle between 12 and 24 files at any given time). This would be a lot more space efficient if I used MIDI files instead, but I couldn’t get PsychoPy to run when I tried using MIDI files - is there a trick to this?

Thanks for the help!


Any thoughts on this? Really struggling… Best wishes all!


Regarding Issue 2: What version of PsychoPy are you using? Recently there was a hanning bug fix to remove the clicks - see Github #1718.


Thanks for that - I’ve been using version 1.85.4 - is that one ancient now then? Thanks for the tip off


so looks like 1.90.1 is the current? I’ll download and see if it fixes it - thanks :slight_smile:


Ok so now I’ve updated PsychoPy my code doesn’t work anymore. Getting this:

Traceback (most recent call last):
File “/Users/sam/Downloads/AP_experiment_1/”, line 872, in
exec(paramName + ‘= thisTrial.’ + paramName)
File “”, line 1, in
AttributeError: ‘OrderedDict’ object has no attribute ‘audioStim’


I’ll give this some thought tomorrow… thanks for your help :slight_smile:


Looks like you aren’t alone in encountering this bug:

@dvbridges this seems like a general issue we should get to the bottom of. I seem to recall some recent change where there was a shift to ordered dicts, perhaps by @richard , to yield more predictable behaviour, although that change may not itself be the source of this error.


Thanks @Michael, I will try to recreate the error and see what is happening. Hey @richard, if you have any insights it would be good to hear from you.


Not wanting to drop this in your lap, David, was more musing to myself but thought I should get it noted down.

@Sam_Leak: any chance you could help out by producing a minimal reproducible example of this latest bug (i.e. one that doesn’t need access to your 4350 sound files…)? It would help a lot in figuring out what is causing this.


Hi Michael

I can try to do that on Friday! A bit hectic until then…

In other news I had to go back to an older version today in order to check a student’s work. I had been on 1.85.4 (prior to yesterday’s change up to 1.90.1), but I decided to try going back to 1.85.6. Everything worked fine again. The clicking on the audio was still there (felt like there was a lot less of it than I was having on 1.85.4 - should that be the case, or is that just a random occurrence?)

The other weird quirk is that it’s started saving two copies of the data file for every run of the experiment…?

Anyway I’ll get on with trying to make a a minimal reproducible example for you on Friday. If you’ve already found the issue by then then lemme know!

Any thoughts on Issue 1 from above?

Thanks :slight_smile:


W/r/t issue 1 you should be able to set it up so you have a single data structure for a line of data that writes immediately and gets reset in the next loop. It might still run into issues but that’s the best I can think of.

The basic structure would be something like:

with open('fileName.csv', 'ab') as fp: #ab because windows. 
    a = csv.writer(fp, delimiter=',',lineterminator='\r\n')
    data = yourData

Then you can just rewrite the “yourData” structure on every loop.