Electrode proximity/distance

Post Reply
zenBen
Posts: 3
Joined: Mon May 06, 2013 12:39 pm

Electrode proximity/distance

Post by zenBen »

Hello,

is there a handy index available to read out the distances between electrodes in the Biosemi caps? For instance, I have data from the Biosemi 128 cap, with A1-32, B1-32, C1-32, D1-32 electrodes. If I want to define a region of interest in Matlab, I must select specific sets of electrodes because labels which are adjacent in number are often NOT adjacent in topography and vice versa, e.g. A8-12 is adjacent to D29-32. A1 is adjacent to A2, B1, C1, D1 and D15. And it can be quite arbitrary to decide what is adjacent and what not, a better solution would be to just define a radius within which all electrodes are included.
Thus it would be really handy to have a table giving the distance between every pair of electrodes, so that one could iterate through all electrodes and for each one, easily pick all adjacent electrodes, or electrodes within X mm, etc.

Any body have any promising leads?

zenBen
Posts: 3
Joined: Mon May 06, 2013 12:39 pm

Re: Electrode proximity/distance

Post by zenBen »

Addendum: of course I would also be happy to see a method for calculating the proximity table myself based on spherical or XYZ coordinates.

zenBen
Posts: 3
Joined: Mon May 06, 2013 12:39 pm

Re: Electrode proximity/distance

Post by zenBen »

Hmm, not sure if this is a *good* solution, but once I thought of it the rest was easy so here it is:

function [epmap rownm colnm] = electrodeProximity( EEG )
%% Calculates the Euclidean distances between all pairs of electrodes given
%
% Note: The function disregards "non-EEG" channels. These are taken as specified
% in the channel location structure/file (anything not labeled EEG or
% "empty" is considered non-EEG). It is highly recommended that you define
% a channel type for each channel, when you define your channel location file.
%
% Syntax:
% epmap = electrodeProximity( EEG )
%
% Parameters
% EEG

eegChan = strcmp('EEG',{EEG.chanlocs.type}) | strcmp('',{EEG.chanlocs.type});
eegchs = sum(eegChan);
epmap = zeros(eegchs);
rownm = cell(eegchs,1);
colnm = cell(1,eegchs);

for i = 1:eegchs
rownm(i) = EEG.chanlocs(i).labels;
for k = i+1:eegchs
A = [EEG.chanlocs(i).X; EEG.chanlocs(i).Y; EEG.chanlocs(i).Z];
B = [EEG.chanlocs(k).X; EEG.chanlocs(k).Y; EEG.chanlocs(k).Z];

epmap(i,k) = eucl_dist(A, B);

if i == 1, colnm(k) = EEG.chanlocs(k).labels; end
end
end
end

function d = eucl_dist(a,b)
aa=sum(a.*a,1); bb=sum(b.*b,1); ab=a'*b;
d = sqrt(abs(repmat(aa',[1 size(bb,2)]) + repmat(bb,[size(aa,2) 1]) - 2*ab));

Post Reply