Home > vbmeg > functions > common > coordinate > vb_distance_to_neigbor.m

vb_distance_to_neigbor

PURPOSE ^

find NP neighbor points for each sensor position

SYNOPSIS ^

function [IX, DD] = vb_distance_to_neigbor(X,Y,Np)

DESCRIPTION ^

 find NP neighbor points for each sensor position
   [Xout, IX, DD] = vb_map_eeg_to_head(X,Y,BEM,dx,Np)
 X    : sensor coordinate            [NX x 3]
 Y    : vertex coordinate for search [NY x 3]
 Np   : Np points are searched for each sensor position
 
 DD   : Distance from X(n,:) to neighbor vertex [NX x Np]
 IX   : Neighbor vertex index of Y for X(n,:)   [NX x Np]

 2010-3-2  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    [IX, DD] = vb_distance_to_neigbor(X,Y,Np)
0002 % find NP neighbor points for each sensor position
0003 %   [Xout, IX, DD] = vb_map_eeg_to_head(X,Y,BEM,dx,Np)
0004 % X    : sensor coordinate            [NX x 3]
0005 % Y    : vertex coordinate for search [NY x 3]
0006 % Np   : Np points are searched for each sensor position
0007 %
0008 % DD   : Distance from X(n,:) to neighbor vertex [NX x Np]
0009 % IX   : Neighbor vertex index of Y for X(n,:)   [NX x Np]
0010 %
0011 % 2010-3-2  M. Sato
0012 %
0013 % Copyright (C) 2011, ATR All Rights Reserved.
0014 % License : New BSD License(see VBMEG_LICENSE.txt)
0015 
0016 if ~exist('Np','var'), Np = 3; end;
0017 
0018 %  Dimension
0019 NX = size(X,1);    % # of EEG sensor
0020 IX = zeros(NX,Np);
0021 DD = zeros(NX,Np);
0022 
0023 for n=1:NX
0024     % Distance from X(n,:)
0025     dd = (Y(:,1)-X(n,1)).^2 + (Y(:,2)-X(n,2)).^2 + (Y(:,3)-X(n,3)).^2;
0026     
0027     % neighbor search
0028     [d, jx] = sort(dd);
0029     IX(n,:) = jx(1:Np)'; 
0030     DD(n,:) = sqrt(d(1:Np))';
0031     
0032 end
0033

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