Variable $jitter as frame duration causes crash

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

OS Windows 10 Pro
PsychoPy version v2022.2.1
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:

Hello all,

I have a paradigm coded with the following sequence:

1.fixation cross (duration = 30 frames)
2. fixation Jitter (which has a text component called jtBlank with a duration = $jitter. $Jitter is a variable defined on my csv file that is read in at the beginning of the loop, set to every repeat)
3. word (duration = participant response indicating wether they already know or don’t know the word).

My jitter variable is supposed to last betwee 50-250 ms. I am using frame duration to be more accurate and my screen refresh rate is at 60 hertz. So I have the jitter variable in my spreadsheet as a random number between 3-15.

Before, everything was working great, I was able to run through the paradigm no problem. Recently, I started getting this errror:
if frameN >= jitter: TypeError: '>=' not supported between instances of 'int' and 'NoneType'.

This specifically seems to happen when my jitter value is set to 11. It doesn’t cause an error for every jitter value at 11 but it does for some. Previously, I did get this error when I had a jitter value of 15, so I just took out all the 15s and changed the jitter value to another number, but I’m further along and don’t want to change all my spreadsheets again. Further, it seems weird this is happening again and I don’t want my paradigm to randomly crash when running subjects in a couple weeks due to a new jitter value causing problems.

When I go to check out the code and where the error is being caused I see this:

if frameN >= jitter:
jtBlank.tStop = t
jtBlank.frameNStop = frameN
jtBlank.setAutoDraw(False)

What did you try to make it work?:

Based on my googling (link here) it seems that the typeError occurs when a value of “None” occurs. Like when my comparison between frameN and jitter = none. But I’m confused on what that means, is it saying like when frameN ends up equalling the jitter that it causes an error? That would expalin why it only happens sometimes for certain values but it makes me scared that changing all the 11s then wouldn’t really fix the issue.

What specifically went wrong when you tried that?:

Again, I’ve tried to “fix” this before by just changing all the jitter values that were giving an error. I am looking for other fixes unless everyone thinks I should I just change all my 11s now to other numbers again.

Thanks in advance!!

Hi @shughesberheim, I agree with your assessment that jitter seems to be None at some point for some reason. To make sure this is indeed the problem, you could insert print(jitter) in your code and have a look in the console to see which value is printed.

Is there anything done in the code to the jitter variable after it’s extracted from the conditions file?

Hi @ajus when I added print(Jitter) it did print None before the paradigm crashed. So that is the problem.

Nothing is done to the jitter variable after it is extracted from the conditions file. It is just called via a basic text component.

You sometimes write Jitter and sometimes jitter. Is this just by accident in your posts?

sorry, that’s an accident. It is always $jitter

The last idea I have is to open the .py file in a text editor and search for jitter to see whether maybe PsychoPy for some reason uses this variable name in the background which causes conflicts or if there’s anything in the code that you are not aware of. If that is not the case you should maybe open a new issue/thread with a title more precisely stating the problem that you’ve now narrowed down so that maybe someone of the pros can help you.

Thanks @ajus. That was not the problem, so I will open up a new thread.

I ended up changing my conditions file to a csv rather than an excel file, and so far that has seemed to fix the problem!