Skip to contents

Analyses total time on defined AOI regions across trials separated into bins. Works with raw data as the input. Data can be separated into bins of a given length of time and the number of bins per trial is calculated automatically, keeping the bin length consistent across varying lengths of trial. Any r=data that cannot fill a bin (tpyically the last few milliseconds of the trial) are dropped to ensure that bins are of a consistent length

Usage

AOI_time_binned(
  data,
  AOIs,
  AOI_names = NULL,
  sample_rate = NULL,
  bin_length = NULL,
  max_time = NULL,
  as_prop = FALSE,
  participant_ID = "participant_ID"
)

Arguments

data

A dataframe of raw data

AOIs

A dataframe of areas of interest (AOIs), with one row per AOI (x, y, width_radius, height).

AOI_names

An optional vector of AOI names to replace the default "AOI_1", "AOI_2", etc.

sample_rate

Optional sample rate of the eye-tracker (Hz) for use with data. If not supplied, the sample rate will be estimated from the time column and the number of samples.

bin_length

the time duration to be used for each bin.

max_time

maximum length of time to use, default is total trial length

as_prop

whether to return time in AOI as a proportion of the total time of trial

participant_ID

the variable that determines the participant identifier. If no column present, assumes a single participant

Value

a dataframe containing the time on the passed AOIs for each trial. One column for each AOI separated by trial.

Details

AOI_time_binned can take either single participant data or multiple participants where there is a variable for unique participant identification. The function looks for an identifier named participant_ID by default and will treat this as multiple-participant data as default, if not it is handled as single participant data, or the participant_ID needs to be specified

Examples


# \donttest{
data <- combine_eyes(HCL)


#with bins of 100ms each and only for the first 2000ms
AOI_time_binned(data = data, AOIs = HCL_AOIs, participant_ID = "pNum",
    bin_length = 100, max_time = 2000)
#>     pNum trial bin_n AOI_1 AOI_2 AOI_3
#> 1    118     1     1     0     0     0
#> 2    118     1     2     0     0     0
#> 3    118     1     3     0     0     0
#> 4    118     1     4     0     0     0
#> 5    118     1     5     0     0    63
#> 6    118     1     6     0     0   100
#> 7    118     1     7     0     0   100
#> 8    118     1     8    27     0    47
#> 9    118     1     9   100     0     0
#> 10   118     1    10   100     0     0
#> 11   118     1    11   100     0     0
#> 12   118     1    12    90     0     0
#> 13   118     1    13     0     0     0
#> 14   118     1    14     0     0    20
#> 15   118     1    15     0     0   100
#> 16   118     1    16     0     0   100
#> 17   118     1    17     0     0   100
#> 18   118     1    18     0     0   100
#> 19   118     1    19     0     0   100
#> 20   118     1    20     0     0   100
#> 21   118     2     1     0     0     0
#> 22   118     2     2     0     0     0
#> 23   118     2     3     0     0     0
#> 24   118     2     4     0    20     0
#> 25   118     2     5     0   100     0
#> 26   118     2     6     0   100     0
#> 27   118     2     7     0   100     0
#> 28   118     2     8     0   100     0
#> 29   118     2     9     0   100     0
#> 30   118     2    10     0   100     0
#> 31   118     2    11     0   100     0
#> 32   118     2    12     0    63    13
#> 33   118     2    13     0     0   100
#> 34   118     2    14     0     0   100
#> 35   118     2    15     0     0   100
#> 36   118     2    16     0     0   100
#> 37   118     2    17     0     0   100
#> 38   118     2    18     0     0   100
#> 39   118     2    19     0     0   100
#> 40   118     2    20     0     0    90
#> 41   118     3     1     0     0     0
#> 42   118     3     2     0     0     0
#> 43   118     3     3     0     0     0
#> 44   118     3     4     0     0     7
#> 45   118     3     5     0     0   100
#> 46   118     3     6     0     0   100
#> 47   118     3     7     0     0   100
#> 48   118     3     8     0     0   100
#> 49   118     3     9     0     0   100
#> 50   118     3    10     0    33    40
#> 51   118     3    11     0   100     0
#> 52   118     3    12     0   100     0
#> 53   118     3    13    57    10     0
#> 54   118     3    14   100     0     0
#> 55   118     3    15   100     0     0
#> 56   118     3    16   100     0     0
#> 57   118     3    17   100     0     0
#> 58   118     3    18   100     0     0
#> 59   118     3    19    33     0    40
#> 60   118     3    20     0     0   100
#> 61   118     4     1     0     0     0
#> 62   118     4     2     0    20     0
#> 63   118     4     3     0   100     0
#> 64   118     4     4     0   100     0
#> 65   118     4     5     0   100     0
#> 66   118     4     6     0    43    33
#> 67   118     4     7     0     0   100
#> 68   118     4     8     0     0   100
#> 69   118     4     9     0     0   100
#> 70   118     4    10     0     0   100
#> 71   118     4    11     0     0    73
#> 72   118     4    12   100     0     0
#> 73   118     4    13   100     0     0
#> 74   118     4    14   100     0     0
#> 75   118     4    15   100     0     0
#> 76   118     4    16    47     0     0
#> 77   118     4    17     0    63     0
#> 78   118     4    18     0   100     0
#> 79   118     4    19     0   100     0
#> 80   118     4    20     0   100     0
#> 81   118     5     1     0     0     0
#> 82   118     5     2     7     0     0
#> 83   118     5     3    97     0     0
#> 84   118     5     4   100     0     0
#> 85   118     5     5    37     0    40
#> 86   118     5     6     0     0   100
#> 87   118     5     7     0     0   100
#> 88   118     5     8     0     0    67
#> 89   118     5     9     0     0     0
#> 90   118     5    10    43     0     0
#> 91   118     5    11    63     7     0
#> 92   118     5    12     0   100     0
#> 93   118     5    13     0   100     0
#> 94   118     5    14     0   100     0
#> 95   118     5    15     0   100     0
#> 96   118     5    16     0   100     0
#> 97   118     5    17     0    73     3
#> 98   118     5    18     0     0   100
#> 99   118     5    19     0     0   100
#> 100  118     5    20     0     0   100
#> 101  118     6     1     0     0     0
#> 102  118     6     2     0     0     0
#> 103  118     6     3     0     0     0
#> 104  118     6     4     0     0    60
#> 105  118     6     5     0     0   100
#> 106  118     6     6     0     0    80
#> 107  118     6     7     0    93     0
#> 108  118     6     8     0   100     0
#> 109  118     6     9     0   100     0
#> 110  118     6    10     0   100     0
#> 111  118     6    11     0   100     0
#> 112  118     6    12     0    70     0
#> 113  118     6    13    97     0     0
#> 114  118     6    14   100     0     0
#> 115  118     6    15   100     0     0
#> 116  118     6    16    30     0    43
#> 117  118     6    17     0     0   100
#> 118  118     6    18     0     0   100
#> 119  118     6    19     0     0   100
#> 120  118     6    20     0     0   100
#> 121  119     1     1     0     0     0
#> 122  119     1     2     0     0     0
#> 123  119     1     3     0     0     0
#> 124  119     1     4     0     0     0
#> 125  119     1     5     0     0    77
#> 126  119     1     6     0     0   100
#> 127  119     1     7     0     0   100
#> 128  119     1     8     0     0   100
#> 129  119     1     9     0     0   100
#> 130  119     1    10     7     0    70
#> 131  119     1    11   100     0     0
#> 132  119     1    12   100     0     0
#> 133  119     1    13   100     0     0
#> 134  119     1    14    90     0     0
#> 135  119     1    15     0     0     7
#> 136  119     1    16     0     0    70
#> 137  119     1    17     0     0   100
#> 138  119     1    18     0     0   100
#> 139  119     1    19     0     0    80
#> 140  119     1    20     0     0     0
#> 141  119     2     1     0     0     0
#> 142  119     2     2    23     0     0
#> 143  119     2     3   100     0     0
#> 144  119     2     4   100     0     0
#> 145  119     2     5   100     0     0
#> 146  119     2     6    73     0     0
#> 147  119     2     7     0    90     0
#> 148  119     2     8     0   100     0
#> 149  119     2     9     0   100     0
#> 150  119     2    10     0   100     0
#> 151  119     2    11     0    93     0
#> 152  119     2    12     0     0     0
#> 153  119     2    13     0     0    43
#> 154  119     2    14     0     0   100
#> 155  119     2    15     0     0   100
#> 156  119     2    16     0     0   100
#> 157  119     2    17     0     0   100
#> 158  119     2    18     0     0   100
#> 159  119     2    19     0     0   100
#> 160  119     2    20     0     0   100
#> 161  119     3     1     0     0     0
#> 162  119     3     2     0     0     0
#> 163  119     3     3    97     0     0
#> 164  119     3     4   100     0     0
#> 165  119     3     5   100     0     0
#> 166  119     3     6   100     0     0
#> 167  119     3     7    73     0     0
#> 168  119     3     8     0    93     0
#> 169  119     3     9     0   100     0
#> 170  119     3    10     0   100     0
#> 171  119     3    11     0   100     0
#> 172  119     3    12     0    63    17
#> 173  119     3    13     0     0   100
#> 174  119     3    14     0     0   100
#> 175  119     3    15     0     0   100
#> 176  119     3    16     0     0   100
#> 177  119     3    17     0     0   100
#> 178  119     3    18     0     0   100
#> 179  119     3    19     0     0   100
#> 180  119     3    20     0     0   100
#> 181  119     4     1     0     0     0
#> 182  119     4     2     0     0     0
#> 183  119     4     3    47     0     0
#> 184  119     4     4   100     0     0
#> 185  119     4     5   100     0     0
#> 186  119     4     6   100     0     0
#> 187  119     4     7   100     0     0
#> 188  119     4     8   100     0     0
#> 189  119     4     9   100     0     0
#> 190  119     4    10   100     0     0
#> 191  119     4    11   100     0     0
#> 192  119     4    12   100     0     0
#> 193  119     4    13   100     0     0
#> 194  119     4    14    93     0     0
#> 195  119     4    15     0    73     0
#> 196  119     4    16     0   100     0
#> 197  119     4    17     0   100     0
#> 198  119     4    18     0   100     0
#> 199  119     4    19     0    67     0
#> 200  119     4    20    57     0     0
#> 201  119     5     1     0     0     0
#> 202  119     5     2     0     0     0
#> 203  119     5     3    70     0     0
#> 204  119     5     4   100     0     0
#> 205  119     5     5   100     0     0
#> 206  119     5     6   100     0     0
#> 207  119     5     7   100     0     0
#> 208  119     5     8   100     0     0
#> 209  119     5     9   100     0     0
#> 210  119     5    10   100     0     0
#> 211  119     5    11   100     0     0
#> 212  119     5    12     3    60     0
#> 213  119     5    13     0   100     0
#> 214  119     5    14     0   100     0
#> 215  119     5    15     0   100     0
#> 216  119     5    16     0   100     0
#> 217  119     5    17     0   100     0
#> 218  119     5    18     0   100     0
#> 219  119     5    19     0   100     0
#> 220  119     5    20     0   100     0
#> 221  119     6     1     0     0     0
#> 222  119     6     2     0     0     0
#> 223  119     6     3     0     0     0
#> 224  119     6     4     0     0     0
#> 225  119     6     5     0     0    67
#> 226  119     6     6     0     0    97
#> 227  119     6     7    80     0     0
#> 228  119     6     8   100     0     0
#> 229  119     6     9   100     0     0
#> 230  119     6    10   100     0     0
#> 231  119     6    11   100     0     0
#> 232  119     6    12   100     0     0
#> 233  119     6    13   100     0     0
#> 234  119     6    14   100     0     0
#> 235  119     6    15   100     0     0
#> 236  119     6    16   100     0     0
#> 237  119     6    17   100     0     0
#> 238  119     6    18   100     0     0
#> 239  119     6    19   100     0     0
#> 240  119     6    20   100     0     0
# }