% ts1_smooth.m


% 
% SMOOTHING
%

global dataroot spm_path subject_ids proc_subs sinfo

nsub = length(subject_ids);
nsub_proc = length(proc_subs);

subj_nsess = length(sinfo(1).cond_order);

% for resliced EPI (individual) : smooth(1)

smooth = struct(...
'FWHMmm', [6 6 8], ...
'files', {{''}} ...
    );
tmp = '';
subtmp = '';

for isub = 1:nsub_proc
  curr_sub_idx = proc_subs(isub);
  
   for isess = 1:subj_nsess
      tmp{isess} = spm_get('Files', ... 
	sprintf('%s%s/epi/run%d/', dataroot, char(subject_ids(curr_sub_idx)), isess), ...
	sprintf('r%s*.img', char(subject_ids(curr_sub_idx))));
  end 
  subtmp{isub} =  char(tmp);
end  % for isub=  

smooth(1).files = char(subtmp);

% for normalized EPI : smooth(2)

smooth(2)=smooth(1);
smooth(2).FWHMmm = [6 6 8];
tmp = '';
subtmp = '';

for isub = 1:nsub_proc
  curr_sub_idx = proc_subs(isub);
  for isess = 1:subj_nsess
    tmp{isess} = spm_get('Files', ... 
	sprintf('%s%s/epi/run%d/', dataroot, char(subject_ids(curr_sub_idx)), isess), ...
	sprintf('n%s*.img', char(subject_ids(curr_sub_idx))));
  end 
  subtmp{isub} =  char(tmp);
end  % for isub=  

smooth(2).files = char(subtmp);


disp('finished reading ts1_smooth')

