Skip to content
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

mt_exclude_initiation not working #14

Closed
pierpri opened this issue Apr 5, 2021 · 3 comments
Closed

mt_exclude_initiation not working #14

pierpri opened this issue Apr 5, 2021 · 3 comments

Comments

@pierpri
Copy link

pierpri commented Apr 5, 2021

Hi,
Thanks for the awesome package! I have been trying to use the mt_exclude_initiation function, but it does not seem to work. That is, the returned trajectory array seems unchanged. As far as I can see, this applies also to the example in the documentation (with mt_example). I have also tried to apply it to the KH2017 data set. Same result - nothing seems to happen. The resulting trajectory data are identical to the non-modified trajectories. Am I doing something wrong?
Best,
Pierpaolo

@PascalKieslich
Copy link
Owner

Hi Pierpaolo,

thanks for raising the question. As far as I can see, everything seems to work fine with the mt_exclude_initiation function.

If you run the following code on the example data:

mt_example <- mt_exclude_initiation(mt_example,
  save_as="mod_trajectories")

and then compare the original trajectory data (stored in trajectories) with the modified trajectory data (stored in mod_trajectories), you will see that all initiatial periods without movements have been removed.

For example, mt_example$trajectories[32,1:40,] shows the first 40 positions of the the 32th trajectory, which are all 0 until 350 ms (the 36th position), when the movement was initiated. In comparison, if you look at the same trajectory in the modified trajectories via mt_example$mod_trajectories[32,1:40,] you will see that this movement now directly starts at the second position.

Notably, the standard trajectory plot of x, y positions will look unchanged as you don't really see the initial period without movement in it.

Does this help? Or were you referring to a different issue?

Best,

Pascal

@pierpri
Copy link
Author

pierpri commented Apr 6, 2021

Hi Pascal,

Thanks a lot for your quick reply. You're right, I had mistakenly overwritten the original trajectory array in the mt_example object. So the example works!

However, I still have difficulty with my own data and also the KH2017 data set. For example, when I run the following,

KH2017 <- mt_import_mousetrap(subset(KH2017_raw, correct==1)) %>% 
  mt_exclude_initiation(save_as = "mod_trajectories")

KH2017$trajectories[20, 1:80, ]
KH2017$mod_trajectories[20, 1:80, ]

I still get the same trajectory data from both trajectory arrays (unmodified and modified) in the two print statements. Shouldn't mt_exclude_initiation(save_as = "mod_trajectories") trim the respective 20th trajectory so that the modified trajectory starts at the 71st position, where the initiation happens?

Best,
Pierpaolo

@PascalKieslich
Copy link
Owner

Hi Pierpaolo,

thanks for providing the additional example. I took a look at it and you are correct, there indeed is a bug in mt_exclude_initiation.

Specifically, mt_exclude_initiation so far has only been behaving as intended when the initial position was (0,0), i.e., for these cases it removed the initial period without movement. If the initial position in a trial corresponded to a different value, the initial period without movement in most cases was simply not removed.

The issue has probably so far not received much attention (including me not spotting it), because many mouse-tracking analyses use mt_align_start first to align the trajectories to a common initial position - and mt_align_start has the default start values of (0, 0), meaning that mt_exclude_initiation has worked correctly in these cases (e.g., in the mt_example and the unmodified KH2017 datasets that are provided within mousetrap).

Thanks a lot for bringing this issue up! I will fix it now and push a new version to CRAN within the next days.

Best,

Pascal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants