Randomise with randomising conditions


Author
Message
aliciay1
aliciay1
Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)
Group: Forum Members
Posts: 12, Visits: 64
Hi, 

I am wondering if it is possible to randomise the selection from two linked lists when presenting in trials with set conditions on the randomisation.

For example I am trying to randomise selection from the trial type list and digit sequence list each time it is run. However, there must be an 80/20 ratio of trial types presented and no two same digits can be presented in a row. I have tried the below code, however I am unsure if the reset function is correct or in the right place, secondly the creation of a new digit list is not that effective. How could this be resolved? 

Any suggestions on how to improve this would be greatly appreciated.

Thank you. 



Note: list of practice trialtypes
<list practice_trialtype>
/items = (trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go,
            trial.practice_nogo, trial.practice_nogo)
/replace = true
/poolsize = 24
</list>

Note: list of digits used for practice
<list practice_digitsequence>
/items = (1,2,3,4,5,6,7,8,9)
/poolsize = 24
</list>


<trial practice_go>
/pretrialpause = values.iti
/ontrialbegin = [
    values.trialtype = "Go";
    values.digit = list.practice_digitsequence.nextvalue;
    values.digitLastChosen = list.practice_digitsequence.currentvalue;
    values.digit_new = list.practice_digitsequence.removeitem(values.digitLastChosen);
    values.digit_new = list.practice_digitsequence.nextvalue;
    list.practice_digitsequence.resetselection(values.digit);
    values.fontsize = list.practice_fontsizes.nextvalue;
    trial.practice_go.insertstimulustime(text.mask, values.digitpresentationtime);
    trial.practice_go.insertstimulustime(shape.background, (values.digitpresentationtime + values.maskpresentationtime));
]
/ ontrialend = [
        trial.practice_go.resetstimulusframes();
]
/stimulustimes = [0 = background, digit]
/responsetime = 0
/responseinterrupt = frames
/monkeyresponse = (57)
/iscorrectresponse = [trial.practice_go.response == 0]
/trialduration = values.digitpresentationtime + values.maskpresentationtime

/ontrialend = [
    if (trial.practice_go.response == 0)
        values.RT = trial.practice_go.latency
    else {
        values.RT = "";
        values.latencytype = 0;
    };
    
    if (values.RT != "" && values.RT < values.anticipatoryresponsetime) {
        values.latencytype = 1;
    };

    if (values.RT != "" && values.RT >= values.anticipatoryresponsetime && values.RT < values.validresponsetime) {
        values.latencytype = 2;
    };
    
    if (values.RT != "" && values.RT >= values.validresponsetime) {
        values.latencytype = 3;
    };
    
    if (values.RT == "") {
        values.responsetype = "Omission";
    };

    if (values.RT != "" && values.RT < values.anticipatoryresponsetime) {
        values.responsetype = "Go Anticipatory";
    };
    
    if (values.RT >= values.anticipatoryresponsetime && values.RT < values.validresponsetime)
        values.responsetype = "Go Ambiguous";
        
    if (values.RT >= values.validresponsetime) {
        values.responsetype = "Go Success";
    };
]
/recorddata = true
/branch = [if (trial.practice_go.error) trial.feedbackerror]
/branch = [if (trial.practice_go.correct) trial.feedbackcorrect]
</trial>


<trial practice_nogo>
/pretrialpause = values.iti
/ontrialbegin = [
    values.trialtype = "NoGo";
   values.digitnogo = list.practice_digitsequence.nextvalue;
    values.digitLastChosen = list.practice_digitsequence.currentvalue;
    values.digitnogo_new = list.practice_digitsequence.removeitem(values.digitLastChosen)
    values.digitnogo_new = list.practice_digitsequence.nextvalue;  
    list.practice_digitsequence.resetselection(values.digitnogo);
  values.fontsize = list.practice_fontsizes.nextvalue;
    if (mod(values.digitnogo, 2) == 0) {
        values.even = true;
        values.correctresponsekey = values.responsekey2;
    }
    else {
        values.even = false;
        values.correctresponsekey = values.responsekey1;
    }
    trial.practice_nogo.insertstimulustime(text.mask, values.digitpresentationtime);
    trial.practice_nogo.insertstimulustime(shape.background, (values.digitpresentationtime + values.maskpresentationtime));
]
/ontrialend = [
    trial.practice_nogo.resetstimulusframes();
]

/stimulustimes = [0 = background, digitnogo]
/responsetime = 0
/responseinterrupt = frames
/monkeyresponse = (57,0)
/iscorrectresponse = [trial.practice_nogo.response == values.correctresponsekey]
/trialduration = values.digitpresentationtime + values.maskpresentationtime

/ontrialend = [

    if (trial.practice_nogo.response == values.correctresponsekey)
        values.RT = trial.practice_nogo.latency
    else {
        values.RT = "";
        values.latencytype = 0;
    };
    
    if (values.RT != "" && values.RT < values.anticipatoryresponsetime) {
        values.latencytype = 1;
    };
    
    if (values.RT != "" && values.RT >= values.anticipatoryresponsetime && values.RT < values.validresponsetime) {
        values.latencytype = 2;
    };
    
    if (values.RT != "" && values.RT >= values.validresponsetime) {
        values.latencytype = 3;
    };
    
    if (values.RT == "") {
        values.responsetype = "NoGo Success";
    } else {
        values.responsetype = "NoGo Failure";
    };
]

/recorddata = true
/branch = [if (trial.practice_nogo.error) trial.feedbackerror]
/branch = [if (trial.practice_nogo.correct) trial.feedbackcorrect]
</trial>


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
aliciay1 - 6/3/2020
Hi, 

I am wondering if it is possible to randomise the selection from two linked lists when presenting in trials with set conditions on the randomisation.

For example I am trying to randomise selection from the trial type list and digit sequence list each time it is run. However, there must be an 80/20 ratio of trial types presented and no two same digits can be presented in a row. I have tried the below code, however I am unsure if the reset function is correct or in the right place, secondly the creation of a new digit list is not that effective. How could this be resolved? 

Any suggestions on how to improve this would be greatly appreciated.

Thank you. 



Note: list of practice trialtypes
<list practice_trialtype>
/items = (trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go,
            trial.practice_nogo, trial.practice_nogo)
/replace = true
/poolsize = 24
</list>

Note: list of digits used for practice
<list practice_digitsequence>
/items = (1,2,3,4,5,6,7,8,9)
/poolsize = 24
</list>


<trial practice_go>
/pretrialpause = values.iti
/ontrialbegin = [
    values.trialtype = "Go";
    values.digit = list.practice_digitsequence.nextvalue;
    values.digitLastChosen = list.practice_digitsequence.currentvalue;
    values.digit_new = list.practice_digitsequence.removeitem(values.digitLastChosen);
    values.digit_new = list.practice_digitsequence.nextvalue;
    list.practice_digitsequence.resetselection(values.digit);
    values.fontsize = list.practice_fontsizes.nextvalue;
    trial.practice_go.insertstimulustime(text.mask, values.digitpresentationtime);
    trial.practice_go.insertstimulustime(shape.background, (values.digitpresentationtime + values.maskpresentationtime));
]
/ ontrialend = [
        trial.practice_go.resetstimulusframes();
]
/stimulustimes = [0 = background, digit]
/responsetime = 0
/responseinterrupt = frames
/monkeyresponse = (57)
/iscorrectresponse = [trial.practice_go.response == 0]
/trialduration = values.digitpresentationtime + values.maskpresentationtime

/ontrialend = [
    if (trial.practice_go.response == 0)
        values.RT = trial.practice_go.latency
    else {
        values.RT = "";
        values.latencytype = 0;
    };
    
    if (values.RT != "" && values.RT < values.anticipatoryresponsetime) {
        values.latencytype = 1;
    };

    if (values.RT != "" && values.RT >= values.anticipatoryresponsetime && values.RT < values.validresponsetime) {
        values.latencytype = 2;
    };
    
    if (values.RT != "" && values.RT >= values.validresponsetime) {
        values.latencytype = 3;
    };
    
    if (values.RT == "") {
        values.responsetype = "Omission";
    };

    if (values.RT != "" && values.RT < values.anticipatoryresponsetime) {
        values.responsetype = "Go Anticipatory";
    };
    
    if (values.RT >= values.anticipatoryresponsetime && values.RT < values.validresponsetime)
        values.responsetype = "Go Ambiguous";
        
    if (values.RT >= values.validresponsetime) {
        values.responsetype = "Go Success";
    };
]
/recorddata = true
/branch = [if (trial.practice_go.error) trial.feedbackerror]
/branch = [if (trial.practice_go.correct) trial.feedbackcorrect]
</trial>


<trial practice_nogo>
/pretrialpause = values.iti
/ontrialbegin = [
    values.trialtype = "NoGo";
   values.digitnogo = list.practice_digitsequence.nextvalue;
    values.digitLastChosen = list.practice_digitsequence.currentvalue;
    values.digitnogo_new = list.practice_digitsequence.removeitem(values.digitLastChosen)
    values.digitnogo_new = list.practice_digitsequence.nextvalue;  
    list.practice_digitsequence.resetselection(values.digitnogo);
  values.fontsize = list.practice_fontsizes.nextvalue;
    if (mod(values.digitnogo, 2) == 0) {
        values.even = true;
        values.correctresponsekey = values.responsekey2;
    }
    else {
        values.even = false;
        values.correctresponsekey = values.responsekey1;
    }
    trial.practice_nogo.insertstimulustime(text.mask, values.digitpresentationtime);
    trial.practice_nogo.insertstimulustime(shape.background, (values.digitpresentationtime + values.maskpresentationtime));
]
/ontrialend = [
    trial.practice_nogo.resetstimulusframes();
]

/stimulustimes = [0 = background, digitnogo]
/responsetime = 0
/responseinterrupt = frames
/monkeyresponse = (57,0)
/iscorrectresponse = [trial.practice_nogo.response == values.correctresponsekey]
/trialduration = values.digitpresentationtime + values.maskpresentationtime

/ontrialend = [

    if (trial.practice_nogo.response == values.correctresponsekey)
        values.RT = trial.practice_nogo.latency
    else {
        values.RT = "";
        values.latencytype = 0;
    };
    
    if (values.RT != "" && values.RT < values.anticipatoryresponsetime) {
        values.latencytype = 1;
    };
    
    if (values.RT != "" && values.RT >= values.anticipatoryresponsetime && values.RT < values.validresponsetime) {
        values.latencytype = 2;
    };
    
    if (values.RT != "" && values.RT >= values.validresponsetime) {
        values.latencytype = 3;
    };
    
    if (values.RT == "") {
        values.responsetype = "NoGo Success";
    } else {
        values.responsetype = "NoGo Failure";
    };
]

/recorddata = true
/branch = [if (trial.practice_nogo.error) trial.feedbackerror]
/branch = [if (trial.practice_nogo.correct) trial.feedbackcorrect]
</trial>


It's entirely unclear what the "go" and what the "no go" stimuli are here. That said, if all you care about is having no two identical digits in a row, /maxrunsize is your friend:

https://www.millisecond.com/support/docs/v5/html/language/attributes/maxrunsize.htm
aliciay1
aliciay1
Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)
Group: Forum Members
Posts: 12, Visits: 64
Dave - 6/3/2020
aliciay1 - 6/3/2020
Hi, 

I am wondering if it is possible to randomise the selection from two linked lists when presenting in trials with set conditions on the randomisation.

For example I am trying to randomise selection from the trial type list and digit sequence list each time it is run. However, there must be an 80/20 ratio of trial types presented and no two same digits can be presented in a row. I have tried the below code, however I am unsure if the reset function is correct or in the right place, secondly the creation of a new digit list is not that effective. How could this be resolved? 

Any suggestions on how to improve this would be greatly appreciated.

Thank you. 



Note: list of practice trialtypes
<list practice_trialtype>
/items = (trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go, trial.practice_go,
            trial.practice_nogo, trial.practice_nogo)
/replace = true
/poolsize = 24
</list>

Note: list of digits used for practice
<list practice_digitsequence>
/items = (1,2,3,4,5,6,7,8,9)
/poolsize = 24
</list>


<trial practice_go>
/pretrialpause = values.iti
/ontrialbegin = [
    values.trialtype = "Go";
    values.digit = list.practice_digitsequence.nextvalue;
    values.digitLastChosen = list.practice_digitsequence.currentvalue;
    values.digit_new = list.practice_digitsequence.removeitem(values.digitLastChosen);
    values.digit_new = list.practice_digitsequence.nextvalue;
    list.practice_digitsequence.resetselection(values.digit);
    values.fontsize = list.practice_fontsizes.nextvalue;
    trial.practice_go.insertstimulustime(text.mask, values.digitpresentationtime);
    trial.practice_go.insertstimulustime(shape.background, (values.digitpresentationtime + values.maskpresentationtime));
]
/ ontrialend = [
        trial.practice_go.resetstimulusframes();
]
/stimulustimes = [0 = background, digit]
/responsetime = 0
/responseinterrupt = frames
/monkeyresponse = (57)
/iscorrectresponse = [trial.practice_go.response == 0]
/trialduration = values.digitpresentationtime + values.maskpresentationtime

/ontrialend = [
    if (trial.practice_go.response == 0)
        values.RT = trial.practice_go.latency
    else {
        values.RT = "";
        values.latencytype = 0;
    };
    
    if (values.RT != "" && values.RT < values.anticipatoryresponsetime) {
        values.latencytype = 1;
    };

    if (values.RT != "" && values.RT >= values.anticipatoryresponsetime && values.RT < values.validresponsetime) {
        values.latencytype = 2;
    };
    
    if (values.RT != "" && values.RT >= values.validresponsetime) {
        values.latencytype = 3;
    };
    
    if (values.RT == "") {
        values.responsetype = "Omission";
    };

    if (values.RT != "" && values.RT < values.anticipatoryresponsetime) {
        values.responsetype = "Go Anticipatory";
    };
    
    if (values.RT >= values.anticipatoryresponsetime && values.RT < values.validresponsetime)
        values.responsetype = "Go Ambiguous";
        
    if (values.RT >= values.validresponsetime) {
        values.responsetype = "Go Success";
    };
]
/recorddata = true
/branch = [if (trial.practice_go.error) trial.feedbackerror]
/branch = [if (trial.practice_go.correct) trial.feedbackcorrect]
</trial>


<trial practice_nogo>
/pretrialpause = values.iti
/ontrialbegin = [
    values.trialtype = "NoGo";
   values.digitnogo = list.practice_digitsequence.nextvalue;
    values.digitLastChosen = list.practice_digitsequence.currentvalue;
    values.digitnogo_new = list.practice_digitsequence.removeitem(values.digitLastChosen)
    values.digitnogo_new = list.practice_digitsequence.nextvalue;  
    list.practice_digitsequence.resetselection(values.digitnogo);
  values.fontsize = list.practice_fontsizes.nextvalue;
    if (mod(values.digitnogo, 2) == 0) {
        values.even = true;
        values.correctresponsekey = values.responsekey2;
    }
    else {
        values.even = false;
        values.correctresponsekey = values.responsekey1;
    }
    trial.practice_nogo.insertstimulustime(text.mask, values.digitpresentationtime);
    trial.practice_nogo.insertstimulustime(shape.background, (values.digitpresentationtime + values.maskpresentationtime));
]
/ontrialend = [
    trial.practice_nogo.resetstimulusframes();
]

/stimulustimes = [0 = background, digitnogo]
/responsetime = 0
/responseinterrupt = frames
/monkeyresponse = (57,0)
/iscorrectresponse = [trial.practice_nogo.response == values.correctresponsekey]
/trialduration = values.digitpresentationtime + values.maskpresentationtime

/ontrialend = [

    if (trial.practice_nogo.response == values.correctresponsekey)
        values.RT = trial.practice_nogo.latency
    else {
        values.RT = "";
        values.latencytype = 0;
    };
    
    if (values.RT != "" && values.RT < values.anticipatoryresponsetime) {
        values.latencytype = 1;
    };
    
    if (values.RT != "" && values.RT >= values.anticipatoryresponsetime && values.RT < values.validresponsetime) {
        values.latencytype = 2;
    };
    
    if (values.RT != "" && values.RT >= values.validresponsetime) {
        values.latencytype = 3;
    };
    
    if (values.RT == "") {
        values.responsetype = "NoGo Success";
    } else {
        values.responsetype = "NoGo Failure";
    };
]

/recorddata = true
/branch = [if (trial.practice_nogo.error) trial.feedbackerror]
/branch = [if (trial.practice_nogo.correct) trial.feedbackcorrect]
</trial>


It's entirely unclear what the "go" and what the "no go" stimuli are here. That said, if all you care about is having no two identical digits in a row, /maxrunsize is your friend:

https://www.millisecond.com/support/docs/v5/html/language/attributes/maxrunsize.htm
Thank you very much. 
The go and nogo are presentation of digits in different colours and required different responses as outlined in the trial code. 
<text digitnogo>
/items = ("<%values.digitnogo%>")
/ fontstyle = ("Symbol", values.fontsize, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/position = (50%, 50%)
/erase = false
</text>

<text digit>
/items = ("<%values.digit%>")
/ fontstyle = ("Symbol", values.fontsize, false, false, false, false, 5, 1)
/ txcolor = (red)
/txbgcolor = (black)
/position = (50%, 50%)
/erase = false
</text>

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
If color is the sole distinguisher, then /maxrunsize=1 in the digit <list> should do the trick.

aliciay1
aliciay1
Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)Associate Member (121 reputation)
Group: Forum Members
Posts: 12, Visits: 64
Dave - 6/3/2020
If color is the sole distinguisher, then /maxrunsize=1 in the digit <list> should do the trick.

OK great, thanks very much! That is very helpful. 

I have a secondary issue, as one form of the task is a 1-back task, to correctly score resposnses it is required that the randomly selected digit sequence is saved to determine whether the response correct. Is there a way to track and save the selection of digits using maxrunsize, or do you have any suggestions on how I could correctly score performance? 

I currently have a separate digit list with the correct sequence of answers to the 1-back digit sequence which is fixed but I am unsure how to apply this when digit sequence is randomised. 
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
aliciay1 - 6/3/2020
Dave - 6/3/2020
If color is the sole distinguisher, then /maxrunsize=1 in the digit <list> should do the trick.

OK great, thanks very much! That is very helpful. 

I have a secondary issue, as one form of the task is a 1-back task, to correctly score resposnses it is required that the randomly selected digit sequence is saved to determine whether the response correct. Is there a way to track and save the selection of digits using maxrunsize, or do you have any suggestions on how I could correctly score performance? 

I currently have a separate digit list with the correct sequence of answers to the 1-back digit sequence which is fixed but I am unsure how to apply this when digit sequence is randomised. 

There are n-back scripts available in the library, so you may want to take a look at those:
https://www.millisecond.com/download/library/nback/
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search