Invalid Parameter Error - Not Exiting Loop Properly?

I have created an experiment where blocks appear on the screen and participants respond using the keyboard. I’m using excel sheets and loops to change the visual details of the trials without needing a bunch of separate routines. However, I currently have it set so that participants run through Instructions → Trials → Survey Questions with some nested loops. Then they run through the same routines, with different conditions files in the loops.

The experiment works perfectly the first time. The second time, when it is the same routines but different condition files, it only gets through the first set of instructions and the practice trials. The experiment exits before the survey questions open, and I get an error “Invalid parameter. None is not accepted as value.”

The error code seems to suggest that I am trying to create a button of size “none”, but there is no button in the next routine, and it works fine for the routine in which there is a button. There is nothing in my excel files that is labeled explicitly as “none”. The routines themselves work individually - I have put the routine by itself with a loop defined by an individual file, rather than a conditions file in a nested loop, and it works as intended. Based on my troubleshooting, it seems like issue is arising in the transition from the trials routine to the survey questions routine - maybe in exiting the loop or starting the new one?

I cannot figure out how solve the issue, in part because I can’t figure out exactly what the error is trying to tell me. Below is the actual verbiage of the error, along with screenshots of the routines/flow. Any insight is much appreciated!

Error Code:

File "/Users/cpatton4/Desktop/Research/Difficulty Perception/", line 1819, in <module>
  File "/Users/cpatton4/Desktop/Research/Difficulty Perception/", line 1053, in run
  File "/Applications/", line 1916, in setSize
    setAttribute(self, 'size', val2array(newSize, useNone), log, operation)
  File "/Applications/", line 175, in val2array
    raise ValueError('Invalid parameter. None is not accepted as '
ValueError: Invalid parameter. None is not accepted as value.
################ Experiment ended with exit code 1 [pid:39480] #################
1130.8978     EXP

Screenshot of experiment and trial that runs only once:

Example of Excel sheet used to run the loop around the trials:

Could it be one of the parameters of the loop around the survey. What is that loop for?

I have three questions appear during the survey and want them to appear on different screens, but they all are formatted the same, so I have the questions in an excel sheet. The loop just reads in the questions. It works perfectly the first time I call the routine and the loop with the sheet (the “surveyTrialsLoop”) but it doesn’t work the second time (“surveyTextAutoLoop”).

The survey question routine looks like this (it is set to “set every repeat” - I checked)

with survey_text being a variable $SurMess from the excel sheet, which looks like this:

Here’s the loop information, if that helps:

The loop and routine are, theoretically, exactly the same each time. I only have a different name in the loop because I can’t name them the same. If there is a way to repeat that loop/routine from the first time, I am totally open to that too.

In case anyone comes across this in the future, here is the solution:

I saw in the data output file that PsychoPy was trying to start an 11th trial, even though I had only put 10 trials into the Excel sheet that was being read in. I came across this discussion, so I exported my Excel file to a .csv and opened it in TextEdit. There were about a dozen empty rows, denoted by a lot of commas. I deleted every “empty” row and column in my spreadsheet (control+shift+down arrow), resaved it as an Excel file, and that seems to have fixed the problem.

1 Like