%   BAT.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 SubVec MaskStr

%---------------------------------------------------------------
%---------------------------------------------------------------
Con=2
                                                                      
StatStr='HiOff'	%'LoHi72'	%'HiOff'	%'LoHi'	%Para
NSub=length(SubVec);
if Con>9
   ConStr1=['00',int2str(Con)];
   ConStr2=['f0',int2str(Con)];
else
   ConStr1=['000',int2str(Con)];
   ConStr2=['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=['con_',ConStr1,'.img'];
   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
   File=['con_',ConStr2,'.img'];
   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
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)

F1=ExistFilePathMat;

%---------------------------------------------------------------
% batch variables defined here for analysis 'model'
%---------------------------------------------------------------

model(1) = struct( ...
 'types',          4, ...
 'global_effects', {'Scaling'}, ...
 'burst_mode',     0, ...
 'HF_fil',         'none',  ...
 'HF_cut',         'none', ...
 'LF_fil',         'none', ...
 'LF_cut',         0, ...
 'int_corr',       'none', ... 
 'now_later',      1, ...
 'stop_writing',   0, ...
 'trial_fcon',     0, ...
 'RT',             3, ...
 'replicated',     1, ...
 'same_time_param',1, ...
 'nsess',          1, ...
 'nscans',         [20], ...
 'files',          {{F1}}, ...
 'conditions_nb',  1, ...     
 'conditions',     1, ...
 'regressors_nb',  0, ...
 'regressors',     [], ...
 'parametrics_type', {{'none'}}, ...
 'parametrics',    [], ...
 'stochastics_flag',0, ...
 'stochastics',    []);


%-------------------------------------------
conditions(1) = struct( ...
 'names',   {{'High'}}, ...
 'onsets',{{[0:2:20]}}, ...   
 'types',    {{'epochs'}}, ... 
 'bf_ep',   [1], ...
 'volterra',  0, ...
 'variable_dur',0);

%-------------------------------------------

bf_ep(1) = struct( ...
  'ep_type', 3, ...
  'length',2, ...
  'conv',  0, ...  
  'deriv', 0);

%---------------------------------------------------------------
% batch variables defined here for analysis 'contrasts'
%---------------------------------------------------------------
c1=[1 0];

contrasts(1) = struct( ...
  'names',  {{'High'}}, ...
  'types',   {{'T'}}, ...
  'values',  {{c1}});