Howdy, Stranger!

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

Supported by

Joystick using for Approach - Avoidance Task

edited August 2 in OpenSesame

Hi,

I have some experience with Opensesame, but I have hardly any coding knowledge or experience. Currently, I'm trying to prepare an approach-avoidance task using the joystick (I've never used joystick before). Although I understand some of the basics of using the joystick while looking at the forum, I still need your support.

In the task, some photos will be presented, and when the participant wants to approach the photo, he/she has to pull the joystick and push forward if he/she wants to avoid it. When the participant pushes or pulls the joystick, the size of the photo should increase or decrease by 20% for every 7% of the joystick movement. When the joystick movement is greater than 30%, the stimulus screen should disappear and the fixation screen should appear.

So far I have done the following; I added a joystick plug in before a sketchpad(0 ms duration) for stimulus presentation. And after the sketchpad, in an inline_script, I added some code from the forum discussions. These codes are as follows;

# Loop until a response is given
while True:
    # Get a joystick movement
    movement,timestamp = exp.joystick.get_joyaxes()
    # `movement` is a tuple indicating the horizontal and vertical movement.
    dy = movement[1]
    # If there is vertical movement, set the variable `move_joystick` to up or
    # down, and break the loop.
    if dy < 0:
        exp.set('move_joystick', 'up')
        var.derece = dy
        break
    elif dy > 0:
        exp.set('move_joystick', 'down')
        var.derece = dy
        break

When I looked at previous discussions on this, there were some similar questions, but I did not solve some basic problems. Here my questions;

1- What can I do to increase or decrease stimulus size according to joystick movement?

2- How do I set the stimulus presentation time, based on the participant's joystick response? (Fixation screen should come when joystick movement is greater than 30% angle).

  • I guess, the solution of this is about 'while loop', but unfortunately, I have no idea how to do that.

3- I want the other buttons on the joystick to be inactive and the only allowed response is to be the joystick movement (Y axis). How can I do that?

  • I know all the button numbers except the joystick movement.

I know that the answers to these questions are available under different topics in the forum, but since I don't have coding skills, I have difficulty integrating them into this experiment. Any help would be greatly appreciated!

Kind regards,

Aslan.

Comments

  • Hi Aslan,

    1- What can I do to increase or decrease stimulus size according to joystick movement?

    In the same while loop you have to access the stimulus information and show it. For example, an image has a scale keyword that you can use, other stimuli you might have to first compute the new dimensions, and then draw it. For example:

    # preparations (can be done before the trial)
    cv = Canvas()
    cv['stim'] = Image(path_to_image.png)
    while True: 
        # do the stuff that you want to do wrt the joysticks
       # change the stimulus according to the joystick motion
        new_value = joystick_related_motion_factor
        cv['stim'].scale = new_value
        cv.show() # show the updated stimulus
    

    See https://osdoc.cogsci.nl/3.2/manual/python/canvas/ for more info

    How do I set the stimulus presentation time, based on the participant's joystick response? (Fixation screen should come when joystick movement is greater than 30% angle).

    Same way as changing the scale factor, but instead of adjusting the canvas that you are currently seeing, show another canvas that only has a fixation dot

    3- I want the other buttons on the joystick to be inactive and the only allowed response is to be the joystick movement (Y axis). How can I do that?

    I don't know whether you can actively deactive them, but if you don't access its values and they don't, per default, with your experiment, why not just ignore them?


    Hope this helps.

    Eduard

Sign In or Register to comment.