Blog

EEGlab: Gracefully overwrite the default colormap

EEGlab has ‘jet’ as the default colormap. But jet is pretty terrible   You see structure where there is none (e.g. rings in the third example).   The problem: Eeglabs sets the default colormap to ‘jet’, thus overwriting a system wide default set e.g. by “` set(0,’DefaultFigureColormap’,parula); “` It does so by calling “`icadefs.m “` in various functions (e.g. topoplot, erpimage) and defining: “` DEFAULT_COLORMAP = ‘jet’ “` We want to overwrite the one line, but keep it forward compatible i.e. we do not want to copy the whole icadefs file, but just replace the single line whenever icadefs is…

Simple Filter Generation

I sometimes explain concepts to my students. Then I forget the code and the next time round, I have to redo it. Take this post as an extended memory-post. In this case I showed what filter-ringing artefacts could look like. This is especially important for EEG preprocessing where filtering is a standard procedure. A good introduction to filtering can be found in this slides by andreas widmann or this paper by andreas widmann Impulse with noise I simulated as simple impulse response with some additional noise. The idea is to show the student that big spikes in the EEG-data could result…

Logistic Regression: Will it rain in Osnabrück tomorrow?

TLDR; 52% of days it rained (Precipitation>0) Is it sunny? 2x as likely that it is sunny tomorrow as well. Is it rainy? 2.3x as likely that it is rainy tomorrow as well Predicting rainfall using logistic regression I’m playing around with some analyses for an upcoming course. This follows loosely the example of “Advanced Data Analysis from an Elemental Point of View” Chapter 12.7 It is a somewhat naive analysis. Further improvements are discussed at the end. library(ggplot2) library(plyr) We load the data and change some of the German variables # I downloaded the data from here: # http://www.dwd.de/DE/leistungen/klimadatendeutschland/klimadatendeutschland.html…

How to use bimodal priors for bayesian data analysis in STAN

I tried adding a bi-modal prior in STAN for a homework exercise on Bayesian Data Analysis. At first, I thought this could work: “`STAN model{ mu ~ normal(-0.5,0.3) + normal(0.5,0.3); } “` But it doesn’t. I had to dig deeper and I thought I could simply add multiple times to the log-posterior due to a sideremark of Bob Carpenter: “`STAN target += normal_lpdf(mu|.5,0.3); target += normal_lpdf(mu|-.5,0.3); “` Which also does not work. Finally, the solution is akin to the mixture model in the STAN manual: “`STAN target += log_sum_exp(normal_lpdf(mu|.5,0.3),normal_lpdf(mu|-.5,0.3)); “` This results in beautiful bi-modal priors: I did not find…

Scatterplots, regression lines and the first principal component

I made some graphs that show the relation between X1~X2 (X2 predicts X1), X2~X1 (X1 predicts X2) and the first principal component (direction with highest variance, also called total least squares). The line you fit with a principal component is not the same line as in a regression (either predicting X2 by X1 [X2~X1] or X1 by X2 [X1~X2]. This is quite well known (see references below). With regression one predicts X2 based on X1 (X2~X1 in R-Formula writing) or vice versa. With principal component (or total least squares) one tries to quantify the relation between the two. To completely…

EEG: Contours in multiple topoplots

The problem It is commonly accepted that axes of plots should align if data needs to be compared between subplots. But the default way on how multiple topoplots are plotted violates this principle. While usually the limits of the colormap are kept constant for all colormaps, the contours rarely are. This default plot looks similar to this one: The solution It is simple, keep the contours constant! In eeglab this is done using the topoplot function with the argument ‘numcontours’, linspace(-scale,scale,n_contours) or similar. You can also use my new plotting script available here on github So if we would keep…

Multitaper Time vs Frequency Resolution

Goal Give a graphical representation of multitaper time frequency parameters. Background Frequency Resolution and sFFT In M/EEG analysis we are often interested in oscillations. One tool to analyse oscillations is by using time-frequency methods. In principle they work by segmenting the signal of interest in small windows and calculating a spectrum for each window. A tutorial can be found on the fieldtrip page. There exists a time-frequency tradeof: $\delta f = \frac{1}{T}$ with T the timewindow (in s) and $\delta f$ the frequency resolution. The percentage-difference of two neighbouring frequency resolution gets smaller the higher the frequency goes, e.g. a…

Latency Measurements in a Vision Lab

We recently moved to a new building and the labs moved with us. We did not only use this opportunity to get rid of old computers and monitors, but also to thoroughly check that our timing is correct. This work was mostly done by Ule Diallo, an intern from Marburg University. We were very lucky to have him! TLDR; We searched for fixed and jittered delays in our setup. We measured many monitors with two luminance sensors. We also checked our parallel-ports trigger-timing. We did not find jittered delays, the fixed delays are, as expected, only by the monitors. Why…

Jiameng Wu: The influence of Saliency on the Initation of Saccades in a Guided Viewing Paradigm with Bubble-Stimuli

One of my bachelor’s students (Jiameng Wu) finished her thesis on parts of this project. I again tried to make art out of science. In this piece I used three of her features on different scales and calculated them for each page of her thesis. I then recombined and arranged them. In eye-tracking these image features are commonly used to analyse where people look (high contrast regions and the like). In this case we find surpringly emerging global structures (I mean the guy with a tophat in row 2 or the cat in row 3) . The idea is to…

ICA weights and invweights

Update 01.08.2016 after further discussion we discovered that the correlation matrix was a bit off. This is because I plotted the correlation of the weights without the sphering (=whitening) step. Sphering removes the correlation between the components. I added a plot with the correlation after sphering and updated the topographies. Goal In EEG blind source separation using ICA, understand the difference between the mixing matrix and the unmixing matrix. brief introduction The blind source separation problem in the context of EEG can be understood as follows: $$ mixing * sourceactivity = EEGdata $$ In words: We have some sources active…

5 of 6
123456