Introduction

This notebook contains statistical analyses reported in Stauch, Peter, Ehrlich, Nolte, & Fries (2021), Gammaband responses to equiluminant colors in early human visual cortex.

To run it, the dataset color_dataset.csv (available from Zenodo) needs to be stored in the same folder as the notebook.

First, we’ll load in required libraries as well as the dataset, remove invalid trials and prepare data formats.

library(magrittr)
library(lme4)
library(lmerTest)
library(afex)
library(dplyr)
library(data.table)
library(tidyverse)
library(Hmisc)
library(emmeans)
library(tidymodels)
library(MuMIn)
library(BayesFactor)
data <- fread('color_dataset.csv', stringsAsFactors=TRUE)
data$ID <- factor(data$ID)
data$stimulusVerbal <- relevel(data$stimulusVerbal, ref = "grating")
data %<>% filter(answer !='prepress' & answer !='pause')

peaks <- fread('color_peaks.csv', stringsAsFactors=TRUE)

Results

We’ll now go through the subsections of our Results and provide code for statistical analyses.

Behavior

Get average per-subject accuracy and reaction times.

data %>% 
    filter(correctReport==1|correctReport==0) %>%
    filter(wasCatch==0 & wasFixated==1) -> behavData
behavData %>% 
    group_by(ID, stimType) %>%
    dplyr::summarize(meanAcc = mean(correctReport, na.rm=TRUE),
                     meanRT = mean(rt, na.rm=TRUE)) -> meanBehav
behavData %>% 
    group_by(ID, stimulusVerbal) %>%
    dplyr::summarize(meanAcc = mean(correctReport, na.rm=TRUE),
                     meanRT = mean(rt, na.rm=TRUE)) -> meanBehavAllStims
behavData %>% 
    group_by(ID, stimulusVerbal) %>%
    filter(repNr > 50) %>% # repetitions during which staircases were stable
    dplyr::summarize(meanContrast = mean(tContrast, na.rm=TRUE)) ->
                       meanBehavAllStimsStable

Get average RT.

meanBehav %>%
    group_by(stimType) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$meanRT*1000))))

Get average accuracy.

meanBehav %>%
    group_by(stimType) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$meanAcc))))

Compare reaction times over stimuli.

meanBehavAllStims %>%
    group_by(stimulusVerbal) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$meanRT*1000))))
meanBehavAllStims %>% ungroup() %>%
    filter(stimulusVerbal != "grating") -> dat

m0 <- aov_ez(id = "ID", dv = "meanRT", within = "stimulusVerbal",
              data = dat)
summary(m0)
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                Sum Sq num Df Error SS den Df   F value    Pr(>F)    
## (Intercept)    71.783      1  1.19798     29 1737.6899 < 2.2e-16 ***
## stimulusVerbal  0.062      7  0.19488    203    9.2562 6.237e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Mauchly Tests for Sphericity
## 
##                Test statistic p-value
## stimulusVerbal        0.58141 0.97814
## 
## 
## Greenhouse-Geisser and Huynh-Feldt Corrections
##  for Departure from Sphericity
## 
##                 GG eps Pr(>F[GG])    
## stimulusVerbal 0.87151   6.47e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                  HF eps   Pr(>F[HF])
## stimulusVerbal 1.129272 6.236841e-10
emmeans(m0, specs = pairwise~stimulusVerbal, adjust ='holm')
## $emmeans
##  stimulusVerbal emmean     SE df lower.CL upper.CL
##  blue            0.560 0.0136 29    0.532    0.588
##  green           0.558 0.0141 29    0.529    0.587
##  greenblue       0.550 0.0142 29    0.521    0.579
##  greenyellow     0.562 0.0137 29    0.534    0.590
##  red             0.509 0.0146 29    0.480    0.539
##  redblue         0.548 0.0155 29    0.517    0.580
##  redyellow       0.552 0.0139 29    0.524    0.581
##  yellow          0.536 0.0136 29    0.508    0.563
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                estimate      SE df t.ratio p.value
##  blue - green             0.00245 0.00831 29   0.294  1.0000
##  blue - greenblue         0.01006 0.00810 29   1.242  1.0000
##  blue - greenyellow      -0.00136 0.00683 29  -0.199  1.0000
##  blue - red               0.05073 0.00786 29   6.451  <.0001
##  blue - redblue           0.01189 0.00852 29   1.394  1.0000
##  blue - redyellow         0.00804 0.00878 29   0.915  1.0000
##  blue - yellow            0.02439 0.00769 29   3.174  0.0674
##  green - greenblue        0.00761 0.00825 29   0.922  1.0000
##  green - greenyellow     -0.00380 0.00744 29  -0.511  1.0000
##  green - red              0.04828 0.00810 29   5.957  <.0001
##  green - redblue          0.00944 0.00846 29   1.115  1.0000
##  green - redyellow        0.00559 0.00896 29   0.624  1.0000
##  green - yellow           0.02195 0.00656 29   3.346  0.0466
##  greenblue - greenyellow -0.01142 0.00698 29  -1.636  1.0000
##  greenblue - red          0.04066 0.00735 29   5.531  0.0001
##  greenblue - redblue      0.00183 0.00841 29   0.217  1.0000
##  greenblue - redyellow   -0.00202 0.00792 29  -0.255  1.0000
##  greenblue - yellow       0.01433 0.00721 29   1.988  1.0000
##  greenyellow - red        0.05208 0.00760 29   6.851  <.0001
##  greenyellow - redblue    0.01324 0.00798 29   1.661  1.0000
##  greenyellow - redyellow  0.00940 0.00864 29   1.087  1.0000
##  greenyellow - yellow     0.02575 0.00659 29   3.907  0.0113
##  red - redblue           -0.03884 0.00731 29  -5.316  0.0003
##  red - redyellow         -0.04269 0.00811 29  -5.263  0.0003
##  red - yellow            -0.02633 0.00784 29  -3.356  0.0466
##  redblue - redyellow     -0.00385 0.00970 29  -0.397  1.0000
##  redblue - yellow         0.01251 0.00926 29   1.351  1.0000
##  redyellow - yellow       0.01636 0.00821 29   1.993  1.0000
## 
## P value adjustment: holm method for 28 tests

Compare staircased target contrast over stimuli.

meanBehavAllStimsStable %>%
    group_by(stimulusVerbal) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$meanContrast*100))))
meanBehavAllStimsStable %>% ungroup() %>%
    filter(stimulusVerbal != "grating") -> dat

m1 <- aov_ez(id = "ID", dv = "meanContrast", within = "stimulusVerbal",
              data = dat)
summary(m1)
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                 Sum Sq num Df Error SS den Df F value    Pr(>F)    
## (Intercept)    24.7034      1  0.78261     29 915.392 < 2.2e-16 ***
## stimulusVerbal  5.8773      7  2.07414    203  82.175 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Mauchly Tests for Sphericity
## 
##                Test statistic   p-value
## stimulusVerbal       0.088246 8.148e-05
## 
## 
## Greenhouse-Geisser and Huynh-Feldt Corrections
##  for Departure from Sphericity
## 
##                 GG eps Pr(>F[GG])    
## stimulusVerbal 0.58532  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                   HF eps   Pr(>F[HF])
## stimulusVerbal 0.6936535 1.873504e-39
m1
## Anova Table (Type 3 tests)
## 
## Response: meanContrast
##           Effect           df  MSE         F  ges p.value
## 1 stimulusVerbal 4.10, 118.82 0.02 82.17 *** .673   <.001
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
## 
## Sphericity correction method: GG
emmeans(m1, specs = pairwise~stimulusVerbal, adjust ='holm')
## $emmeans
##  stimulusVerbal emmean     SE df lower.CL upper.CL
##  blue            0.709 0.0242 29    0.660    0.758
##  green           0.302 0.0141 29    0.273    0.331
##  greenblue       0.293 0.0139 29    0.265    0.322
##  greenyellow     0.204 0.0226 29    0.158    0.251
##  red             0.219 0.0148 29    0.189    0.250
##  redblue         0.372 0.0325 29    0.305    0.438
##  redyellow       0.199 0.0152 29    0.168    0.230
##  yellow          0.268 0.0170 29    0.234    0.303
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                estimate     SE df t.ratio p.value
##  blue - green             0.40691 0.0255 29  15.951  <.0001
##  blue - greenblue         0.41573 0.0234 29  17.778  <.0001
##  blue - greenyellow       0.50470 0.0324 29  15.554  <.0001
##  blue - red               0.48963 0.0275 29  17.829  <.0001
##  blue - redblue           0.33735 0.0386 29   8.737  <.0001
##  blue - redyellow         0.51030 0.0285 29  17.902  <.0001
##  blue - yellow            0.44062 0.0282 29  15.652  <.0001
##  green - greenblue        0.00882 0.0164 29   0.538  1.0000
##  green - greenyellow      0.09779 0.0229 29   4.268  0.0027
##  green - red              0.08272 0.0176 29   4.693  0.0010
##  green - redblue         -0.06957 0.0332 29  -2.093  0.3042
##  green - redyellow        0.10339 0.0180 29   5.742  0.0001
##  green - yellow           0.03371 0.0160 29   2.112  0.3042
##  greenblue - greenyellow  0.08897 0.0265 29   3.353  0.0268
##  greenblue - red          0.07390 0.0177 29   4.167  0.0033
##  greenblue - redblue     -0.07838 0.0306 29  -2.563  0.1425
##  greenblue - redyellow    0.09457 0.0190 29   4.969  0.0005
##  greenblue - yellow       0.02490 0.0211 29   1.180  1.0000
##  greenyellow - red       -0.01507 0.0259 29  -0.581  1.0000
##  greenyellow - redblue   -0.16735 0.0315 29  -5.312  0.0002
##  greenyellow - redyellow  0.00560 0.0235 29   0.239  1.0000
##  greenyellow - yellow    -0.06408 0.0211 29  -3.033  0.0556
##  red - redblue           -0.15228 0.0318 29  -4.787  0.0008
##  red - redyellow          0.02067 0.0197 29   1.051  1.0000
##  red - yellow            -0.04900 0.0215 29  -2.284  0.2388
##  redblue - redyellow      0.17295 0.0356 29   4.863  0.0007
##  redblue - yellow         0.10328 0.0374 29   2.762  0.0986
##  redyellow - yellow      -0.06968 0.0154 29  -4.514  0.0015
## 
## P value adjustment: holm method for 28 tests

Test blue target contrast against all other colors.

meanBehavAllStimsStable %>%
  filter(stimulusVerbal != 'grating') %>%
  mutate(isBlue = factor(stimulusVerbal=='blue')) %>%
  group_by(isBlue, ID) %>%
  dplyr::summarize(meanContBN = mean(meanContrast)) %>%
  group_split(isBlue) -> s1

t.test(s1[[1]]$meanContBN, s1[[2]]$meanContBN, paired = TRUE)
## 
##  Paired t-test
## 
## data:  s1[[1]]$meanContBN and s1[[2]]$meanContBN
## t = -18.009, df = 29, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.4939853 -0.3932275
## sample estimates:
## mean of the differences 
##              -0.4436064

ERFs

Get averages over stimulus types

data %>% 
    filter(wasFixated==1) -> erfData
erfData %>% 
    group_by(ID, stimType) %>%
    dplyr::summarize(meanC1 = mean(C1, na.rm=TRUE)) %>%
    ungroup() -> meanERFType
erfData %>% 
    group_by(ID, stimulusVerbal) %>%
    dplyr::summarize(meanC1 = mean(C1, na.rm=TRUE)) %>%
    ungroup() -> meanERFStim

Compare between stimuli

meanERFStim %>%
    group_by(stimulusVerbal) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$meanC1))))
meanERFStim %>% ungroup() %>%
    filter(stimulusVerbal != "grating") -> dat

m2 <- aov_ez(id = "ID", dv = "meanC1", within = "stimulusVerbal",
              data = dat)
summary(m2)
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                Sum Sq num Df Error SS den Df F value    Pr(>F)    
## (Intercept)    52.034      1   6.4973     29 232.248  2.23e-15 ***
## stimulusVerbal  3.287      7   2.8935    203  32.944 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Mauchly Tests for Sphericity
## 
##                Test statistic    p-value
## stimulusVerbal       0.014211 2.9848e-12
## 
## 
## Greenhouse-Geisser and Huynh-Feldt Corrections
##  for Departure from Sphericity
## 
##                 GG eps Pr(>F[GG])    
## stimulusVerbal 0.48744  5.588e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                   HF eps  Pr(>F[HF])
## stimulusVerbal 0.5603186 4.99152e-18
m2
## Anova Table (Type 3 tests)
## 
## Response: meanC1
##           Effect          df  MSE         F  ges p.value
## 1 stimulusVerbal 3.41, 98.95 0.03 32.94 *** .259   <.001
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
## 
## Sphericity correction method: GG
emmeans(m2, specs = pairwise~stimulusVerbal, adjust ='holm')
## $emmeans
##  stimulusVerbal emmean     SE df lower.CL upper.CL
##  blue           -0.228 0.0175 29   -0.264   -0.192
##  green          -0.454 0.0309 29   -0.517   -0.391
##  greenblue      -0.359 0.0221 29   -0.404   -0.314
##  greenyellow    -0.587 0.0431 29   -0.675   -0.499
##  red            -0.599 0.0485 29   -0.698   -0.500
##  redblue        -0.544 0.0445 29   -0.635   -0.453
##  redyellow      -0.441 0.0296 29   -0.501   -0.380
##  yellow         -0.513 0.0444 29   -0.604   -0.423
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                estimate     SE df t.ratio p.value
##  blue - green              0.2258 0.0263 29   8.574  <.0001
##  blue - greenblue          0.1308 0.0172 29   7.604  <.0001
##  blue - greenyellow        0.3589 0.0358 29  10.032  <.0001
##  blue - red                0.3711 0.0435 29   8.535  <.0001
##  blue - redblue            0.3159 0.0369 29   8.553  <.0001
##  blue - redyellow          0.2126 0.0271 29   7.837  <.0001
##  blue - yellow             0.2853 0.0349 29   8.180  <.0001
##  green - greenblue        -0.0951 0.0209 29  -4.542  0.0013
##  green - greenyellow       0.1331 0.0180 29   7.387  <.0001
##  green - red               0.1453 0.0279 29   5.211  0.0002
##  green - redblue           0.0901 0.0247 29   3.649  0.0113
##  green - redyellow        -0.0132 0.0241 29  -0.548  1.0000
##  green - yellow            0.0594 0.0310 29   1.919  0.4194
##  greenblue - greenyellow   0.2282 0.0313 29   7.278  <.0001
##  greenblue - red           0.2403 0.0358 29   6.708  <.0001
##  greenblue - redblue       0.1851 0.0316 29   5.856  <.0001
##  greenblue - redyellow     0.0818 0.0202 29   4.046  0.0042
##  greenblue - yellow        0.1545 0.0353 29   4.379  0.0018
##  greenyellow - red         0.0122 0.0331 29   0.367  1.0000
##  greenyellow - redblue    -0.0430 0.0297 29  -1.450  0.6307
##  greenyellow - redyellow  -0.1463 0.0316 29  -4.630  0.0011
##  greenyellow - yellow     -0.0737 0.0236 29  -3.117  0.0369
##  red - redblue            -0.0552 0.0189 29  -2.915  0.0544
##  red - redyellow          -0.1585 0.0310 29  -5.105  0.0003
##  red - yellow             -0.0858 0.0438 29  -1.958  0.4194
##  redblue - redyellow      -0.1033 0.0292 29  -3.533  0.0140
##  redblue - yellow         -0.0306 0.0384 29  -0.798  1.0000
##  redyellow - yellow        0.0727 0.0376 29   1.933  0.4194
## 
## P value adjustment: holm method for 28 tests

Test grating ERF vs color ERF.

meanERFType %>%
  group_split(stimType) -> s1

t.test(s1[[1]]$meanC1, s1[[2]]$meanC1, paired = TRUE)
## 
##  Paired t-test
## 
## data:  s1[[1]]$meanC1 and s1[[2]]$meanC1
## t = 6.941, df = 29, p-value = 1.251e-07
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.3168609 0.5815992
## sample estimates:
## mean of the differences 
##               0.4492301

Gamma power and frequency

Get average per-subject gamma power and frequency per stimulus

data %>% 
    filter(wasFixated==1) -> gammaData
gammaData %>% 
    group_by(ID, stimType) %>%
    dplyr::summarize(meanGPower = mean(percGammapower, na.rm=TRUE),
                     meanGFreq = mean(realGammapeak, na.rm=TRUE)) %>%
    ungroup() -> meanGP
gammaData %>% 
    group_by(ID, stimulusVerbal) %>%
    dplyr::summarize(meanGPower = mean(percGammapower, na.rm=TRUE),
                     meanGFreq = mean(realGammapeak, na.rm=TRUE)) %>%
    ungroup() -> meanGPStims
peaks %>%
  group_by(ID, stimType) %>%
  dplyr::summarize(meanPeak1 = mean(peak1, na.rm=TRUE),
                   meanPeak2 = mean(peak2, na.rm=TRUE)) %>%
  ungroup() -> peaksStimtype

Compare gamma power between stimulus types

meanGP %>%
    group_by(stimType) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$meanGPower))))
meanGP %>%
  group_split(stimType) -> s1

t.test(s1[[1]]$meanGPower, s1[[2]]$meanGPower, paired = TRUE)
## 
##  Paired t-test
## 
## data:  s1[[1]]$meanGPower and s1[[2]]$meanGPower
## t = -8.3195, df = 29, p-value = 3.594e-09
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -100.22417  -60.67036
## sample estimates:
## mean of the differences 
##               -80.44727

Compare gamma frequency between stimulus types

peaksStimtype %>%
    group_by(stimType) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$meanPeak1, na.rm=TRUE))))
peaksStimtype %>%
  group_split(stimType) -> s1

t.test(s1[[1]]$meanPeak1, s1[[2]]$meanPeak1, paired = TRUE)
## 
##  Paired t-test
## 
## data:  s1[[1]]$meanPeak1 and s1[[2]]$meanPeak1
## t = -4.2483, df = 27, p-value = 0.0002288
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -7.146827 -2.491694
## sample estimates:
## mean of the differences 
##                -4.81926
cor.test(s1[[1]]$meanPeak1, s1[[2]]$meanPeak1)
## 
##  Pearson's product-moment correlation
## 
## data:  s1[[1]]$meanPeak1 and s1[[2]]$meanPeak1
## t = 4.2245, df = 26, p-value = 0.0002598
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.3476463 0.8166744
## sample estimates:
##       cor 
## 0.6379782
peaksStimtype %>%
    group_by(stimType) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$meanPeak2, na.rm=TRUE)))) 
t.test(s1[[1]]$meanPeak2, s1[[2]]$meanPeak2, paired = TRUE)
## 
##  Paired t-test
## 
## data:  s1[[1]]$meanPeak2 and s1[[2]]$meanPeak2
## t = 0.54335, df = 1, p-value = 0.6831
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -110.1574  119.9996
## sample estimates:
## mean of the differences 
##                 4.92107

Compare gamma power between stimuli

meanGPStims %>%
    group_by(stimulusVerbal) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$meanGPower))))
meanGPStims %>% ungroup() %>%
    filter(stimulusVerbal != "grating") -> dat

m3 <- aov_ez(id = "ID", dv = "meanGPower", within = "stimulusVerbal",
              data = dat)
summary(m3)
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                Sum Sq num Df Error SS den Df F value    Pr(>F)    
## (Intercept)     89061      1    56055     29  46.076 1.882e-07 ***
## stimulusVerbal  24256      7    48400    203  14.534 2.728e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Mauchly Tests for Sphericity
## 
##                Test statistic    p-value
## stimulusVerbal      0.0002407 8.3231e-32
## 
## 
## Greenhouse-Geisser and Huynh-Feldt Corrections
##  for Departure from Sphericity
## 
##                 GG eps Pr(>F[GG])    
## stimulusVerbal 0.33968  1.442e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                   HF eps   Pr(>F[HF])
## stimulusVerbal 0.3720514 5.320935e-07
m3
## Anova Table (Type 3 tests)
## 
## Response: meanGPower
##           Effect          df    MSE         F  ges p.value
## 1 stimulusVerbal 2.38, 68.96 701.90 14.53 *** .188   <.001
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
## 
## Sphericity correction method: GG
emmeans(m3, specs = pairwise~stimulusVerbal, adjust ='none')
## $emmeans
##  stimulusVerbal emmean   SE df lower.CL upper.CL
##  blue             2.25 1.05 29    0.106     4.38
##  green           31.19 5.43 29   20.094    42.29
##  greenblue       15.72 2.53 29   10.557    20.89
##  greenyellow     30.86 5.13 29   20.363    41.36
##  red             30.83 6.15 29   18.242    43.42
##  redblue         17.36 2.53 29   12.177    22.54
##  redyellow       10.46 1.96 29    6.454    14.46
##  yellow          15.44 2.94 29    9.423    21.46
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                estimate   SE df t.ratio p.value
##  blue - green            -28.9475 5.49 29  -5.269  <.0001
##  blue - greenblue        -13.4777 2.46 29  -5.474  <.0001
##  blue - greenyellow      -28.6167 5.40 29  -5.303  <.0001
##  blue - red              -28.5837 6.13 29  -4.661  0.0001
##  blue - redblue          -15.1117 2.57 29  -5.876  <.0001
##  blue - redyellow         -8.2111 1.96 29  -4.195  0.0002
##  blue - yellow           -13.1973 3.29 29  -4.017  0.0004
##  green - greenblue        15.4698 3.27 29   4.725  0.0001
##  green - greenyellow       0.3309 3.80 29   0.087  0.9312
##  green - red               0.3638 2.70 29   0.135  0.8939
##  green - redblue          13.8358 3.81 29   3.632  0.0011
##  green - redyellow        20.7364 4.43 29   4.677  0.0001
##  green - yellow           15.7502 4.91 29   3.206  0.0033
##  greenblue - greenyellow -15.1390 4.07 29  -3.724  0.0008
##  greenblue - red         -15.1060 4.39 29  -3.439  0.0018
##  greenblue - redblue      -1.6340 1.75 29  -0.933  0.3583
##  greenblue - redyellow     5.2666 1.70 29   3.093  0.0043
##  greenblue - yellow        0.2804 3.14 29   0.089  0.9294
##  greenyellow - red         0.0329 4.61 29   0.007  0.9944
##  greenyellow - redblue    13.5050 3.63 29   3.716  0.0009
##  greenyellow - redyellow  20.4056 5.06 29   4.035  0.0004
##  greenyellow - yellow     15.4193 3.18 29   4.849  <.0001
##  red - redblue            13.4720 4.13 29   3.261  0.0028
##  red - redyellow          20.3726 5.42 29   3.756  0.0008
##  red - yellow             15.3864 5.93 29   2.597  0.0146
##  redblue - redyellow       6.9006 2.49 29   2.770  0.0097
##  redblue - yellow          1.9144 2.79 29   0.686  0.4980
##  redyellow - yellow       -4.9862 3.56 29  -1.399  0.1725

Compare gamma power between red and green - Bayes factor

meanGPStims %>% ungroup() %>%
    filter(stimulusVerbal == "red" | stimulusVerbal == "green") %>%
    group_split(stimulusVerbal)-> s

1/ttestBF(s[[1]]$meanGPower, s[[2]]$meanGPower, paired = TRUE, rscale = 1)
## Bayes factor analysis
## --------------
## [1] Null, mu=0 : 7.01814 ±0.01%
## 
## Against denominator:
##   Alternative, r = 1, mu =/= 0 
## ---
## Bayes factor type: BFoneSample, JZS

Check how many peaks were fitted for all stimuli

peaks %>% ungroup() %>%
  group_by(stimType,ID) %>%
  dplyr::summarize(onePeak1Found = paste("Peak1", 
                                         as.character(sum(peak1found)>0)),
                   onePeak2Found = paste("Peak2", 
                                         as.character(sum(peak2found)>0))) -> d
prop.table(table(d$stimType, d$onePeak1Found),1)
##          
##           Peak1 FALSE Peak1 TRUE
##   color    0.03333333 0.96666667
##   grating  0.03333333 0.96666667
infer::prop_test(d, response = onePeak1Found, explanatory = stimType, 
                 success = "Peak1 TRUE")
prop.table(table(d$stimType, d$onePeak2Found),1)
##          
##           Peak2 FALSE Peak2 TRUE
##   color     0.1000000  0.9000000
##   grating   0.8666667  0.1333333
infer::prop_test(d, response = onePeak2Found, explanatory = stimType, 
                 success = "Peak2 TRUE")

Compare the lower gamma peak frequency between stimuli

peaks %>%
    group_by(stimulusVerbal) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$peak1))))
peaks %>% ungroup() %>%
    filter(stimulusVerbal != "grating") -> dat

m4 <- aov_ez(id = "ID", dv = "peak1", within = "stimulusVerbal",
              data = dat)
summary(m4)
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                Sum Sq num Df Error SS den Df  F value    Pr(>F)    
## (Intercept)    113054      1   1894.4      5 298.3851 1.191e-05 ***
## stimulusVerbal    785      7   1374.0     35   2.8559    0.0182 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
m4
## Anova Table (Type 3 tests)
## 
## Response: peak1
##           Effect    df   MSE      F  ges p.value
## 1 stimulusVerbal 7, 35 39.26 2.86 * .194    .018
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
## 
## Sphericity correction method: GG
emmeans(m4, specs = pairwise~stimulusVerbal, adjust ='holm')
## $emmeans
##  stimulusVerbal emmean   SE df lower.CL upper.CL
##  blue             49.3 2.26  5     43.5     55.2
##  green            46.1 2.49  5     39.7     52.5
##  greenblue        44.5 4.94  5     31.8     57.2
##  greenyellow      45.6 2.72  5     38.6     52.6
##  red              48.5 4.07  5     38.0     58.9
##  redblue          47.0 5.36  5     33.2     60.8
##  redyellow        58.4 2.33  5     52.4     64.3
##  yellow           48.9 3.88  5     38.9     58.9
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                estimate   SE df t.ratio p.value
##  blue - green               3.248 3.71  5   0.876  1.0000
##  blue - greenblue           4.843 5.58  5   0.868  1.0000
##  blue - greenyellow         3.780 3.24  5   1.166  1.0000
##  blue - red                 0.874 4.83  5   0.181  1.0000
##  blue - redblue             2.313 5.24  5   0.442  1.0000
##  blue - redyellow          -9.024 2.67  5  -3.379  0.5318
##  blue - yellow              0.424 4.36  5   0.097  1.0000
##  green - greenblue          1.595 2.63  5   0.607  1.0000
##  green - greenyellow        0.532 1.17  5   0.453  1.0000
##  green - red               -2.374 2.10  5  -1.129  1.0000
##  green - redblue           -0.935 3.75  5  -0.250  1.0000
##  green - redyellow        -12.272 3.70  5  -3.313  0.5504
##  green - yellow            -2.824 1.83  5  -1.543  1.0000
##  greenblue - greenyellow   -1.063 2.54  5  -0.418  1.0000
##  greenblue - red           -3.969 1.94  5  -2.045  1.0000
##  greenblue - redblue       -2.530 3.07  5  -0.824  1.0000
##  greenblue - redyellow    -13.867 5.59  5  -2.481  1.0000
##  greenblue - yellow        -4.419 2.23  5  -1.983  1.0000
##  greenyellow - red         -2.906 2.31  5  -1.257  1.0000
##  greenyellow - redblue     -1.467 2.95  5  -0.497  1.0000
##  greenyellow - redyellow  -12.804 3.38  5  -3.790  0.3572
##  greenyellow - yellow      -3.356 1.47  5  -2.277  1.0000
##  red - redblue              1.438 4.29  5   0.336  1.0000
##  red - redyellow           -9.898 4.66  5  -2.126  1.0000
##  red - yellow              -0.450 2.69  5  -0.167  1.0000
##  redblue - redyellow      -11.337 5.74  5  -1.975  1.0000
##  redblue - yellow          -1.889 2.16  5  -0.875  1.0000
##  redyellow - yellow         9.448 4.67  5   2.022  1.0000
## 
## P value adjustment: holm method for 28 tests

Compare the higher gamma peak frequency between stimuli

As the second peak is missing for many participant-stimulus combinations, we’re using a linear mixed-model instead of a RMANOVA here.

peaks %>%
    group_by(stimulusVerbal) %>%
    do(data.frame(rbind(Hmisc::smean.cl.boot(.$peak2))))
peaks %>% ungroup() %>%
    filter(stimulusVerbal != "grating") -> dat

m5 <- lmer(peak2 ~ (1|ID) + stimulusVerbal, data = dat)
anova(m5)
emmeans(m5, specs = pairwise~stimulusVerbal, adjust ='holm')
## $emmeans
##  stimulusVerbal emmean   SE   df lower.CL upper.CL
##  blue             97.4 3.04 94.9     91.3    103.4
##  green            94.2 2.39 94.6     89.5     98.9
##  greenblue        96.1 2.39 94.6     91.4    100.9
##  greenyellow      96.2 2.30 94.3     91.6    100.7
##  red              96.7 2.30 94.4     92.1    101.2
##  redblue          95.2 2.03 92.8     91.1     99.2
##  redyellow        96.3 2.59 94.9     91.1    101.4
##  yellow          102.6 2.48 94.9     97.7    107.5
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                estimate   SE   df t.ratio p.value
##  blue - green              3.1797 3.81 93.0   0.834  1.0000
##  blue - greenblue          1.2634 3.84 94.0   0.329  1.0000
##  blue - greenyellow        1.2301 3.72 91.0   0.331  1.0000
##  blue - red                0.7089 3.72 90.8   0.191  1.0000
##  blue - redblue            2.2165 3.58 92.4   0.619  1.0000
##  blue - redyellow          1.1200 3.96 93.8   0.283  1.0000
##  blue - yellow            -5.1986 3.84 91.4  -1.352  1.0000
##  green - greenblue        -1.9164 3.23 82.3  -0.593  1.0000
##  green - greenyellow      -1.9497 3.13 76.9  -0.623  1.0000
##  green - red              -2.4708 3.13 77.1  -0.789  1.0000
##  green - redblue          -0.9632 2.98 79.8  -0.323  1.0000
##  green - redyellow        -2.0597 3.36 80.7  -0.612  1.0000
##  green - yellow           -8.3783 3.31 83.2  -2.531  0.3712
##  greenblue - greenyellow  -0.0333 3.19 84.3  -0.010  1.0000
##  greenblue - red          -0.5544 3.18 82.9  -0.174  1.0000
##  greenblue - redblue       0.9532 3.01 83.5   0.317  1.0000
##  greenblue - redyellow    -0.1434 3.40 85.0  -0.042  1.0000
##  greenblue - yellow       -6.4619 3.32 84.5  -1.944  1.0000
##  greenyellow - red        -0.5211 3.08 77.8  -0.169  1.0000
##  greenyellow - redblue     0.9865 2.90 77.5   0.340  1.0000
##  greenyellow - redyellow  -0.1101 3.33 83.3  -0.033  1.0000
##  greenyellow - yellow     -6.4286 3.26 83.8  -1.973  1.0000
##  red - redblue             1.5076 2.91 79.0   0.518  1.0000
##  red - redyellow           0.4110 3.35 85.0   0.123  1.0000
##  red - yellow             -5.9075 3.26 83.6  -1.814  1.0000
##  redblue - redyellow      -1.0966 3.16 83.2  -0.346  1.0000
##  redblue - yellow         -7.4151 3.09 84.7  -2.400  0.5017
##  redyellow - yellow       -6.3185 3.44 81.6  -1.838  1.0000
## 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: holm method for 28 tests

Methods

Number of excluded trials

nanCounts <- data %>% 
    group_by(ID) %>%
    dplyr::summarize(non_na_count = sum(!is.na(gammapower)))
sprintf('Gamma power reported in %.0f%% of trials.', 
        100*(mean(nanCounts$non_na_count)/540))
## [1] "Gamma power reported in 81% of trials."