3

Can I use ggplot to create a topoplot of regression results from some EEG data?

Essentially I want to do something like this: topoplot in ggplot2 – 2D visualisation of e.g. EEG data while my data is not voltage but results (e.g., coefficients, t-values, Bayes factors, etc) from regression.

I managed to replicate that example where the voltages are plotted. In my attempt, I had a list of Bayes factors from each electrode at a certain time slice. However, I wasn't able to adapt the code in that post to mine. Here is a section of my data:

Example data

This is what I did after importing the data:

R code

Following the code, my predicted values would become the same for all electrodes, or a gradient.

Failed example from one time slice

I got this only after I executed this section of the ggplot command:

ggplot(datmat2, aes(x, y, z = value)) +
    geom_tile(aes(fill = value)) +
    stat_contour(aes(fill = ..level..), geom = 'polygon', binwidth = 0.01) +
    geom_contour(colour = 'white', alpha = 0.5) +
    scale_fill_distiller(palette = "Spectral", na.value = NA) + 
    geom_path(data = circledat, aes(x, y, z = NULL))

If I went on with the rest, the graph turned to this: enter image description here

I think the problem occurred when I did the interpolation. Or, it could be because the co-ordinates of the electrodes were different. I'm really a novice with how topoplot and interpolation works, so please bear with me if I've made a dumb mistake.

Any help would be greatly appreciated!

Pennie
  • 131
  • 4

0 Answers0