How can I avoid two trials in a row that belong to the same condition?

Hello everyone. I am working on a Stop Signal Task and would like to add a code component that would prevent the task from generating two consecutive stop signals. In other words, after a stop signal I would like a go signal to necessarily appear.
I am asking for your help because I do not have a clear idea of how to proceed. I specify that the conditions are specified in an excel file.
Thank you to anyone who will try to help me

Hello

this question has been asked before.

look here

here

or here

Notice that this constraint will result in a predictable order, after each stop-signal there will be a go-signal.

Best wishes Jens

Hello and thank you for your response. I saw the topic that you sent and I think I understood how to do it, however, I have a doubt. In the example that you sent the conditions are equidistributed, that is, they do not appear with different probabilities. So I was wondering how to do when the conditions have different probabilities of appearing. I am attaching an excel file similar to the one I am using so as to make the idea better. The “codice” column helps me recognize each type of condition, and the go’s are indicated either by “1” or “2.” My goal is to make sure that no two stops appear consecutively.

conditionsv1.xlsx (14.7 KB)

Hello MTH

What did you try? What did not work?

Best wishes Jens

I tried the same code but i added a condition near the first if

list_ok = False
double_stim = False
condition = " "
ldx = 0

index = [x for x in range(250)]
shuffle(index)

conditionList = [x for x in range(250)]
picList.sort()

while list_ok == False:
for i in range(len(picList) - 1):
# check for equal neighbours:
if conditionList[i] == conditionList[i + 1] and (codice!=1 or codice!=2) :
double_stim = True # D’oh!
break # can stop checking on this run
if double_stim == True:
shuffle(conditionList) # try a new order
double_stim = False
else:
list_ok = True

I also added the piece of code that must be written in the begin routine and in the end routine. And two consecutive stops continue to appear

Hello MTH,

I can’t really follow your code. Anyway, this is a brute-force approach which will hardly be ever satisfied given the distribution of your conditions. Therefore it might take a “very” long time until a solution is found. You might want to try a different approach for your pseudo-randomization. Something similar to

1. randomly select a condition
2. check its value 1, 2 or …
3. if you select a 2, pick another randomly selected condition next

Best wishes Jens

1 Like

Thanks but how can I “recall” my conditions ?
In this piece of code there are 48 different conditions and in my case there are 14 different condition that are repeated
index = [x for x in range(48)]
shuffle(index)

1 Like

Hello MTH

ok, just to understand you better. Your Excel-file has 250 rows, 166 are go-trials (indicated by 1 and 2), everything above 2 is another trial (no-trial perhaps, 84 trials). Is this correct?

And you want that everything above 2 does not occur twice in a row? Correct?

Well, that doesn’t give you a lot of options to place the 2s, does it? Using brute force won’t work in this case. You need a deterministic code.

Best wishes Jens

Hello and thank you for your patience, unfortunately, as I a beginner, I am not familiar with what a deterministic code is. Could you provide me an example suitable for my case?

What I do for prospective memory tasks, where there are a small number of targets within a larger number of filler trials, is I load them into two lists and have a random gap between target trials. In your case you would need an average of about two go trials in between each no-go trial so you could shuffle a list containing 28 1s, 28 2s and 28 3s and then use pop() to select the last item from that list for the gap after each no-go trial.

Have a look at my Complex Randomisation demo as a possible way to set this up. The demo shows how to do CVC, but you might want to shuffle equal numbers of GN, GGN and GGGN.

Hello and thank you for your response. I tried to click the code in your demo but I can’t see it (it tells me error404). Also, I was thinking about your reasoning and I think this would be easier for me if the stop signs were all the same or had the same probability of appearing, at least I think.

Please try again now. I’d forgotten to set complex randomisation to public,

Hi and thank you. I understood what you mean, but how can I shuffle the order of “GN”? For example GNG, GGN, NGG and so on.