Howdy, Stranger!

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

Supported by

[open] Displaying Error Feedback with 'Swipe Stimuli' on Android

edited December 2015 in OpenSesame

Hello,

I have an experiment that involves 'swiping' stimuli up and down the screen (an image is presented, and the individual then either swipes it towards or away from them), however I want to make this blocked instead of free-response - thus there will be incorrect/error feedback. However, I'm not entirely sure how to do this seeing as the image is being swiped, so it is the end location that needs to provide the feedback of whether it was an error or not (as well as whether it was too slow).

from openexp.mouse import mouse
from openexp.canvas import canvas
my_mouse = mouse(exp)
my_canvas = canvas(exp)
path = exp.get_file(u'NEM4.png')
upper = exp.get("height") - 200
lower = 200
my_canvas.image(path)
trialstart = my_canvas.show()
button, position, movstart = my_mouse.get_click(timeout=None)
exp.set ("position_NEM4", position)
while True:
    pos, time = my_mouse.get_pos()
    my_canvas.clear()
    my_canvas.image(path, x=pos[0], y=pos[1])
    timestamp = my_canvas.show()
    if pos[1] < lower:
        response = "top"
        break
    if pos[1] > upper:
        response = "bottom"
        break
    # calculate the movement time
    movtime = timestamp - movstart
    # calculate the RT
    resptime = movstart - trialstart
exp.set("response_NEM4", response)  
exp.set("movetime_NEM4", movtime)
exp.set("reponse_time_NEM4", resptime)

Thanks!

Comments

  • edited 11:07PM

    Hey,

    I don't really understand the problem. When exactly do you want to present the feedback? During the movement, or after it is done? From what I get so far, your situation is not much different than in a regular experiment.

    Would you mind helping me out here?

    Eduard

  • edited 11:07PM

    Hi Eduard,

    I would like the feedback to be presented if the image is swiped in the wrong direction (there is a sketchpad item before each image telling the participant which way to swipe), which I thought could be done by importing another sketchpad item to the script when it's the wrong way?

    Also, there needs to be feedback if the response time is too short or too long, however I'm not entirely sure how to do this.

    So basically, for the former, the feedback would be after the movement is done (i.e. if the response is incorrect) and the latter would be before the movement if it is too slow and after if it was too quick, if that makes any more sense?

    Thanks!

  • edited December 2015

    Hi,

    Assuming that you have a variable that codes the correct response, this code here (adapted from the one you posted) should do what you want.

    from openexp.mouse import mouse
    from openexp.canvas import canvas
    
    my_mouse = mouse(exp)
    my_canvas = canvas(exp)
    feedback_cv = canvas(exp) # new
    
    correct_response = exp.get('correct_response') # new
    path = exp.get_file(u'NEM4.png')
    upper = exp.get("height") - 200
    lower = 200
    min_rt = 100 # new
    max_rt = 2000 # new
    my_canvas.image(path)
    trialstart = my_canvas.show()
    while True: # new
        button, position, movstart = my_mouse.get_click(timeout=None)
        exp.set ("position_NEM4", position)
        if movstart - trialstart < min_rt: # new
            feedback = "Too quick!" # new
            break # new
        elif movstart - trialstart > max_rt: # new
            feedback = "Too slow!" # new
            break # new
        while True:
            pos, time = my_mouse.get_pos()
            my_canvas.clear()
            my_canvas.image(path, x=pos[0], y=pos[1])
            timestamp = my_canvas.show()
            if pos[1] < lower:
                response = "top"
                responded = True # new
                break
            if pos[1] > upper:
                response = "bottom"
                responded = True # new
                break
        break
    
    if responded: # new
        if correct_response == response: # new
             feedback = "Correct!" # new
        else: # new
             feedback = "Wrong!" # new
    feedback_cv.text(feedback) # new
    feedback_cv.show() # new 
    self.sleep(1000) # new
    # calculate the movement time
    movtime = timestamp - movstart
    # calculate the RT
    resptime = movstart - trialstart
    exp.set("response_NEM4", response)  
    exp.set("movetime_NEM4", movtime)
    exp.set("reponse_time_NEM4", resptime)
    
    # note: I did not define a correct response here. 
    # This should have happened earlier
    

    As you can see I added another while loop to make it work. Can you try the code and let me know whether it does what it supposed to do?

    Thanks,

    Eduard

  • edited 11:07PM

    Whereabouts should I be defining the correct response? Is it in this bit:

    correct_response = exp.get('correct_response') # new 
    

    or

    if responded: # new
        if correct_response == response: # new
             feedback = "Correct!" # new
    

    The correct response for example would be 'bottom'.

    Thanks for your help.

  • edited 11:07PM

    Rather the first than the second, in best case even earlier. Like you said, a sketchpad informs the subjects which direction is the correct one. I suppose this direction is not constant but can change over trials. Therefore, you would have to have a variable, whose value is updated on every trial and defines the direction. This variable (if it has the values bottom and top) you can use as correct response variable.

    The typical approach is to define for every unique trial the respective correct response in the loop table. If you did so, you can retrieve those values with the command exp.get(variable).

    Does this make sense?

    Eduard

Sign In or Register to comment.