Continuous recording of mouse coordinates


Continuous recording of mouse coordinates

Author
Message
jcummins
jcummins
Associate Member
Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)

Group: Forum Members
Posts: 2, Visits: 12
Hi,

I’m trying to create an implementation of a procedure in Inquisit which is capable of providing me with the continuous output of the x and y coordinates of the mouse cursor throughout each trial of the procedure (akin to MouseTracker and similar such programs). I’ve tried a few different approaches to implementing this (which I can pass on if need be), but haven’t had much luck. At the moment, the most promising version I’m working with (which is an abridged version of code posted by Dave in this thread https://www.millisecond.com/forums/Topic18169.aspx) looks like this:

<expressions>
/ leftpress = (mouse.x > 0.05*display.width && mouse.x <  .1*display.width && mouse.y > 0*display.height && mouse.y < .1*display.height)
/ rightpress = (mouse.x > 0.9*display.width && mouse.x <  .95*display.width && mouse.y > 0*display.height && mouse.y < .1*display.height)
</expressions>

<values>
/ mouse_x = ""
/ mouse_y = ""
/ mouse_time = ""
</values>

<block myblock2>
/ trials = [1, 2 = sequence(startbutton,mouseovertrial)]
</block>

<trial startbutton>
/ ontrialbegin = [values.mouse_x = ""; ]
/ stimulusframes = [1=start]
/ inputdevice = mouse
/ validresponse = (start)
</trial>

<text start>
/ items = ("CLICK HERE TO START")
/ position = (50%, 90%)
</text>

<trial mouseovertrial>
/ posttrialpause = 500
/ stimulusframes = [1=true,false]
/ inputdevice = mouse
/ validresponse = (lbuttondown)
/ isvalidresponse = [if (trial.mouseovertrial.response == "mousemove") {
    values.mouse_x = concat(concat(values.mouse_x, mouse.x), ", "); 
    false; } ;
    expressions.leftpress || expressions.rightpress ]
/ isvalidresponse = [if (trial.mouseovertrial.response == "mousemove") {
    values.mouse_y = concat(concat(values.mouse_y, mouse.y), ", "); 
    false; } ;
    expressions.leftpress  || expressions.rightpress ]
/ isvalidresponse = [if (trial.mouseovertrial.response == "mousemove") {
    values.mouse_time = concat(concat(values.mouse_time, trial.mouseovertrial.latency), ", "); 
    false; } ;
    expressions.leftpress  || expressions.rightpress ]
</trial>

<text true>
/ items = ("TRUE")
/ txbgcolor = (white)
/ size = (5%, 5%)
/ position = (10%,5%)
</text>

<text false>
/ items = ("FALSE")
/ txbgcolor = (white)
/ size = (5%,5%)
/ position = (90%,5%)
</text>

<data>
/ columns = [date time subject trialnum trialcode response latency expressions.leftpress expressions.rightpress values.mouse_x values.mouse_y values.mouse_time]
/ separatefiles = true
</data>


I have the following issues with the code thus far:
1. The code only outputs coordinates when there is a mousemove response, which is problematic if the participant does not move the mouse for prolonged periods of time. Of course if the mouse isn’t moved then the position is known, but ideally it would be nice for the data to reflect this stasis in some way. Is there any way to record these coordinates at regular, frequent (~3ms) intervals? I know Dave in a previous post said that it is preferable to not do this within the Inquisit framework, but is it hypothetically possible to efficiently implement? Or is there some workaround which could avoid the issue of not recording coordinates when there is no movement? 

2. In the data file that is produced for the mouse coordinates and timing, it seems to add new data cumulatively. For example, if my times for trial 1 are 5, 10, 15, 20, and my times for trial 2 are 4, 8, 12, and 16, then trial 2’s output for timing is “5, 10, 15, 20, 4, 8, 12, 16”. Is there any solution to this such that the coordinates and timings produced for each trial are representative of that individual trial's movements only?

I only starting using Inquisit a couple of months ago, so my code is most likely sub-optimal. Any help with this would be greatly appreciated. Thanks!

Dave
Dave
Supreme Being
Supreme Being (516K reputation)Supreme Being (516K reputation)Supreme Being (516K reputation)Supreme Being (516K reputation)Supreme Being (516K reputation)Supreme Being (516K reputation)Supreme Being (516K reputation)Supreme Being (516K reputation)Supreme Being (516K reputation)

Group: Administrators
Posts: 9.2K, Visits: 39K
jcummins - Thursday, May 17, 2018
Hi,

I’m trying to create an implementation of a procedure in Inquisit which is capable of providing me with the continuous output of the x and y coordinates of the mouse cursor throughout each trial of the procedure (akin to MouseTracker and similar such programs). I’ve tried a few different approaches to implementing this (which I can pass on if need be), but haven’t had much luck. At the moment, the most promising version I’m working with (which is an abridged version of code posted by Dave in this thread https://www.millisecond.com/forums/Topic18169.aspx) looks like this:

<expressions>
/ leftpress = (mouse.x > 0.05*display.width && mouse.x <  .1*display.width && mouse.y > 0*display.height && mouse.y < .1*display.height)
/ rightpress = (mouse.x > 0.9*display.width && mouse.x <  .95*display.width && mouse.y > 0*display.height && mouse.y < .1*display.height)
</expressions>

<values>
/ mouse_x = ""
/ mouse_y = ""
/ mouse_time = ""
</values>

<block myblock2>
/ trials = [1, 2 = sequence(startbutton,mouseovertrial)]
</block>

<trial startbutton>
/ ontrialbegin = [values.mouse_x = ""; ]
/ stimulusframes = [1=start]
/ inputdevice = mouse
/ validresponse = (start)
</trial>

<text start>
/ items = ("CLICK HERE TO START")
/ position = (50%, 90%)
</text>

<trial mouseovertrial>
/ posttrialpause = 500
/ stimulusframes = [1=true,false]
/ inputdevice = mouse
/ validresponse = (lbuttondown)
/ isvalidresponse = [if (trial.mouseovertrial.response == "mousemove") {
    values.mouse_x = concat(concat(values.mouse_x, mouse.x), ", "); 
    false; } ;
    expressions.leftpress || expressions.rightpress ]
/ isvalidresponse = [if (trial.mouseovertrial.response == "mousemove") {
    values.mouse_y = concat(concat(values.mouse_y, mouse.y), ", "); 
    false; } ;
    expressions.leftpress  || expressions.rightpress ]
/ isvalidresponse = [if (trial.mouseovertrial.response == "mousemove") {
    values.mouse_time = concat(concat(values.mouse_time, trial.mouseovertrial.latency), ", "); 
    false; } ;
    expressions.leftpress  || expressions.rightpress ]
</trial>

<text true>
/ items = ("TRUE")
/ txbgcolor = (white)
/ size = (5%, 5%)
/ position = (10%,5%)
</text>

<text false>
/ items = ("FALSE")
/ txbgcolor = (white)
/ size = (5%,5%)
/ position = (90%,5%)
</text>

<data>
/ columns = [date time subject trialnum trialcode response latency expressions.leftpress expressions.rightpress values.mouse_x values.mouse_y values.mouse_time]
/ separatefiles = true
</data>


I have the following issues with the code thus far:
1. The code only outputs coordinates when there is a mousemove response, which is problematic if the participant does not move the mouse for prolonged periods of time. Of course if the mouse isn’t moved then the position is known, but ideally it would be nice for the data to reflect this stasis in some way. Is there any way to record these coordinates at regular, frequent (~3ms) intervals? I know Dave in a previous post said that it is preferable to not do this within the Inquisit framework, but is it hypothetically possible to efficiently implement? Or is there some workaround which could avoid the issue of not recording coordinates when there is no movement? 

2. In the data file that is produced for the mouse coordinates and timing, it seems to add new data cumulatively. For example, if my times for trial 1 are 5, 10, 15, 20, and my times for trial 2 are 4, 8, 12, and 16, then trial 2’s output for timing is “5, 10, 15, 20, 4, 8, 12, 16”. Is there any solution to this such that the coordinates and timings produced for each trial are representative of that individual trial's movements only?

I only starting using Inquisit a couple of months ago, so my code is most likely sub-optimal. Any help with this would be greatly appreciated. Thanks!

Re. #1: "Is there any way to record these coordinates at regular, frequent (~3ms) intervals?"

No, I cannot think of a way to do that.

Re. #2: Yes, you need to reset the respective values to an empty string at the start of each round.

jcummins
jcummins
Associate Member
Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)Associate Member (58 reputation)

Group: Forum Members
Posts: 2, Visits: 12
Dave - Thursday, May 17, 2018
jcummins - Thursday, May 17, 2018
Hi,

I’m trying to create an implementation of a procedure in Inquisit which is capable of providing me with the continuous output of the x and y coordinates of the mouse cursor throughout each trial of the procedure (akin to MouseTracker and similar such programs). I’ve tried a few different approaches to implementing this (which I can pass on if need be), but haven’t had much luck. At the moment, the most promising version I’m working with (which is an abridged version of code posted by Dave in this thread https://www.millisecond.com/forums/Topic18169.aspx) looks like this:

<expressions>
/ leftpress = (mouse.x > 0.05*display.width && mouse.x <  .1*display.width && mouse.y > 0*display.height && mouse.y < .1*display.height)
/ rightpress = (mouse.x > 0.9*display.width && mouse.x <  .95*display.width && mouse.y > 0*display.height && mouse.y < .1*display.height)
</expressions>

<values>
/ mouse_x = ""
/ mouse_y = ""
/ mouse_time = ""
</values>

<block myblock2>
/ trials = [1, 2 = sequence(startbutton,mouseovertrial)]
</block>

<trial startbutton>
/ ontrialbegin = [values.mouse_x = ""; ]
/ stimulusframes = [1=start]
/ inputdevice = mouse
/ validresponse = (start)
</trial>

<text start>
/ items = ("CLICK HERE TO START")
/ position = (50%, 90%)
</text>

<trial mouseovertrial>
/ posttrialpause = 500
/ stimulusframes = [1=true,false]
/ inputdevice = mouse
/ validresponse = (lbuttondown)
/ isvalidresponse = [if (trial.mouseovertrial.response == "mousemove") {
    values.mouse_x = concat(concat(values.mouse_x, mouse.x), ", "); 
    false; } ;
    expressions.leftpress || expressions.rightpress ]
/ isvalidresponse = [if (trial.mouseovertrial.response == "mousemove") {
    values.mouse_y = concat(concat(values.mouse_y, mouse.y), ", "); 
    false; } ;
    expressions.leftpress  || expressions.rightpress ]
/ isvalidresponse = [if (trial.mouseovertrial.response == "mousemove") {
    values.mouse_time = concat(concat(values.mouse_time, trial.mouseovertrial.latency), ", "); 
    false; } ;
    expressions.leftpress  || expressions.rightpress ]
</trial>

<text true>
/ items = ("TRUE")
/ txbgcolor = (white)
/ size = (5%, 5%)
/ position = (10%,5%)
</text>

<text false>
/ items = ("FALSE")
/ txbgcolor = (white)
/ size = (5%,5%)
/ position = (90%,5%)
</text>

<data>
/ columns = [date time subject trialnum trialcode response latency expressions.leftpress expressions.rightpress values.mouse_x values.mouse_y values.mouse_time]
/ separatefiles = true
</data>


I have the following issues with the code thus far:
1. The code only outputs coordinates when there is a mousemove response, which is problematic if the participant does not move the mouse for prolonged periods of time. Of course if the mouse isn’t moved then the position is known, but ideally it would be nice for the data to reflect this stasis in some way. Is there any way to record these coordinates at regular, frequent (~3ms) intervals? I know Dave in a previous post said that it is preferable to not do this within the Inquisit framework, but is it hypothetically possible to efficiently implement? Or is there some workaround which could avoid the issue of not recording coordinates when there is no movement? 

2. In the data file that is produced for the mouse coordinates and timing, it seems to add new data cumulatively. For example, if my times for trial 1 are 5, 10, 15, 20, and my times for trial 2 are 4, 8, 12, and 16, then trial 2’s output for timing is “5, 10, 15, 20, 4, 8, 12, 16”. Is there any solution to this such that the coordinates and timings produced for each trial are representative of that individual trial's movements only?

I only starting using Inquisit a couple of months ago, so my code is most likely sub-optimal. Any help with this would be greatly appreciated. Thanks!

Re. #1: "Is there any way to record these coordinates at regular, frequent (~3ms) intervals?"

No, I cannot think of a way to do that.

Re. #2: Yes, you need to reset the respective values to an empty string at the start of each round.

Thanks for the response!
GO


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....






Millisecond Forums


Search