Bart R
Bart R

Reputation: 157

Calculating response latency of the eye

I would like to calculate the response latency of the eye. I want to do this by measuring the time difference between onscreen appearance of a target and the onset of the fast eye movement in response.

Below a picutre of a single trial example. The purple line is the period where target appears on screen. The top line shows the position data of the Y coordinate of the eye, the bottom line shows the velocity. As you can see here, the fast eye movement downwards, with a high velocity, is a saccade. enter image description here

To give you an idea how my data looks, I made a dummy data.frame. The block represents the blocks you can also see in the figure. Ignore trial.block for now. saccade is a column telling you if the data is a S(saccade) or F(fixation).

Any idea how to calculate the time between Iview at the onset of the target and the onset of the first saccade for each individual trial?

Thanks alot

library(dplyr)
N = 500

G.df <- data.frame(Iview = seq(N*2),
               cue.condition = rep(c("spatial", "non-spatial"), each = N),
               block = rep(c("fixation.1", "fixation.2", "target.1", "target.2"), each = N/2),
               trial.block = rep(1:4, each = N/2),
               trial.number = rep(1:50, each = 10),
               saccade = sample(c("S","F"), size = 100, replace = T))

Upvotes: 1

Views: 83

Answers (1)

LAP
LAP

Reputation: 6685

I'm not sure if I understood your request correctly. The time between the first occurence of block == 'target.1' and the first occurence of block == 'target.1' & saccade == 'S' for each trial could be calculated like this:

G.df %>%
  group_by(trial.number) %>%
  summarise(time_between = Iview[block == "target.1" & saccade == "S"][1] - Iview[block == "target.1"][1])

# A tibble: 50 x 2
   trial.number time_between
          <int>        <int>
 1            1            2
 2            2            1
 3            3            0
 4            4            0
 5            5            1
 6            6            1
 7            7            1
 8            8            1
 9            9            0
10           10            0
# ... with 40 more rows

Upvotes: 1

Related Questions