Running a classic oddball paradigm

Hello psychopy community!

Feels like I’m shouting into the void but might as well give it a try! I’m a grad student in applied neuroscience writing my thesis about cognitive activity during an oddball paradigm task. I am having trouble randomizing my two stimuli so that the 1 target :4 non-target ratio is fulfilled. I just end up hearing a series of sounds in chronological order without randomization. I feel like its close but still there is a crutial building setup that is missing…

There is no way for me to attach an image of the builder view here but if someone could offer some advice it would be much appreciated!

Thanks to the community and happy building,

gilo

What would this look like? Assuming X is common and Y is oddball, is the 1:4

a) strict ( 1 in every 4)

I would do foo=[ “X”, “X”, “X”, “X”, “Y” ] and then numpy.random.shuffle foo every 5th trial. This could produce Y X X X X X X X X Y chains and X X X X Y Y X X X X chains.

b) statistical (on average)

similar to a but larger scope:
x=[“X”] * 40

y=[“Y”] * 10

numpy.random.shuffle ( x+y ) after every 50 trials

c) never more than 4 X before 1 Y. Trickier.

The point is to figure out your constraints (about min and max runs of X or Y) which includes your scope (over 5 trials, or over the entire stimulus list). If there are constraints, you are best to generate your trial descriptions BEFORE running rather than on-the-fly during.

Are you using a loop pointing at a spreadsheet defining the stimulus types? If so, check it’s random, not sequential.

So your suggestion is to edit the excel file or the code itself? Definitely looking to keep this as simple as possible. I would like to have an xxxyxyxx sequence, or some kind of variation like that. I have managed to make it work just barely, e.g. xyxyxy. however this seems too predictable to get the P3 and N2 components that we are looking for.

using a loop, yes. but the builder setup has both sounds (target and non-target), and havee not been able to find the relevant excel sheet. But I will check that it is random.

To clarify the different approaches (1 or 2 ):

  1. create trial spec files BEFORE you run. This means that you will use some other program (like a spread sheet, R, etc) to generate a file (probably 1 per subject) that contains your randomized trial descriptions. Typically the file has one line per trial so a 4 trial file might be

x y x x
x x y x
y x x x
x x x y

if this file happens to be called “s1-oddball.txt”

when your experiment (psychopy) starts, the file is read in and your trial loop just uses the lines that you read in (probably as a list) in order. Using the above, your internal list might be
trials=[ [‘x’, ‘y’, ‘x’ ,‘x’], [‘x’, ‘x’, ‘y’, ‘x’], [‘y’, ‘x’, ‘x’, ‘x’],[‘x’, ‘x’, ‘x’, ‘y’]]

ignoring for now how we get x to be sound1 and y to be sound2, then your trial loop would be

for this_trial in trials:

for s in this_trial:

  s.play()
  core.wait(s.duration + <silent time between sounds> )
  s.stop()
  1. inside psychopy, take the list [‘y’, ‘x’, ‘x’, ‘x’] and let psychopy randomize it.

It comes down to pregenerating the subject/trial file and reading it in to psychopy versus letting psychopy do the work. There are merits to either way.

Hello @gilo20

To elaborate on the explanation provided by @ben, I suggest doubling or tripling the number of lines in s1-oddball.txt. In an experiment with a condition file of just four lines, the fourth trial can be predicted by the participant. Having more stimulus lines makes this prediction more difficult.

Best wishes Jens

I’ve updated an old Oddball task and added it to demos. This one has 10 trials in the conditions file - two oddball and eight standard. To keep the demos simple, it does not attempt to prevent consecutive trials being oddball trials. In theory you could get four on the trot if the two oddball trials randomly appeared at the end of one block of ten and at the start of the next block.

According to Gemini, four oddball trials in a row will occur on average in about 1 in 400 runs of 60 trials, and runs of three oddball trials will occur in about 1 in 25 runs.