Howdy, Stranger!

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

Supported by

change the range of measures (e.g., 0-25, 26-50, 51-75, 76-100 ranges)


In mousetrap, mt_measures gives us various measures in a time_normalized format (e.g., AUC in a 0-101 time-standardized trajectory).

How can I segment a time-standardized trajectory (tn_trajectories) into, for example, four segments (e.g., 0-25, 26-50, 51-75, 76-100 ranges) and calculate various measures (e.g., AUC, MD, MAD) in each segment?

I can do this manually (e.g., dividing tn_trajectories into four segments, and then apply mt_measures to each segment). but is there any easy / ready-made function to do this?

Thank you



  • edited March 2019

    Hi Takashi,

    there is no mousetrap function that allows you to split a trajectory directly. However, you can do this yourself by only passing a selected range of positions to mt_measures:

    mt_example <- mt_time_normalize(mt_example)
    measures_1_26 <- mt_measures(mt_example$tn_trajectories[,1:26,])
    measures_27_51 <- mt_measures(mt_example$tn_trajectories[,27:51,])

    However, this way the idealized trajectory will depend on the start and end point of each segment which can lead to strange results for MAD, MD_above, AUC and AD. Other measures like xpos_flips will work fine.

    Alternatively, you can calculate the deviations from the idealized line directly for every position in the time-normalized trajectories using mt_deviations like below. Then, you can calculate the maximum and mean of these deviations for different segments which would correspond to the MD_above and AD for the segment.

    mt_example <- mt_deviations(mt_example, use="tn_trajectories")
    MD_above_1_26 <- apply(mt_example$tn_trajectories[,1:26,"dev_ideal"],1,max)
    MD_above_27_57 <- apply(mt_example$tn_trajectories[,1:26,"dev_ideal"],1,max)
    AD_1_26 <- apply(mt_example$tn_trajectories[,1:26,"dev_ideal"],1,mean)
    AD_27_57 <- apply(mt_example$tn_trajectories[,1:26,"dev_ideal"],1,mean)



Sign In or Register to comment.