0001 function [cmat, X] = post_process_corrmat_fsl(fsldir,opt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 if nargin < 2
0027 opt = struct();
0028 end
0029
0030 load new_seismic
0031
0032 if ~exist(fsldir,'dir')
0033 error('fsldir (%s) not found',fsldir);
0034 end
0035
0036 matfname = fullfile(fsldir,'fsf.mat');
0037 fsffname = fullfile(fsldir,'design.fsf');
0038 desfname = fullfile(fsldir,'design.mat');
0039
0040
0041 if ~exist(matfname,'file') && ~exist(fsffname,'file')
0042 error('FSL fsf FEAT structure not found in %s',fsldir);
0043 elseif exist(matfname,'file')
0044 load(matfname);
0045 elseif exist(fsffname,'file')
0046 error(['reading straight from design.fsf not yet supported ...\n' ...
0047 'please provide an fsf.mat file']);
0048
0049
0050 end
0051
0052 evnames = {fsf.ev.name};
0053
0054
0055 if exist(desfname,'file')
0056 desmat = loadtxt(desfname,'skipline',5);
0057 X = cell2mat(desmat);
0058 else
0059 error('could not find design matrix (%s)',desfname);
0060 end
0061
0062
0063
0064
0065 figure
0066
0067
0068 imagesc(X);
0069
0070
0071
0072
0073 set(gca,'xtick',[])
0074 set(gca,'ticklen',[0 0])
0075
0076 for ic = 1:size(X,2)
0077 text(ic,size(X,1)+0.5,strrep(evnames{ic},'_','\_'),'rotation',-90,'horizontalalign','left')
0078 end
0079
0080
0081 if isfield(opt,'title')
0082 title(sprintf('%s design matrix',opt.title),'fontsize',14)
0083 else
0084 title('design matrix','fontsize',14);
0085 end
0086
0087
0088
0089 try
0090 if opt.printfig
0091 print(sprintf('%s_desmat.ps',opt.figstub),'-dpsc','-adobecset', opt.append_str)
0092
0093
0094
0095
0096 end
0097 catch
0098 end
0099
0100
0101
0102
0103 figure
0104
0105
0106 rem_col = find(sum(X) == size(X,1));
0107 if ~isempty(rem_col)
0108 X(:,rem_col) = [];
0109 evnames(rem_col) = [];
0110 end
0111
0112 cmat = corrcoef(X);
0113
0114
0115 imagesc(cmat,[-1 1]), axis square
0116
0117
0118 colorbar
0119
0120 set(gca,'ytick',1:size(cmat,2))
0121 set(gca,'yticklabel',evnames)
0122
0123 if isfield(opt,'plot_corr_txt') && opt.plot_corr_txt
0124 for ir = 1:size(cmat,1)
0125 for ic = 1:size(cmat,2)
0126 text(ic,ir,sprintf('%1.2f', cmat(ir,ic)),'horizontalalign','center')
0127 end
0128 end
0129 end
0130
0131 set(gca,'xtick',[])
0132 set(gca,'ticklen',[0 0])
0133
0134 for ic = 1:size(cmat,2)
0135 text(ic,size(cmat,1)+0.5,strrep(evnames{ic},'_','\_'),'rotation',-90,'horizontalalign','left')
0136 end
0137
0138 if isfield(opt,'title')
0139 title(sprintf('%s regressor correlations',opt.title),'fontsize',14)
0140 else
0141 title('design matrix','fontsize',14);
0142 end
0143
0144
0145
0146 try
0147 if opt.printfig
0148 print(sprintf('%s_desmat_corr.ps',opt.figstub),'-dpsc','-adobecset', opt.append_str)
0149
0150
0151
0152
0153 end
0154 catch
0155 end