%   FindMinNormSymDipInd.m

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.  

global ScalpLeadLocCart
ScalpLeadLocCart=ReadAscii;

ROIIndVecFR=[]
ROIIndVecFL=[]





TmpVec=[]
NoVec=[]
ROIIndVec1=find(ScalpLeadLocCart(:,1)>0 & ScalpLeadLocCart(:,2)>0)';

ROIIndVec1=find(ScalpLeadLocCart(:,1)>0)
ScalpLeadLocCartTmp=ScalpLeadLocCart;
ScalpLeadLocCartTmp(:,1)=-ScalpLeadLocCartTmp(:,1);
l=0;
k=0;
m=0;
for i=1:length(ROIIndVec1)
    x=ScalpLeadLocCart(ROIIndVec1(i),:);
    j=0;
    ok=0;
    while j<196 %655
        j=j+1;
        y=ScalpLeadLocCartTmp(j,:);
        a=sum(abs(x-y));
        if a==0
            k=k+1;
            ROIIndVec2(k)=j;
            ok=1;
        end
    end
    if ok
        l=l+1;
        TmpVec(l)=i;
    else
        m=m+1;
        NoVec(m)=i;
    end
end
ROIIndVec2=ROIIndVec2';

ROIIndVec1
ROIIndVec1(TmpVec)
ROIIndVec2
ROIIndMat=zeros(length(ROIIndVec1),2)
ROIIndMat(:,1)=ROIIndVec1
ROIIndMat(:,2)=ROIIndVec2

return

ROIIndVecBR=[]
ROIIndVecBL=[]
TmpVec=[]
NoVec=[]
ROIIndVecBR=find(ScalpLeadLocCart(:,1)>0 & ScalpLeadLocCart(:,2)<0)';
ScalpLeadLocCartTmp=ScalpLeadLocCart;
ScalpLeadLocCartTmp(:,1)=-ScalpLeadLocCartTmp(:,1);
l=0;
k=0;
m=0;
for i=1:length(ROIIndVecBR)
    x=ScalpLeadLocCart(ROIIndVecBR(i),:);
    j=0;
    ok=0;
    while j<655
        j=j+1;
        y=ScalpLeadLocCartTmp(j,:);
        a=sum(abs(x-y));
        if a==0
            k=k+1;
            ROIIndVecBL(k)=j;
            ok=1;
        end
    end
    if ok
        l=l+1;
        TmpVec(l)=i;
    else
        m=m+1;
        NoVec(m)=i;
    end
end
ROIIndVecBR
ROIIndVecBR(TmpVec)
ROIIndVecBL