Mouse-Tracker Warning Sign

17 views
Skip to first unread message

Jordan Axt

unread,
Sep 30, 2020, 10:07:55 AM9/30/20
to min...@googlegroups.com
Hello Minno Team,

I am programming a mouse-tracker task on the open dashboard. I just made the study public, it's called 'mt_racegender'. 

Ideally, participants are shown a 'moveWarning' that asks them to move the mouse faster any time the mouse stays still for 500 milliseconds in a trial. I have found the warning to work well at the start of a trial if no movement is made. But the warning shows up inconsistently if someone pauses the mouse after an initial movement. I attached a video that an RA made. 

Is it possible to have the warning show up when pauses occur after an initial movement? Thank you for any help and let me know if I can pass along any more information. 

Jordan

--
Jordan Axt
MT_Study_Demo.mov

Elad Zlotnick

unread,
Oct 1, 2020, 4:08:55 AM10/1/20
to Minno.js
Hi Jordan,

The challenge in your request, is that Javascript does not actually trigger an event when the mouse is NOT moved.
What you need to do is create a timer that triggers after 500ms, and reset it each time that the mouse is moved.
I would use a custom input in order to do this, following is an example of how this can be done.
You can improve performance  a bit by debouncing the onmove function (https://lodash.com/docs/4.17.15#debounce), but I don't think it is necessary in this case.

{
            input: [
                { on: 'click', handle: 'end' ,stimHandle:'clickButton'},
                {
                    handle: 'nomove',
                    delay: 500, // set length of delay before warning
                    on: function(inputObj, canvas, stream){
                        var $listener = stream();
                        var timeoutID;

                        document.addEventListener('mousemove', onmove);
                        onmove();

                        $listener.end.map(function(){
                            clearTimeout(timeoutID);
                            document.removeEventListener('mousemove',onmove);
                        });

                        return $listener;

                        function onmove(e){
                            clearTimeout(timeoutID);
                            timeoutID = setTimeout(function(){
                                $listener(e);
                                onmove(); // reset the timer
                            }, inputObj.delay);
                        }
                    }
                }
            ],
            interactions: [
                {
                    conditions: [{ type: 'begin'}],
                    actions: [{ type: 'showStim', handle: 'clickButton' }]
                },
                {
                    conditions: [{ type: 'inputEquals', value: 'nomove' }],
                    actions: [
                        { type:'showStim', handle: 'warning'},
                        { type:'removeInput', handle: 'hideWarning'}, // prevent blinking 
                        { type: 'trigger', handle: 'hideWarning', duration: 600 }
                    ]
                },
                {
                    conditions: [{ type: 'inputEquals', value: 'hideWarning'}],
                    actions: [{ type: 'hideStim', handle: 'warning' }]
                },
                {
                    conditions: [{ type: 'inputEquals', value: 'end' }],
                    actions: [{type:'log'}, { type: 'endTrial' }]
                }
            ],
            stimuli: [
                { handle: 'clickButton', media: 'Click me!' },
                { handle: 'warning', media: 'Please move the mouse' , location: {bottom:20}, css: {color:'red'}}
            ]
        }

Jordan Axt

unread,
Oct 1, 2020, 9:16:50 AM10/1/20
to Elad Zlotnick, min...@googlegroups.com
Hi Elad,

Thanks a lot for this quick help. I was able to incorporate the code you sent into my task and it is working well. Other minno users, please feel free to contact me if you want to use/adapt my MouseTracker program. 

Jordan

--
You received this message because you are subscribed to the Google Groups "Minno.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minnojs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/minnojs/2e17c58c-2952-49c4-aa60-0ef1ecf09b2an%40googlegroups.com.


--
Jordan Axt
Reply all
Reply to author
Forward
0 new messages