Howdy, Stranger!

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

Supported by

Question about 'mt_time_normalize' function in mousetrap R package

Hi there,

I am a psychology student and I am trying to use mousetrap to analysis some mouse tracking data. Our task is asking the participants to rate their emotion on a x-y coordinate. When I am trying to use mt_time_normalize function to do the temporal normalization, sometimes I will get the error :

Error in stats::approx(trajectories[i, , timestamps], trajectories[i, : need at least two non-NA values to interpolate

I searched about this, and it seems that it's caused by the tied x when y is different (so the code doesn't know how to interpolate between these two points). I speculate that if we add [tied = ordered] in the code for mt_time_normalize this problem may be solved, but I am not sure whether this is the right way to do this.

Hope to get your comments on this issue!



  • Hi Haoxue,

    I think that the error is caused by trajectories that contain <= 2 logged positions. I would suggest that you check this in your data and potentially exclude all trajectories with <= 2 logged positions.

    # Load mousetrap library
    # Calculate number of logged positions
    mt_example <- mt_count(mt_example, save_as = "data")
    # Table of number of logged positions
    # Check if there are trials with 2 or fewer logged positions
    # Only keep trials with more than 2 logged positions
    mt_example <- mt_subset(mt_example, nobs>2)

    Hope this helps. Just let me know if it does not work or if you have additional questions.



  • Hi Pascal,

    Thanks for your quick reply! I have now figured out why temporal normalization doesn't work - this is due to in some trials the participants didn't move their mouse at all (because we don't have a required ending point), then something is wrong in the process to align start and end.

    Truly there're a bunch of data with logged position <=2, but now it seems that it isn't the real problem.

    Besides, could you please tell me what exactly 'logged position' means? I am still a little bit confused about this concept.

    Thanks again for this amazing R package and your help!


  • Hi Haoxue,

    indeed there seems to be an additional problem in case all positions in a trial are the same. However, what happens then is that mt_align_start_end does not work properly, result in every positiion to be NaN. This subsequently leads to a problem in mt_time_normalize.

    I would suggest to exclude all trials with identical positions across the whole trial, as these trials (where the cursor was not moved at all) would also not contain any relevant information for computing mouse-tracking indices or creating plots. You could do this using the following code:

    # Calculate variance of positions for each trial
    mt_example$data$pos_var <- apply(mt_example$trajectories[,,"xpos"],1,var,na.rm=TRUE) + apply(mt_example$trajectories[,,"ypos"],1,var,na.rm=TRUE)
    # Check if there are trials with 0 variance (i.e., all positions are identical)
    # Only keep trials where positions varied
    mt_example <- mt_subset(mt_example, pos_var>0)

    With logged positions I just meant that each trial varies with regard to the number of cursor positions that was recorded. If you use the mousetrap plugin in OpenSesame to track mouse movements, it will be default record the cursor position every 10 ms leading to 101 recorded positions for a trial lasting 1 s and 201 recorded positions for a trial lasting 2 s.



Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games