MouseTracker element: Dynamic starting procedure

PennController for IBEX Forums Support MouseTracker element: Dynamic starting procedure

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #8251
    jschlen
    Participant

    Hi,

    I like to set-up a mouse-tracking experiment in which participants see two scenes at the top while they listen to a sentence, and then they have to select the scene that matches the sentence by clicking on it. This is my first mouse-tracking experiment and having a template for it was already of great help. For my research questions and design it would be nice to have a dynamic starting procedure, so only after participants have started to move the mouse upwards the critical end-of sentence information is presented (i.e. after crossing an invisible horizontal line). Is that possible with PCIbex? So far, I am only able to change the template in a way that a signal appears saying “Start” to prompt participants moving the mouse as quickly as possible:

    https://farm.pcibex.net/r/ikWEij/

    Any help is greatly appreciated.

    Best,
    Judith

    #8261
    Jeremy
    Keymaster

    Hi Judith,

    Apologies for the late reply. You can pass a function to the callback command of the MouseTracker element that takes the x,y coordinates as arguments—you can then use the Y coordinate to either check that the cursor moved upwards by N pixels, or that it is above a certain line. Here is a simple trial illustrating how to update a Text element once the mouse has moved at least 50px north after clicking:

    newTrial(
        newButton("Start").print().wait().remove()
        ,
        newVar("start_y", undefined)
        ,
        newText("prompt", "Hello _____").print()
        ,
        newMouseTracker("mouse")
            .callback( async (x,y) => {
                if (getVar("start_y").value === "stop") return;
                else if (getVar("start_y").value === undefined) 
                    await getVar("start_y").set(y)._runPromises();
                else if (getVar("start_y").value - y > 50) {
                    await getVar("start_y").set("stop")._runPromises();
                    await getText("prompt").text("Hello World")._runPromises();
                }
            })
            .start()
        ,
        newButton("Finish").print().wait()
        ,
        getMouseTracker("mouse").stop()
    )

    Jeremy

    #8275
    jschlen
    Participant

    Hi Jeremy, Thanks a lot for your help! I will try this and then start adjusting the code, so it works with the auditory presentation. Best, Judith

    #8308
    jschlen
    Participant

    Hi Jeremy,

    Thanks again for your help! I have tried to adjust the code and use two audio files. Currently, the critical information is heard two times, once after the initial sentence part and, again, when the mouse is moved upwards.

    https://farm.pcibex.net/r/ikWEij/

    Do you have an idea what I am doing wrong?

    Best,
    Judith

    #8311
    Jeremy
    Keymaster

    Hi Judith,

    The critical Audio element is played twice because you tell it twice to play: once when you create it, just after the previous Audio element has stopped playing, and once inside the callback function, when the mouse moves upward. Simply delete the .play() that you don’t want

    Jeremy

    #8313
    jschlen
    Participant

    Hi Jeremy,

    Thank you for the fast reply! That was it, thanks! I think I had tried this, but I just realized that my initial changes were not effective. If I update the code, it takes a while until it is updated and sometimes the changes are gone. That’s a bit weird.

    Best,
    Judith

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.