Howdy, Stranger!

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

Supported by

Initial acceleration?

Hi!

I have been using mousetrap plugin for a while and it is sooo awesome. I am trying to study the influence of proactive inhibition on mouse movement. Could you please help me with devising a way to calculate initial acceleration? I.e. acceleration on the first recorded section of the trajectory?


Thank you!

Comments

  • Hi,

    glad to hear that you like the mousetrap software packages! :)

    How would you specifically like to define "acceleration on the first recorded section of the trajectory"?

    That is, what is the first recorded section? The first XXX ms? Or the first XX percent of the trial?

    And how would you like to compute the acceleration of the section? The average acceleration in that section? The maximum acceleration that occurred anywhere in this section?

    Best

    Pascal

  • What I have in mind is first 25% of trajectory. Is it possible to compute maximum AND averafe acceleration on this part?

  • I have another (tangentially related) question. In one of the previous theme (long ago) you provided the way to calculate the distance after certain amount of time (for example). Is there any way to make it trial by trial?

    In our stop-signal task, the stop signal sounded after a delay that was set using a staircase procedure in each trial. Suppose we want to calculate distance that an individual went in each stop trial after hearing a stop-signal. Is there a way to calculate this given the stop-signal delay in a given trial(i.e., individually for each trial).


    Thank you in advance!

  • Hi,

    I just realized that I forgot to answer the two questions you posted a while ago, sorry for that! What is the current status concerning your questions? Are they still up to date?

    Best,

    Pascal

  • Hi again! Yes they are.


    Best, Anton

  • Hi Anton,

    regarding your first question ("What I have in mind is first 25% of trajectory. Is it possible to compute maximum AND averafe acceleration on this part?"):


    I think there are two ways how you could to do this (not sure which way is best). I'll illustrate both ways with R scripts that use the example data in mousetrap. Please note that this is just an illustration how you can implement it on a technical level - I have not thought thoroughly about whether this procedure makes sense in practice.


    First variant:

    Time normalize trajectories first, the calculate the acceleration for each point and then aggregate (manually via the apply function) over the first 25 % of values per trial:

    # time normalize trajectories
    mt_example <- mt_time_normalize(mt_example)
    
    # calculate acceleration (and velocity) for time normalized trajectories
    mt_example <- mt_derivatives(mt_example,use="tn_trajectories")
    
    # calculate measures (not really necessary, I just do it to add the measures data.frame)
    mt_example <- mt_measures(mt_example, use="tn_trajectories")
    
    # calculate maximum acceleration for first 25 % of time normalized trajectories
    mt_example$measures$acc_max_25percent <-
     apply(mt_example$tn_trajectories[,1:25,"acc"],1,max)
    
    # calculate mean acceleration for first 25 % of time normalized trajectories
    mt_example$measures$acc_mean_25percent <-
     apply(mt_example$tn_trajectories[,1:25,"acc"],1,mean)
    

    Second variant:

    Calculate the acceleration for each point in the raw trajectories, time normalize trajectories afterwards and then aggregate (manually via the apply function) over the first 25 % of values per trial:

    # calculate acceleration (and velocity) for time normalized trajectories
    mt_example <- mt_derivatives(mt_example)
    
    # calculate measures (not really necessary, I just do it to add the measures data.frame)
    mt_example <- mt_measures(mt_example)
    
    # time normalize trajectories
    mt_example <- mt_time_normalize(mt_example,dimensions = c("xpos","ypos","acc"))
    
    # calculate maximum acceleration for first 25 % of time normalized trajectories
    mt_example$measures$acc_max_25percent <-
      apply(mt_example$tn_trajectories[,1:25,"acc"],1,max)
    
    # calculate mean acceleration for first 25 % of time normalized trajectories
    mt_example$measures$acc_mean_25percent <-
      apply(mt_example$tn_trajectories[,1:25,"acc"],1,mean)
    

    Both variants might lead to different results as you look at the trajectory with a different resolution (which can make a difference especially for acceleration values that can be quite volatile).


    Best,


    Pascal

  • Regarding the second question ("In our stop-signal task, the stop signal sounded after a delay that was set using a staircase procedure in each trial. Suppose we want to calculate distance that an individual went in each stop trial after hearing a stop-signal. Is there a way to calculate this given the stop-signal delay in a given trial(i.e., individually for each trial)."):

    As you wrote I think that this relates back to another discussion we had some time ago here: http://forum.cogsci.nl/discussion/comment/14531/#Comment_14531

    You could modify the code there a bit:

    # Load mousetrap library
    library(mousetrap)
    
    # Calculate mouse-tracking derivatives for each position (distance, velocity, acceleration)
    mt_example <- mt_derivatives(mt_example)
    
    # Calculate standard mouse-tracking measures
    mt_example <- mt_measures(mt_example)
    
    # Set distances for timestamps before 600 ms to 0
    mt_example$trajectories[,,"dist"][mt_example$trajectories[,,"timestamps"]<600] <- 0
    
    # Calculate sum of distances for timestamps >= 600 ms as a new measure in mt_example$measures
    mt_example$measures$total_dist_600 <- rowSums(mt_example$trajectories[,,"dist"],na.rm=TRUE)
    

    Assuming you have a trial variable that contains the time at which the sound occurred in a given trial which is stored as "threshold" in mt_example$data, you could modify the code even further

    # Load mousetrap library
    library(mousetrap)
    
    # Calculate mouse-tracking derivatives for each position (distance, velocity, acceleration)
    mt_example <- mt_derivatives(mt_example)
    
    # Calculate standard mouse-tracking measures
    mt_example <- mt_measures(mt_example)
    
    # Set distances for timestamps before individual threshold to 0
    for (id in mt_example$data$mt_id){
      mt_example$trajectories[id,,"dist"][
        mt_example$trajectories[id,,"timestamps"]<mt_example$data[id,"threshold"]
      ] <- 0
    }
    
    # Calculate sum of distances for timestamps >= threshold as a new measure in mt_example$measures
    mt_example$measures$total_dist_thre <- rowSums(mt_example$trajectories[,,"dist"],na.rm=TRUE)
    

    Hope this helps!

  • Thank you soo much! that does indeed help!

Sign In or Register to comment.