I just added a loop to my code so that my trials are broken up into ‘blocks’ (not a blocked design, really just for the sake of giving participants a break every few minutes), and it has done something funky to my log saves. As I have it now, my script is only logging information about the last trial in the loop. I saw a thread with a similar issue, but they were only iterating through trials, not blocks and trials, and I’m not quite sure how to interpret the answer given there to my code.
# Iterate through conditions
for block_id in block_order:
block_content = trials[trials.blockID==block_id]
block_content = shuffle(block_content)
blockNum += 1
prompt = 'This is block %s out of %s.\n\nPlease use this time to blink, stretch, adjust yourself. Remember to hold still and try not to blink when you advance to the next block. \n\nPress any button to continue.'%(str(blockNum), n_blocks)
present_text(prompt)
for _, trial in block_content.iterrows():
correct_answer = random.randint(1, 2) == 1
# Present Fixation: On time: 300ms Off time: 300ms
present_fixation()
# Present Stimulus: On time: 300ms Off time: 300ms
present_sentence(trial)
# Present Task Word: On/Off time: inf
if trial.cond != 'cons_str':
answer, rt = present_answer(trial, correct_answer)
correct = True if (correct_answer and answer == '1') or (not correct_answer and answer == '2') else False
print("Correct?", correct)
trialNum += 1
exp.addData('participant', participant_name)
exp.addData('trialnum', trialNum)
exp.addData('stimulus', trial.stim)
exp.addData('condition', trial.cond)
exp.addData('correct', correct)
exp.addData('reaction_time', rt)
exp.addData('blockID', trial.blockID)
exp.nextEntry()