Separate .csv output file per block and counterbalancing blocks across participants - dynamic updating


I am using PsychoPy and collecting MEG data.

I have 8 blocks per participant. I need 8 separate .csv output files from Psychopy for each block (this is because my MEG data will be recorded in 8 separate files due to recalibrating the scanner).

To minimise the risk of crashing, I wanted to run either 8 separate PsychoPy script, or run the same script 8 separately 8 times for each block. This is to minimise the risk of crashing and to easily have 8 separate output .csv files.

Is there a way to develop task such that it selects a specific set of stimuli based on participant number AND the block number for that particular participant? This would be to run the same script separately and adjust the order of stimuli depending on which block it is. I think this could be described as dynamic updating of the order of stimuli depending on participant number AND block number provided in the box at the start of the experiment.

Or is it better to simply keep 8 separate PsychoPy files for each block? I realise that this is not automated and not streamlined. However, I will have a small number of participants.

Thank you.

Hello KatKat

I am running MEG-experiments myself and while there are several blocks for the MEG-recording (several data-files), I have one experiment script. Block is coded as an additional variable in the Excel-file.

Best wishes Jens

Dear @JensBoelte ,

thank you for your kind reply.

May I please ask whether you reset the time for each block?

Since each block will be a separate MEG file, I believe it would be best for each corresponding behavioural .csv file to have a timer starting from 0, rather than an absolute time from the start of the experiment.

I acknowledge that it is possible to align all of that with triggers, but for clarity I do think it is best not to run one timer in PsychoPy for separate MEG files (especially when breaks between blocks may be very long - for me there will be a 15 min break halfway through).

What do you think? Do you reset timer per block within the same script?


everything is trigger controlled. Start experiment, start recording, end recording aso. Which timer do you want to reset?

Best wishes Jens

the timer which controls time in the behavioural output .csv.
In the output file, there is always a ‘behavioural’ time representing that a stimulus was presented, participant pressed a button, a text was displayed etc. These times are relative to starting the PsychoPy script.

Therefore, if we have several blocks, the times for given events in the last block will be in magnitude of minutes/hours (if the experiment is long), e.g/, that a given stimulus was displayed at 1h20min35sec29milisec from the start of the experiment since that is when the timer started. At the same time, the corresponding MEG time will be much less, e.g., 5min20sec34milisec since timer restarts with every new MEG file.

This is not very important as everything is trigger controlled as you said, but still may be helpful for sanity check to have the behavioural output and corresponding MEG file both starting from ‘0’ at the start of the block, rather than the PsychoPy running the timer from the start of the experiment (which may be very long).

Hello KatKat,

ok, I see. You could use your own timer which you reset at each block start, but I admit that it might be cumbersome. I guess I would solve the problem in R.

Back to your question: I don’t know of a way to have results files per block and to reset the timer per block. So I would probably use one PsychoPy-file and select the stimuli to be presented based on the block-number that you assign manually.

Best wishes Jens

Dear @JensBoelte,

thank you for your kind reply. That is precisely what I did. It also has an extra small benefit of being able to repeat blocks in case of a crash or other reasons without much problem.

Thank you!

1 Like