0001 function [cmat, X] = post_process_corrmat(spm_fname,opt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 if nargin < 2
0022 opt = struct();
0023 end
0024
0025 load new_seismic
0026
0027 data = load(spm_fname);
0028 if isfield(data,'SPM')
0029 xX = data.SPM.xX;
0030 Xnames = xX.name;
0031 Sess = data.SPM.Sess;
0032 else
0033 xX = data.xX;
0034 Xnames = xX.Xnames;
0035 Sess = data.Sess;
0036 end
0037
0038
0039 if isfield(opt,'figh')
0040 figure(opt.figh), clf
0041 else
0042 figure
0043 opt.figh = gcf;
0044 end
0045
0046 nruns = length(Sess);
0047 for irun = 1:nruns
0048
0049 cc = Sess(irun).col;
0050 cr = Sess(irun).row;
0051
0052
0053 if isfield(opt,'names')
0054 cc = find(ismember(Xnames,opt.names));
0055 end
0056
0057
0058 X = xX.X(cr,cc);
0059
0060
0061 cnames = Xnames(cc);
0062
0063
0064 rem_col = find(sum(X) == size(X,1));
0065 if ~isempty(rem_col)
0066 X(:,rem_col) = [];
0067 cnames{rem_col} = [];
0068 end
0069
0070 cmat = corrcoef(X);
0071
0072
0073 subplot(nruns,1,irun)
0074
0075
0076 imagesc(cmat,[-1 1]), axis square
0077
0078 colormap(new_seismic)
0079 colorbar
0080
0081 set(gca,'ytick',1:size(cmat,2))
0082 set(gca,'yticklabel',cnames)
0083
0084 if isfield(opt,'plot_corr_txt') && opt.plot_corr_txt
0085 for ir = 1:size(cmat,1)
0086 for ic = 1:size(cmat,2)
0087 text(ic,ir,sprintf('%1.2f', cmat(ir,ic)),'horizontalalign','center')
0088 end
0089 end
0090 end
0091
0092 set(gca,'xtick',[])
0093 set(gca,'ticklen',[0 0])
0094
0095 if nruns == 1
0096 for ic = 1:size(cmat,2)
0097 text(ic,size(cmat,1)+0.5,strrep(cnames{ic},'_','\_'),'rotation',-90,'horizontalalign','left')
0098 end
0099 end
0100
0101 if isfield(opt,'title')
0102 if irun == 1
0103 title_str = sprintf('%s, Run %d', opt.title, irun);
0104 else
0105 title_str = sprintf('Run %d', irun);
0106 end
0107 title(title_str,'fontsize',14)
0108 end
0109 end
0110
0111
0112 try
0113 if opt.printfig
0114 print(sprintf('%s.ps',opt.figstub),'-dpsc', opt.append_str)
0115
0116
0117
0118
0119 end
0120 catch
0121 end
0122
0123
0124 if nargout > 1
0125 X = xX.X;
0126 end