Howdy, Stranger!

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

Supported by

Struggling to define acc for feedback

edited June 2020 in OpenSesame

My experiment is an oddity task where a participant hears three sounds and click on the circles that lit up with the sound that was the odd one out. The cursor_roi are coded as 'left', 'centre' and 'right' for the positions of the circles.

After the mouse click response I have used the inline script below, which successfully runs feedback after each trial.

if var.target_visual in var.cursor_roi:
    var.correct = 1
else:
    var.correct = 0

However, I want to give feedback at the end of the block with acc% but I cannot figure out how to define the variable. I tried adding the variable 'correct_response' to the block loop, however when I use 'left', 'right' and 'centre' or [target_visual] in order to correspond to the correct roi the experiment no longer runs and says that they are invalid.

Could you let me know where I'm going wrong?

Comments

  • From what I can see, the problem might be that var.acc source is a keyboard response, but I can't figure out why or how to change it to the correct mouse response.

  • Ok, so now it just seems to reject the possibility of 'centre' being a correct response...

  • edited June 2020

    Apologies for continued updates. I have managed to change it to the mouse response and changed the inline script to:

    if var.target_visual == var.cursor_roi:
       var.correct_response = 1
    else:
       var.correct_response = 0
    

    While this does now calculate an accuracy score, the score is inaccurate (ironically). For example, if I get 3 out of 6 incorrect it sometimes reports 60% accuracy and other times 40% accuracy, depending on the order of the correct or incorrect answers.

  • Hey,

    I can't say for sure what the problem is, but you can simply create your own accuracy variable. All you need is a variable that counts the total number of trials, and one that counts the total number of correct responses. Divide one by the other et voila, you have your accuracy.

    # every time you want to reset your accuract, 
    # but at least once in the beginning of the experiment, 
    # initialize a variable for the total number of correct trials and trial count
    var.total_correct = 0
    var.total_trials = 0
    
    

    In a different inline_script:

    # update those counters based on the responses
    if var.target_visual == var.cursor_roi:
       var.correct_response = 1
       var.total_correct += 1 
    else:
       var.correct_response = 0
    var.total_trials +=1
    

    In a different inline_script:

    # compute accuracy
    var.accuracy = var.total_correct/var.total_trials
    
    # if you use Python 2, you should use float variables
    var.accuracy = float(var.total_correct)/var.total_trials
    

    Then you can use the variable var.accuracy, just like var.acc


    Hope this helps!

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.