Home > vbmeg > functions > leadfield > eeg > vb_map_eeg_to_head.m

vb_map_eeg_to_head

PURPOSE ^

EEG positions are mapped to outermost head surface

SYNOPSIS ^

function [Xout, IX, DD] = vb_map_eeg_to_head(X,Vs,BEM,dx,Np)

DESCRIPTION ^

 EEG positions are mapped to outermost head surface
   [Xout, IX, DD] = vb_map_eeg_to_head(X,Vs,BEM,dx,Np)
 X    : sensor coordinate (センサー座標)             [Neeg x 3]
 Vs   : vertex coordinate on the boudary surface (境界面座標) [Nv x 3]
 BEM.Nvertex   = start & end vertex index for n-th closed surface
               = [ start_id(1)     end_id(1)     ; 
                             ...                 ;
                   start_id(Nsurf) end_id(Nsurf) ]
                   innermost to outermost 
               = 各境界面の頂点インデックス
               = [開始インデックス, 終了インデックス]
 dx   : neighbor points are searched within dx (m) from nearest point
 Np   : Np points are searched for each sensor position
 
 IX   : Vertex index nearest to EEG sensor [Neeg x Np]
 DD   : Distance from EEG sensor to head vertex [Neeg x Np]
 Xout : Nearest head vertex point to EEG sensor;
 2007-12-25  M. Sato 

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    [Xout, IX, DD] = vb_map_eeg_to_head(X,Vs,BEM,dx,Np)
0002 % EEG positions are mapped to outermost head surface
0003 %   [Xout, IX, DD] = vb_map_eeg_to_head(X,Vs,BEM,dx,Np)
0004 % X    : sensor coordinate (センサー座標)             [Neeg x 3]
0005 % Vs   : vertex coordinate on the boudary surface (境界面座標) [Nv x 3]
0006 % BEM.Nvertex   = start & end vertex index for n-th closed surface
0007 %               = [ start_id(1)     end_id(1)     ;
0008 %                             ...                 ;
0009 %                   start_id(Nsurf) end_id(Nsurf) ]
0010 %                   innermost to outermost
0011 %               = 各境界面の頂点インデックス
0012 %               = [開始インデックス, 終了インデックス]
0013 % dx   : neighbor points are searched within dx (m) from nearest point
0014 % Np   : Np points are searched for each sensor position
0015 %
0016 % IX   : Vertex index nearest to EEG sensor [Neeg x Np]
0017 % DD   : Distance from EEG sensor to head vertex [Neeg x Np]
0018 % Xout : Nearest head vertex point to EEG sensor;
0019 % 2007-12-25  M. Sato
0020 %
0021 % Copyright (C) 2011, ATR All Rights Reserved.
0022 % License : New BSD License(see VBMEG_LICENSE.txt)
0023 
0024 DEBUG = 0;
0025 Rmax  = 1000;
0026 
0027 if ~exist('dx','var'), dx = 0.02; end; % 20 mm
0028 if ~exist('Np','var'), Np = 3; end;
0029 
0030 %  変数の次元
0031 Neeg = size(X,1);    % # of EEG sensor
0032 IX = zeros(Neeg,Np);
0033 DD = repmat(Rmax,[Neeg,Np]);
0034 
0035 % Find outermost head vertex near EEG position
0036 
0037 % Vertex index for outermost surface
0038 Nsurf    = size(BEM.Nvertex,1);    % 境界面の数
0039 ix_head = BEM.Nvertex(Nsurf,1):BEM.Nvertex(Nsurf,2);
0040 
0041 % Vertex for outermost surface
0042 V = Vs(ix_head,:);
0043 
0044 if DEBUG==1, V = Vs; end;
0045 
0046 for n=1:Neeg
0047     % センサに最も近い境界面頂点探索
0048     dd = sqrt((V(:,1)-X(n,1)).^2 + (V(:,2)-X(n,2)).^2 + (V(:,3)-X(n,3)).^2);
0049     dmin = min(dd);
0050     
0051     ix = find( dd <= (dmin + dx));
0052     Nx = length(ix);
0053     [d, jx] = sort(dd(ix));
0054     
0055     if Nx > Np, 
0056         jx = jx(1:Np); 
0057         IX(n,:) = ix_head(ix(jx));
0058         DD(n,:) = d(1:Np)';
0059     else
0060         IX(n,1:Nx) = ix_head(ix(jx));
0061         DD(n,1:Nx) = d';
0062     end;
0063     
0064 end
0065 
0066 Xout = Vs(IX(:,1),:);

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005