Randomise with randomising conditions


Author
Message
aliciay1
aliciay1
Associate Member (152 reputation)Associate Member (152 reputation)Associate Member (152 reputation)Associate Member (152 reputation)Associate Member (152 reputation)Associate Member (152 reputation)Associate Member (152 reputation)Associate Member (152 reputation)Associate Member (152 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>


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Reading This Topic

Explore
Messages
Mentions
Search