-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
idle time for mouse-trajectories with sampling rate depending on movement #9
Comments
That's a good point. I really like the solution you suggested - to mix constant and linear interpolation, and to use a threshold for determining when which type of interpolation should be performed. I'll see whether I can implement something like this in |
I have implemented this option in If you use
You will get an idle time of 309 ms. Note that this is 2 ms shorter than what you suggested. However, I think this makes sense for the following reason: Your example data looks as follows:
Internally,
Afterwards, However, as the position of the mouse slightly differs, the movement has to occur somewhere which currently reduces the idle time by 1 ms for the period for timestamps 19 to 20 and 310 to 311. We could even think about a different criterion for adding the constant timestamps, e.g., instead of subtracting 1 from the next timestamp, we could subtract the |
Thank you very much, that' s great! |
You are right that the movement has to occur slightly before it can be captured and thus the idle time has to be shorter than I originally suggested. I had a closer look at the code now and I really like the solution. Concerning your question on how much earlier the movement occurred: Is there a way to find out how fast the logging works? I would rather use
for line https://github.com/PascalKieslich/mousetrap/blob/master/R/preprocess.R#L731 What do you think? I also looked at the following graph for different settings:
The second point I would like to bring up is the minimal timespan that is counted to be part of idle time: |
Thanks to @sbrockhaus for the suggestion
Thanks for your suggestions! I like the idea of subtracting half the constant_interpolation threshold and have implemented this instead of subtracting 1 (cf. 423036f). The only change I made is that I do not round the subtraction - this is another advantage of your idea: we are now independent of the timestamps unit (i.e., timestamps could now also be in seconds with decimals). Regarding the discussion about a minimal timespan that needs to be exceeded for the mouse to be counted as idle or hovering: I think the easiest way to solve this is to report the |
Agreed, using |
Just as a comment. We have discussed that hovering can be defined with and without the initiation time. In
Do you agree or did I get something wrong? |
I agree, looks goods good to me! |
For technical reasons it is possible that the mouse-coordinates are recorded whenever the mouse changes the position (in contrast to data that is logged at a constant rate). To get an idea of such data, I include a minimal example that closely mimics my data at hand.
I think for the computation of idle time (and hovers, but I would stick to idle time for the moment), it is important how such data is treated.
Focusing on the timestamps, we see that when the mouse is moving, the logging rate is every 8 ms:
My intuition would be that the idle time is 20 + 291 = 311 ms for this trajectory (whether a lower threshold > 8 ms should be defined for times to count as idle time is a different question that should be discussed - when not making this threshold explicit it is determined by the sampling rate).
When using the mousetrap-package to compute the idle time on this data, we get per definition 0 idle time, as the coordinates are only logged in case of movement.
When doing a resampling of the observations to a regular grid using linear interpolation, again the idle time is 0 (or only non-zero in case of mistakes with the machine epsilon).
We already discussed that a possible solution would be to do linear interpolation (see #7). However, we agreed that liner interpolation is better than constant interpolation whenever the mouse is moving.
Maybe it would be a solution to make a mix of linear and constant interpolation, with constant interpolation for time-differences that are above a certain threshold (this threshold should be 0 per default for backwards-compatibility and in my current example it would be set to 8).
What do you think?
Otherwise the idle time could be computed as
But in my opinion this second solution fits very poorly into the current package design.
The text was updated successfully, but these errors were encountered: