%   Con2Block.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. 


ResultPath=pwd
[NCondFiles,CondFileMat]=ReadFileNames([],'*.con*','Choose the condition file(s):');
for FileInd=1:NCondFiles
    [CondFile,CondPath,CondFilePath]=GetFileNameOfMat(CondFileMat,FileInd);
    [CondVec] = ReadData(CondFilePath,1,[],'ascii','ascii');
                                                                     
    NCondVec=length(CondVec)
    if round(NCondVec./2)~=NCondVec/2
        CondVec=CondVec(1:NCondVec-1);
        NCondVec=NCondVec-1;
    end
    CondVec=CondVec+1;
    Ind=find(CondVec(NCondVec/2+1:NCondVec)==1);
    CondVec(NCondVec/2+Ind)=3.*ones(size(Ind));
    Ind=find(CondVec(NCondVec/2+1:NCondVec)==2);
    CondVec(NCondVec/2+Ind)=4.*ones(size(Ind));
    SaveData(CondVec,[ResultPath,CondFile],1,[],'ascii','ascii',[],[],[],1,1,0);
end
    
