Introduction

In this report, we will look at some statistics for the measured data. I only have data for two blocks from one subject.

For this report, we will combine leftward and rightward movements. Future analysis should look for differences in direction.

  1. comparison of pre and post mean Gaze peak velocity
  2. comparison of pre and post mean Gaze latency
  3. comparison of pre and post mean primary Gaze gain

  4. comparison of pre and post mean Head peak velocity e.comparison of pre and post mean Head latency
  5. comparison of pre and post mean head contribution to gaze
  6. comparison of pre and post mean head contribution gain
  7. comparison of pre and post mean head total amp
  8. comparison of pre and post mean head total amp gain

  9. comparison of pre and post mean final eye position re: head

I have two blocks of data. Preseason A-01 and post-season A-02

I will show some of these plots and the code needed to generate them from the measured data

library(ggplot2)
library(dplyr)
library(knitr)
samplerate<- 304.7508/1000
#load the measured data. See previous report for this process. 
hm <- readRDS('knightMeasuredDemo2018.RDS')

Let’s take a quick look at the measured data that will be used for plotting:

kable(head(hm,10))
block trialnum firstshift fixation.velocity gaze.onset gaze.offset gaze.dur gaze.amp total.gaze.offset total.gaze.amp peak.gaze.velocity IHP IGP IEP head.contribution total.head.contribution firsthead head.onset head.offset peak.head.velocity head.amp target.amp total.missing missing.critical missing.gs gaze.onset.ms
A-01 1 49 0.2182047 429 496 67 56.90950 496 55.69420 407.5210 -0.15626 3.4598 3.61606 13.11126 13.11126 13 410 680 64.45980 34.7917 57.6 51 32 19 751.43363
A-01 2 59 0.0915341 327 368 41 -46.60600 368 -45.27700 -480.8032 28.41900 56.4050 27.98600 -0.23600 -0.23600 16 439 671 NA NA -89.6 51 11 0 416.73393
A-01 3 78 0.1441907 353 408 55 -26.63103 408 -23.92363 -301.6979 -7.85250 -42.8540 -35.00150 -3.32550 -3.32550 18 349 455 -18.82968 -5.0808 -25.6 367 0 31 502.04954
A-01 4 80 1.7271703 291 336 45 35.47200 336 35.57300 449.8122 -15.07600 -55.5860 -40.51000 0.23300 0.23300 20 420 677 NA NA 102.4 247 159 0 298.60463
A-01 5 85 0.6973569 334 371 37 -42.95970 371 -41.76190 -543.8441 14.19300 50.2940 36.10100 -0.18300 -0.18300 21 459 704 NA NA -102.4 50 0 0 439.70352
A-01 6 93 -88.3286236 181 218 37 -7.22600 218 -1.74300 164.4675 -9.96320 -52.1470 -42.18380 -0.83380 -0.83380 21 0 212 -49.53115 -21.6770 57.6 79 18 2 -62.34602
A-01 7 104 -0.1015810 322 350 28 17.47080 434 57.21680 329.6843 -8.15040 3.1162 11.26660 1.85520 16.03420 23 311 564 56.83439 25.2133 57.6 51 21 11 400.32709
A-01 8 109 0.0580441 299 349 50 -61.70040 349 -60.38740 -538.5668 16.18100 59.0510 42.87000 -0.89500 -0.89500 Inf NA NA NA NA -57.6 11 0 11 324.85559
A-01 9 112 0.2512714 308 355 47 51.26128 355 49.69400 493.0480 12.89900 1.7020 -11.19700 0.14900 0.14900 Inf NA NA NA NA 44.8 0 0 0 354.38791
A-01 10 115 -0.0950496 310 357 47 -55.37430 357 -54.05330 -501.3978 13.19500 50.3330 37.13800 -0.36700 -0.36700 26 385 679 NA NA -102.4 20 0 0 360.95065
#Based on the previous report, I'm rejecting trials with 20 or more interpolated data points during the detected primary gaze shift, and trials where the latency is too short or too long. These ranges can be adjusted if future investigation warrants. 

hm %>%
  mutate(gaze.onset.ms=(gaze.onset-200)/samplerate) %>%
  filter(missing.gs<20,
         gaze.onset.ms>150,
         gaze.onset.ms<500) %>%
  
  ungroup()->
  hpp
hpp <- mutate(hpp,amp.bins.combined=cut(abs(target.amp),breaks=c(0,10,20,30,40,50,60,70,80)))
ggplot(filter(hpp,!is.na(amp.bins.combined)))+
  geom_boxplot(aes(amp.bins.combined,abs(peak.gaze.velocity),fill=block))+
  ylab('Peak gaze shift velocity (deg/s)')+
  xlab('Target amplitude bins combined left and right (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post peak gaze velocity')

ggplot(hpp,aes(abs(target.amp),abs(peak.gaze.velocity),color=block))+
  geom_point()+
  stat_smooth(method='lm')+
  ylab('Peak gaze shift velocity (deg/s)')+
  xlab('Target Amplitude (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post peak gaze velocity')

ggplot(filter(hpp,!is.na(amp.bins.combined)))+
  geom_boxplot(aes(amp.bins.combined,gaze.onset.ms,fill=block))+
  ylab('Gaze Shift Latency (ms)')+
  xlab('Target amplitude bins combined left and right (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post mean Gaze latency')

ggplot(hpp,aes(abs(target.amp),gaze.onset.ms,color=block))+
  geom_point()+
  ylab('Gaze Shift Latency (ms)')+
  xlab('Target amplitude combined left and right (deg)')+
  stat_smooth(method='lm')+
  theme_minimal()+
  ggtitle('comparison of pre and post mean Gaze latency')

  1. comparison of pre and post mean primary Gaze gain
ggplot(filter(hpp,!is.na(amp.bins.combined)))+
  geom_boxplot(aes(amp.bins.combined,abs(gaze.amp),fill=block))+
  ylab('Primary Gaze amplitude (deg)')+
  xlab('Target amplitude bins combined left and right (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post peak gaze gain')

ggplot(hpp,aes(abs(target.amp),abs(gaze.amp),color=block))+
  geom_point()+
  stat_smooth(method='lm')+
  ylab('Primary Gaze amplitude (deg)')+
  xlab('Target Amplitude (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post peak gaze gain')

Head movements

The plots here only include trials where head movements met the criteria for inclusion. This means that many trials without head movements are omitted.

e.comparison of pre and post mean Head latency

Note that there is significantly less head movement

hpp %>% 
  filter(head.onset<gaze.onset+100,
         head.onset>gaze.onset) %>%
  mutate(head.onset.ms=(head.onset-200)/samplerate)->
  hphead

hphead %>%
  filter(!is.na(amp.bins.combined)) %>%
  ggplot()+
  geom_boxplot(aes(amp.bins.combined,head.onset.ms,fill=block))+
  ylab('Head movement latency (ms)')+
  xlab('Target amplitude bins combined left and right (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post mean Head latency')

ggplot(hphead,aes(abs(target.amp),abs(head.onset.ms),color=block))+
  geom_point()+
  stat_smooth(method='lm')+
  ylab('Head Movement latency (ms)')+
  xlab('Target Amplitude (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post mean Head latency')

ggplot(filter(hphead,!is.na(amp.bins.combined)))+
  geom_boxplot(aes(amp.bins.combined,abs(peak.head.velocity),fill=block))+
  ylab('Peak head velocity (deg/s)')+
  xlab('Target amplitude bins combined left and right (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post mean Head peak velocity')
## Warning: Removed 14 rows containing non-finite values (stat_boxplot).

ggplot(hphead,aes(abs(target.amp),abs(peak.head.velocity),color=block))+
  geom_point()+
  stat_smooth(method='lm')+
  ylab('Peak Head Velocity (deg/s)')+
  xlab('Target Amplitude (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post mean Head peak velocity')
## Warning: Removed 17 rows containing non-finite values (stat_smooth).
## Warning: Removed 17 rows containing missing values (geom_point).

Some Statistics

As you can probably tell, once the data are organized and measured, the process of making the plots is straightforward and a matter of preference.

Doing the stats is similarly easy in terms of the number of lines of code required, but it requires careful attention to what is being measured. Here is an example:

ggplot(filter(hpp,!is.na(amp.bins.combined)))+
  geom_boxplot(aes(amp.bins.combined,gaze.onset.ms,fill=block))+
  ylab('Gaze Shift Latency (ms)')+
  xlab('Target amplitude bins combined left and right (deg)')+
  theme_minimal()+
  ggtitle('comparison of pre and post mean Gaze latency')

hpp %>%
  filter(!is.na(amp.bins.combined)) %>%
  group_by(amp.bins.combined) %>%
  do(g.onset.ms=t.test(gaze.onset.ms~block,data=.)$p.value)->
  stats1


kable(stats1)
amp.bins.combined g.onset.ms
(10,20] 0.3817485
(20,30] 0.1055063
(30,40] 0.3268133
(40,50] 0.02469099
(50,60] 0.4607734
(60,70] 0.6378242
(70,80] 0.5070733