Problem with practice trials

Hello people,

I am having problems with the code of my experiment. I needed to create practice trails that are different from the main trails and from the practice trails I want to take only 6. I have try to do it in the coder but now the practice trails do not appear when I run the experiment.

Here is the code where I think there is problems:

Define practice and main trial lists based on the ‘Practice’ column

practiceTrials = [trial for trial in trialList if trial[‘Practice’] == 1]
mainTrials = [trial for trial in trialList if trial[‘Practice’] == 0]

Present trials

for procedure in [‘practice’]:

practice_experiment = data.TrialHandler(trialList = practiceTrials, nReps = 1, method = "random") 
thisExp.addLoop(practice_experiment) # add a trial loop to the experiment

for procedure in [‘main’]:

experiment = data.TrialHandler(trialList = mainTrials, nReps = 1, method = "random") 
thisExp.addLoop(experiment) # add a trial loop to the experiment

# Main or practice trials

if procedure == 'main':
    maxTrials = len(mainTrials)
    
    # Repeat instructions
    instructionsRepeatText.draw()
    win.flip()
    resp = event.waitKeys(keyList = ['space','escape'])
    escape(resp)
else:
   maxTrials = npracticeTrials
   selectedPracticeTrials = practiceTrials[:maxTrials]

# Iterate over trials    
for t, trial in enumerate(practice_experiment if procedure == 'practice' else experiment):    
    if t < maxTrials:
        
        # Show fixation cross
        fixationText.draw()
        win.flip()
        core.wait(1) # Duration = 1000ms
        
        # Show target images ... etc.

Thank you in advance for your time.

Hi There,

Is there a reason to create this in coder rather than using builder? In Builder this would be a case of using the same routine twice, but with different loops, in each loop you can feed in a different set of trials (e.g. your practice and main trails).

I attach a psyexp file here to demonstrate the structure, note how different spreadsheets are fed into the practice loop and main loop.

Hope this helps,

Becca
practice_demo.psyexp (10.1 KB)