I’m running a memory experiment in which participants would see sentences first ,and then cues. There are 40 Chinese sentences which corresponds to 2 cues and the cues represents remember and forget respectively. I would like to randomize the sentences but the same cue could appear twice consecutively at most. That means the order " F, F, R, R, F "is ok.
I have read psychopy coding function tutorial and tried to follow this link : https://discourse.psychopy.org/t/randomisation-without-consecutive-presentations/8089
I adjusted the code several times, and here is the last version:
trialList = data.importConditions('stimu_all.xlsx') useRows='' trials=data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('stimu_all.xlsx', selection=useRows), seed=None,name='trials') CueWord='' SentenItem='' list_ok=False triple_stim=False import random random.shuffle(CueWord) for thisTrial in trials: SentenItem=thisTrial['SentenItem'] CueWord=thisTrial['CueWord'] while list_ok==False: for i in range(len(CueWord)-1): if CueWord[i]==CueWord[i+1] and CueWord[i+1]==CueWord[i+2]: triple_stim==True break if triple_stim==True: random.shuffle(CueWord) triple_stim=False else: list_ok=True print(thisTrial)
The problem is that only one trial appears in the experiment, so I only see one sentence and one cue, and then the experiment move on to the next routine.
Because I know little about coding, I’m not sure where goes wrong. Could anyone help me please?