%A script designed to:

%1)convert ROIs from Talairach space to MNI space
%2)smooth the ROI
%3)truncate the ROI

%Sue Whitfield 



files = roi_list; 

outfiles = tal2mnigui(files);

imgs = mm2img(outfiles);  %create new analyze ROI image
p = spm_input('smoothing {FWHM in mm}',1);

cdir = pwd;
for i=1:size(imgs,1)
    [filepath, name, ext] = fileparts(imgs(i,:));
    s_imgs{i,1} = fullfile(filepath,['s' name ext]);
    [s_path, s_name] = fileparts(s_imgs{i,1});
    cd(s_path);
    spm_smooth(deblank(imgs(i,:)),strcat(s_name, ext),p);
end
cd(cdir);

%right now, we only show the first selected ROI... but that will change.
spm_image('init',s_imgs{1,1});

ts_imgs = roi_truncate(char(s_imgs));

disp('\n\n%%%%%%%%%%%%%%%%%%%%\nROI Processing finished!\n%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n');
 
%display_rois;
 
 
 
  
  