Hi! I am making easy oddball experiment with X as a standart as O as deviant stimulus. I am trying to vary the amount of X’s between O’s. There should be from 3-6 X’s between every O. I put O as one routine and X’s as a second. Is there any way i can change in Builder amount of stimulus in every block (i got 50 blocks). Thanks fof help
Hi Filipp,
Please find below one way to do this (perhaps not the most efficient, but speed might not matter so much here). The code creates 100 trials that fulfil your constraints and writes them to a file called trials.csv
that you could then import into your experiment using a loop (with the loopType set to sequential
). You could either run the code as a Python script beforehand or you could add it to a code component in PsychoPy (in the tab Begin Experiment).
You didn’t mention what the correct responses are, so I’ve chosen left
and right
to demonstrate how to add those to the input file.
I’m not sure if the distance between two oddballs is sufficiently variable, but that’s something you will need to decide.
import random
import csv
# note: the number of oddballs will not be constant
# an alternative approach would be to determine the number of oddballs first
nrOfTrials = 100
minDist = 4 # that is: o x x x o (number refers to min. distance to next o)
maxDist = 7
count = 0
distCount = 0
std = "x"
odd = "o"
stdResp = "left"
oddResp = "right"
stims = ["stim"]
resps = ["corrAns"]
oddballDist = random.randint(minDist, maxDist)
#print("new oddball distance: {}".format(oddballDist))
while count < nrOfTrials:
count = count + 1
distCount = distCount + 1
if distCount != oddballDist: # a standard trial
stims.append(std)
resps.append(stdResp)
#print(distCount)
else: # we need an oddball
stims.append(odd)
resps.append(oddResp)
oddballDist = random.randint(minDist, maxDist)
#print("current distCount: {}".format(distCount))
#print("new oddball distance: {}".format(oddballDist))
distCount = 0
#print(stims)
with open('trials.csv', 'w') as f:
writer = csv.writer(f)
writer.writerows(zip(stims, resps))
Hope this helps.
Jan
Thank you very much, it seems to be working
I need to change my experiment a little bit and i am wondering if you (or somebody else) could help me. Number of trials should be 700 (i can change that) but the number of odds should be fixed (100 odds). That means that there will be 600 standart stimuli, 3-9 per one repetition with average 6 standard stimuli between two odds in whole presentation. Is it possible to do this?