Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Adaptive sketchpad duration based on accuracy in previous trials

edited October 24 in OpenSesame

Hi everyone,
I hope I didn't overlook a discussion that might answer my question already.
A brief background: I am conducting a study in which participants see an array of 3D objects and have to indicate whether or not the target was among the stimuli. However, I want to combine the search task with a priming design. So one trial in my experiment consists of two search displays (interrupted by a blank for 50 ms). The objects remain the same in both displays but can be illuminated from either the left or the right.

Now to my question: I would like to adapt the presentation duration of each search display based on the participant's performance in the previous 10 trials. I tried to achieve this via the following inline-script (I set the variable "dur" (=duration) already at the beginning of the experiment to 995 ms):

 #get number of trials 
no_trials = self.get("count_trial_sequence_main")

#if number of trials is 10 (if the rest after division by 11 is 10)
#do adaption process
if no_trials%11 == 10:
    #get presentation duration
    pres = self.get("dur")
    #access the results from the last 10 trials 
    #(make them a float so division gives decimals)
    res=float(sum(responses.correct[:10]))
    #kind of redundand, but divide sum of 0s (incorrect) and 1s (correct)
    #from last 10 trials by 10 for 
    var.recent_acc = res/10
    #we decrease presentation time by 100 ms if participants perform good (> 80%)
    if var.recent_acc > 0.80: var.dur = pres - 100
    #we increase presentation time by 100 ms if participants perform poor (< 80%)
    if var.recent_acc < 0.80: var.dur = pres + 100
    #Although it will never happen, stimulus presentation is at least 50 ms
    if var.dur <= 0: var.dur = 45 </pre>

This script works fine if i only have one keyboard response. However, both search displays are presented for 995 ms (well, kind of) and participants can make a response at any point. Hence, my trial sequence looks like this:

When I conduct my experiment like this, the variable "dur" just increases and the search displays are presented longer and longer. I guess the multiple keyboard responses mess up the logged accuracies but I don't know how to prevent that from happening.

Thanks for any suggestions!

Best,
Christian

Comments

  • Just for clarification: the last line in the markdown slipped in there now. My apologies ;)

  • Hi Christian,

    have you already looked into your output?
    Maybe you are summing up some values (e.g. None) that you do not want in that sum?
    Just an idea.

    Another idea:
    put some print recent_acc in your code, to see what the variable values are. (If you have two screens, you can even see that simultaneously in full screen mode)

    Cheers,
    Stephan

  • Hi Stephan,

    Thank you very much for your suggestions. I looked into the data and the variables correct_r1_m etc. just take the values of 0 and 1 (depending on whether 'timeout' was reached or what response was given).
    I also printed the recent accuracy and it seems that indeed all of the potential responses within a trial are being counted, regardless of the 'run if' statement.
    However, the variable [correct] indeed does correctly indicate whether or not a correct response was made in the course of one trial. So if i was able to access only that variable from the previous ten trials, it should - I think - work.

    Since the variable [acc] also seemed to have suffered under the multiple response items I tried using the reset feedback in the same way as the multiple response items. I've also fixed the error in the run if statements. Now they are 'run if [response_r1_m]==None' etc. Still, the variable [dur] just increases every ten trials regardless of the variable [correct].

    Thanks again!

    Best,
    Christian

  • edited October 30

    Hi,

    I now fixed this issue. For everyone who has a similar problem:

    I define the variable correct_answer before the loop item. I then count the correct responses given in the inline-script after each trial, as can be seen in the picture above.

    My adapt_training script now looks like this:

    #get number of trials 
    no_trials = self.get("count_trial_sequence_training")
    
    #if number of trials is 10 (if the rest after division by 11 is 10)
    #do adaption process
    if no_trials%11 == 10:
        #get presentation duration
        pres = self.get("dur")
        #we decrease presentation time by 100 ms if participants perform good (> 80%)
        if correct_answer > 8: var.dur = pres - 100
        #we increase presentation time by 100 ms if participants perform poor (< 80%) 
        if correct_answer < 8: var.dur = pres + 100
        #Although it will never happen, stimulus presentation is at least 50 ms
        if var.dur < 0: var.dur = 45 
        correct_answer = 0
    
    

    Every 10th trial, I reset "correct_answer".

    I hope this helps!

    Best,
    Christian

    Thanked by 1eduard
Sign In or Register to comment.