function spm_roi_plot(infile)
% reads in text output from spm_roi_compute and plots data
%


% load in the data

[data,sess,cond,tp,comments]=spm_roi_read_datfile(infile);

% create plots

Fgraph = spm_figure('FindWin','Graphics');
if isempty(Fgraph),
  Fgraph=spm_figure;
end;
figure(Fgraph);

% figure out which sessions are included
sess_idx=zeros(1,100);
for x=1:size(sess,2),
  sess_idx(sess(x))=1;
end;
sess_idx=find(sess_idx>0);


plot_ctr=1;
for s=sess_idx,
  subplot(round(size(sess_idx,2)/2),2,plot_ctr);
  sess_data=data(find(sess==s),:);
  sess_cond=cond(find(sess==s));
  plot(tp,sess_data');
  plot_ctr=plot_ctr+1;
  legend_cmd='legend(sess_cond{1}';
  % create legend on the fly from cond labels
  for c=2:size(sess_cond,2),
    legend_cmd=sprintf('%s,sess_cond{%d}',legend_cmd,c);
  end;
  legend_cmd=sprintf('%s)',legend_cmd);
  eval(legend_cmd);
  title(sprintf('Session %d',s));
end;
subplot(round(size(sess_idx,2)/2),2,2);
% kludge  - add spaces to center string
title_string=sprintf(...
  '%s                                \n%s                                ',...
  comments{1},comments{2});
title(title_string);


return;







