OS : MacOS Mojave
PsychoPy version : 2021 2.3
What are you trying to achieve?: I am running an fMRI experiment. I need to randomize the order of blocks. However, if for some reason the experiment needs to stop in the middle, I would like to find a way to stop the code in the middle and pick back up where it left off.
What did you try to make it work?:
So far, I was able to randomize the order of my blocks using a for loop, where I randomize the order of the four blocks (only one shown).
r = list(range(1,5))
random.shuffle(r) #randomly shuffles the block order
print(r)
for i in r:
if i ==1:
#no switch - one block type
noswitch_log = noswitch(win, fixation, i, image, scenes_df, words_df, num_scenes, num_words, j, curr_word, curr_scene, word, word_item, scene_item_indoor, scene_item_outdoor, scene_list, scene_indoor,scene_outdoor)
noswitch_log['subnum'] = int(subnum)
output_noswitch = os.path.join(sub_folder, 'sub{}_noswitch_run{}.csv'.format(subnum, i))
noswitch_log.to_csv(output_noswitch, index=False)
math_log = math_distraction(win, fixation, i, cur_equation, math)
math_log['subnum'] = int(subnum)
output_math = os.path.join(sub_folder, 'sub{}_math_run{}.csv'.format(subnum, i))
math_log.to_csv(output_math, index=False)
if i ==2: #second block type ...
.......
If I need to stop for any reason, I’m not sure how I would start from the second, or third block, for example, without starting from the beginning of the script. A for loop might not be the best way to do this, so open to other ways of randomizing these blocks! Thanks!!