[Eeglablist] Fix for wrong reference channel location

Arnaud Delorme arno at ucsd.edu
Fri Feb 22 10:27:49 PST 2019


Dear Ryan and others,

Yes, the MNI coordinates in EEGLAB are rotated by 90 degrees when you use the MNI template electrode location file. This is because the convention in EEGLAB is to use the +X axis as the direction for the nose. Historically this did not use to be the case.. The nose direction was not fixed. But the issue is that all functions plotting channels had to know about the nose direction which was not convenient or user friendly. When you use the MNI montage for your electrode locations (look up electrode positions based on labels), it is rotated automatically by 90 degree so nose direction is along +X. 

However, this is only for 2-D plotting of electrode. Whenever you plot in 3-D (headplot) or use source localization (dipfit), your electrode location are coregistered with the model (so rotated back to MNI space if you do source localization in the MNI space). This is even done automatically in EEGLAB: When you use your montage for source localization with the MNI brain, it is rotated back to its original MNI space.

So the constraint of using +X as the nose dimension only apply to 2-D plots. I would not rotate back the electrodes to MNI space in EEGLAB as Ryan suggest, because then the scalp topographies will be wrong (as they assume nose in the +X direction).

Best wishes,

Arno

> On Feb 18, 2019, at 11:31 AM, Downey, Ryan J <RDowney at bme.ufl.edu> wrote:
> 
> This fix is in response to the post by Li Xiang (https://sccn.ucsd.edu/pipermail/eeglablist/2015/010584.html), titled “Wrong channel location with MNI brain model.” I’ve been meaning to share this for a while. Sorry for the delay. Please let me know if there is a better way to respond specifically to old posts rather than creating a new thread.
>  
> Issue: Let’s assume 10-5 electrode naming conventions. If you take raw data, use pop_chanedit to append your reference channel as a “nodatchan”, then “look up locs” with MNI, and and finally close pop_chanedit, then your original reference channel will have the wrong location. 
>  
> Cause: the MNI brain is defined with the nose along +Y and in EEGLAB a rotation is applied to data channel locations to align the nose to +X; however, this same rotation isn’t applied to “nodatchan” entries (i.e. the reference channel you appended). If you click “plot 3-D (xyz)” immediately after “look up locs”, you’ll see that the reference channel appears in what seems like the correct location, but note that even though the reference is correct with respect to the locations of all the normal EEG channels, everything is temporarily aligned with nose set to +Y. When you click “ok” to close pop_chanedit, then the function eeg_checkset gets called. Eeg_checkset notices your channels aren’t aligned how it prefers (line 1078), and it rotates the chanloc information (lines 1086-1098). In the 2015 post by Li Xiang, the thought was that it was related to adding the reference channel back to the data after average referencing, but with my own tests I can see the reference channel location info is wrong before reaching the re-referencing step.
>  
> Fix: add the following code immediately after line 1098 (i.e. after the for loop that goe through all EEG.chanlocs and rotates the location info). The code below is essentially a copy-paste of 1086-1098 but modified for EEG.nodatchans (where your reference location is stored initially).
>  
> %%%%%%%%%%%%%%%%%%%
> for index = 1:length(EEG.chaninfo.nodatchans)
>     if ~isempty(EEG.chaninfo.nodatchans(index).theta)
>         rotategrad = rotate/180*pi;
>         coord = (EEG.chaninfo.nodatchans(index).Y + EEG.chaninfo.nodatchans(index).X*sqrt(-1))*exp(sqrt(-1)*-rotategrad);
>         EEG.chaninfo.nodatchans(index).Y = real(coord);
>         EEG.chaninfo.nodatchans(index).X = imag(coord);
>         EEG.chaninfo.nodatchans(index).theta     = EEG.chaninfo.nodatchans(index).theta    -rotate;
>         EEG.chaninfo.nodatchans(index).sph_theta = EEG.chaninfo.nodatchans(index).sph_theta+rotate;
>         if EEG.chaninfo.nodatchans(index).theta    <-180, EEG.chaninfo.nodatchans(index).theta    =EEG.chaninfo.nodatchans(index).theta    +360; end;
>         if EEG.chaninfo.nodatchans(index).sph_theta>180 , EEG.chaninfo.nodatchans(index).sph_theta=EEG.chaninfo.nodatchans(index).sph_theta-360; end;
>     end;
> end;
> %%%%%%%%%%%%%%%%%%%
>  
>  
> Sincerely,
>  
> Ryan J. Downey
> Postdoctoral Associate
> Human Neuromechanics Laboratory
> University of Florida
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu



More information about the eeglablist mailing list