function [ExistFilePathMat,NFilesExist,NotExistFilePathMat,NFilesNotExist]=AllCon;
%   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.                                                                      
%---------------------------------------------------------------
% user variables defined here 
%---------------------------------------------------------------
global SubVec
if isempty(SubVec)
   SubVec=[1:3,5:9,11:21]
end

ActPath=pwd
Con=str2num(ActPath(length(ActPath)-1:length(ActPath)))
Tmp=findstr(ActPath,FileSep);
StatStr=ActPath(Tmp(length(Tmp)-1)+6:Tmp(length(Tmp))-1)
FlipStr=ActPath(Tmp(length(Tmp))+1:Tmp(length(Tmp))+4)
NSub=length(SubVec);
if Con>9
   if strcmp(FlipStr,'Mean')
      ConStr=['m0',int2str(Con)];
   else
      ConStr=['00',int2str(Con)];
   end
   FlipConStr=['f0',int2str(Con)];
else
   if strcmp(FlipStr,'Mean')
      ConStr=['m00',int2str(Con)];
   else
      ConStr=['000',int2str(Con)];
   end
   FlipConStr=['f00',int2str(Con)];
end
NFilesExist=0;
NFilesNotExist=0;
ExistFilePathMat=[];
NotExistFilePathMat=[];
for SubInd=1:NSub
   ActSub=SubVec(SubInd);
   ActSubStr=int2str(ActSub);
	if ActSub<10
   	ActSubStr=['0',ActSubStr];
	end
   BasePath=['E:\fMRIData\fMRIDataGV\',ActSubStr,'\snraS',ActSubStr,StatStr,'\'];
   File=['spmF_',ConStr,'.img'];
	if ActSub==1
      if strcmp(StatStr,'Para')
         ConTmp=Con
         if Con>9
   			if strcmp(FlipStr,'Mean')
      			ConStrTmp=['m0',int2str(ConTmp)];
   			else
      			ConStrTmp=['00',int2str(ConTmp)];
   			end
			else
   			if strcmp(FlipStr,'Mean')
     			 	ConStrTmp=['m00',int2str(ConTmp)];
   			else
      			ConStrTmp=['000',int2str(ConTmp)];
  				end
			end
         File=['spmF_',ConStrTmp,'.img'];
      end      
   end
   if ActSub==14
      if strcmp(StatStr,'Para')
         if Con>18
            ConTmp=Con+1
         else
            ConTmp=Con
         end
         if ConTmp>9
				ConStrTmp=['00',int2str(ConTmp)];
			else
   			ConStrTmp=['000',int2str(ConTmp)];
         end
         File=['spmF_',ConStrTmp,'.img'];
      end      
   end
   if ActSub==17
      if strcmp(StatStr,'Para')
         if Con>18
            ConTmp=Con+2
         else
            ConTmp=Con
         end
         if ConTmp>9
				ConStrTmp=['00',int2str(ConTmp)];
			else
   			ConStrTmp=['000',int2str(ConTmp)];
         end
         File=['spmF_',ConStrTmp,'.img'];
      end      
  	end
	FilePath=[BasePath,File];
   FileExist=exist(FilePath,'file');
   if FileExist==2
      NFilesExist=NFilesExist+1;
   	if NFilesExist==1
      	ExistFilePathMat=char(FilePath);
   	else
     	 	ExistFilePathMat=char(ExistFilePathMat,FilePath);
      end
   else
   	NFilesNotExist=NFilesNotExist+1;
   	if NFilesNotExist==1
      	NotExistFilePathMat=char(FilePath);
   	else
     	 	NotExistFilePathMat=char(NotExistFilePathMat,FilePath);
      end   
   end
   if strcmp(FlipStr,'Flip')
      BasePath=['E:\fMRIData\fMRIDataGV\',ActSubStr,'\snraS',ActSubStr,StatStr,'\'];
  	 	File=['spmF_',FlipConStr,'.img'];
		if ActSub==1
      	if strcmp(StatStr,'Para')
         	ConTmp=Con-2
         	if ConTmp>9
					FlipConStrTmp=['f0',int2str(ConTmp)];
				else
   				FlipConStrTmp=['f00',int2str(ConTmp)];
         	end
         	File=['con_',FlipConStrTmp,'.img'];
      	end      
  		end
   	FilePath=[BasePath,File];
   	FileExist=exist(FilePath,'file');
   	if FileExist==2
      	NFilesExist=NFilesExist+1;
   		if NFilesExist==1
      		ExistFilePathMat=char(FilePath);
   		else
     	 		ExistFilePathMat=char(ExistFilePathMat,FilePath);
    	  end
  	 	else
   		NFilesNotExist=NFilesNotExist+1;
   		if NFilesNotExist==1
      		NotExistFilePathMat=char(FilePath);
   		else
     	 		NotExistFilePathMat=char(NotExistFilePathMat,FilePath);
     	 	end   
   	end      
   end
end
fprintf(1,'%g existing files chosen:\n\n',NFilesExist)
disp(ExistFilePathMat)
fprintf(1,'\n\n')
fprintf(1,'%g not existing files chosen:\n\n',NFilesNotExist)
disp(NotExistFilePathMat)