Howdy, Stranger!

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

Supported by

mt_import_long error

Hi, I'm using mt_import_long() to import a mousetracking (repeated measures, long) dataset that was not collected in Opensesame. When I run it, I get the following error:


mt_data1 <- mt_import_long(mouse_dataincorrect, xpos_label = "X_C", ypos_label = "Y_C",timestamps_label = "timestamp", mt_id_label = "ID")

No mt_seq variable found (that indicates the order of the logs). Importing data in sequential order.

After removing trajectory data, more than one unique row per mt_id remains.


Instead of getting a list object I get an array and therefore I can't use other functions I need to use (like mt_time_normalize) that require a list. Any idea what the issue might be?


Thank you!

Comments

  • Hi there,

    would it be possible for you to share a few exemplary rows of the dataset (mouse_dataincorrect) that you use as input for the mt_import_long function? This could make it easier to understand what might be the cause of the problem here.

    Based on the warning message you mention above "After removing trajectory data, more than one unique row per mt_id remains.", one potential problem could be that you might have additional variables in your dataset (mouse_dataincorrect) that vary across the trial and that cause problems during data import. Specifically, after importing the trajectory data from the variables you specified above (X_C, Y_C, and timestamp), mt_import_mousetrap removes them from the original dataset and tries to create a trial level dataset from the remaining variables, assuming that they all remain constant for all rows of a trial (e.g., if the dataset contains the response given by the participant, this value should be constant across all rows of the trial). If there are additional variables that vary, the trial dataset is not built correctly and might cause problems in later analyses. If this is actually an issue here, you could remove the additional variables that vary across the trial from the mouse_dataincorrect dataset before using it as input for mt_import_long.

    Best,

    Pascal

  • engeng
    edited April 2021

    Hi,

    Sorry for the delayed response. Yes, that seemed to be the issue. Once I remove the non-constant variable I don't have that issue. However, I get a different error this time when I try to import the data using this function:


    mt_data1 <- mt_import_long(mouse_dataincorrect, xpos_label = "X_C", ypos_label = "Y_C",timestamps_label = "timestamp", mt_id_label = "ID")
    


    Error in trajectories[, , timestamps] - trajectories[, 1, timestamps] : 
     non-numeric argument to binary operator
    


    I think my variables have the correct structure to be imported (based on the sample script I'm following) but I'm providing a summary below in case I'm wrong:


    'data.frame':	61498 obs. of 19 variables:
     $ Order     : chr "GroupA" "GroupA" "GroupA" "GroupA" ...
     $ Duration   : int 564 564 564 564 564 564 564 564 564 564 ...
     $ ID      : chr "8968" "8968" "8968" "8968" ...
     $ timestamp   : Factor w/ 408 levels "0","100","200",..: 1 2 3 4 5 6 7 8 9 10 ...
     $ X_C      : Factor w/ 1037 levels "4","5","10","23",..: 329 329 329 329 329 329 329 329 329 329 ...
     $ Y_C      : Factor w/ 1015 levels "1","3","5","6",..: 439 439 439 439 439 439 439 439 439 439 ...
     $ Stimulus_type : chr "E2_11" "E2_11" "E2_11" "E2_11" ...
     $ Trial_duration: int 6298 6298 6298 6298 6298 6298 6298 6298 6298 6298 ...
     $ Trial_number : int 3 3 3 3 3 3 3 3 3 3 ...
     $ Condition   : Factor w/ 3 levels "Complex","Control",..: 3 3 3 3 3 3 3 3 3 3 ...
     $ Correct_X   : int 883 883 883 883 883 883 883 883 883 883 ...
     $ Correct_Y   : int 281 281 281 281 281 281 281 281 281 281 ...
     $ Incorrect_X  : int 542 542 542 542 542 542 542 542 542 542 ...
     $ Incorrect_Y  : int 394 394 394 394 394 394 394 394 394 394 ...
     $ AnsProp    : num 1.53 1.53 1.53 1.53 1.53 ...
     $ CorrProp   : num 3.14 3.14 3.14 3.14 3.14 ...
     $ DiffScore   : num -1.61 -1.61 -1.61 -1.61 -1.61 ...
     $ DiffScore1  : num 0 0 0 0 0 0 0 0 0 0 ...
     $ Acc_final   : num 0 0 0 0 0 0 0 0 0 0 ...
    
    


    I appreciate any help!

    Ester

  • Hi Ester,

    thanks for providing a summary of the data. I would agree in that the structure seems to have the correct format required by mt_import_long .

    However, based on the information on the data you provide, I think that there is an issue with the imestamp, X_C, and Y_C variables as they are of type Factorand not numor int . You could try to convert them, e.g., using the as.numeric function. However, it is probably best to first find out if there are any non-numeric values stored in these variables or if there is an issue when you read the data from file into R?

    Best,

    Pascal

Sign In or Register to comment.