Howdy, Stranger!

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

Supported by

Amount of time spent on either side of y-axis

Hi everyone

Is there a way to measure how much time was spent on the left and the right side of the y-axis using mousetrap? I'm almost done with my analysis, but I haven't stumbles upon such a measure yet.

Thanks :)

-Sara

Comments

  • Hi Sara,

    within the mousetrap package, there is no standard measure for that. However, you could compute it with the following code:

    library(mousetrap)
    
    # Use example data from mousetrap package
    mt_data <- mt_example
    
    # Compute derivatives to make timestamp differences accessible
    mt_data <- mt_derivatives(mt_data, return_delta_time = TRUE)
    
    # Compute time spent for positive x values (i.e., right of y axis)
    mt_data$data$time_x_positive <- rowSums(mt_data$trajectories[,,"delta_time"]*(mt_data$trajectories[,,"xpos"]>0), na.rm = TRUE)
    
    # Compute time spent for negative x values (i.e., left of y axis)
    mt_data$data$time_x_negative <- rowSums(mt_data$trajectories[,,"delta_time"]*(mt_data$trajectories[,,"xpos"]<0), na.rm = TRUE)
    

    Note that the time exactly on the y axis (i.e., for x = 0) is excluded. In addition, since you require the time which is a difference measure between two time stamps, it is somewhat arbitrary how these time differences are assigned to the positions (i.e., whether they are shifted forwards or backwards - they are shifted forward within the mt_derivatives function, see documentation: http://pascalkieslich.github.io/mousetrap/reference/mt_derivatives.html#details-1). However, this is just a minor technical detail.

    Best,

    Pascal

Sign In or Register to comment.