Controling for matching trials in block-design paradigm

Dear Psychopy experts,

I am using the Builder to program a task paradigm with blocks of faces and houses. I used as a reference the psychopy demos randomisedBlock which is very useful and helpful by the way and works very well

The paradigm has a task which is a 1-back e.g., participants see a face and have to press a button if it matches the previous one (or no button if it does not match). I would like, if possible, to have the order of the stimulus randomised and to also have in every block the same number of match and non-match trials (e.g. 10 trials could be 2 match/same trials and 8/non-match different trials).

However, this is when I come to a struggle because I have the list of stimuli in excel files and if I choose to randomise the presentation of the stimulus I lose control of the number of match and non-match trials. If I choose the option sequential this is not a problem because I know the order of stimulus presentation and I can control for the number of match and non-match trials (I can organize this so that in every block I have for instance 2 match and 8 non-match trials)

I other words my question is if it is possible to have the stimulus presentation randomised and still control for the number of match and non-match trials? So that this is consistent across different blocks? Or should I use in this case the sequential option?

I hope the message is clear enough but any questions and documentation I would be pleased to send.
Many thanks in advance any help would be very appreciated as I am not experienced in programming.



Have a look at my PM N-Back demo to see how I randomise an N-Back task. I preload the stimuli in random order and insert the repeats during the construction of the trial list.

I’m currently using similar code for a student who just wants N-Back with no Prospective Memory targets.

Thank you the reply. I had a look at your demo but not really sure still how to sort this issue. Does this require coding or can it be done with builder? Perhaps is a problem with the trial list? I send the task as I have programmed in the builder and the trial list of the faces block

tarefa_faces.psyexp (11.9 KB)
facesBlock.xlsx (12.1 KB)

All my demos are created in Builder with code components to customise.

Thank you but I could not find the file with the experiment to upload on psychopy. Could you perhaps be so kind to let me know where is this file with builder experiment of your PM N-Back task so that I could upload it and see how did you set up the task?

It’s in the Gitlab repository (click on code). However, try this one, which includes the code for how to skip the PM task in setup.

pm nback.psyexp (58.6 KB)