0001 function varargout = ui_report(D, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 if nargin < 2
0014 action = 'desrepui';
0015 else
0016 action = varargin{1};
0017 end
0018
0019
0020
0021 cb = 'tmp = get(findobj(''Tag'', ''DesRepUI''),''UserData''); ';
0022
0023
0024 SPM = des_struct(D);
0025
0026
0027 try
0028 SPM.xC;
0029 catch
0030 SPM.xC = {};
0031 end
0032 try
0033 SPM.xsDes;
0034 catch
0035 SPM.xsDes = [];
0036 end
0037
0038 switch lower(action)
0039
0040
0041 case 'desrepui'
0042
0043
0044
0045
0046
0047
0048 if ~isfield(SPM.xX,'nKX')
0049 SPM.xX.nKX = spm_DesMtx('Sca',SPM.xX.X,SPM.xX.name);
0050 end
0051
0052
0053 D = des_struct(D, SPM);
0054
0055
0056
0057
0058
0059
0060 Finter = spm_figure('GetWin','Interactive');
0061 delete(findobj(get(Finter,'Children'),'flat','Tag','DesRepUI'))
0062
0063
0064
0065 hC = uimenu(Finter,'Label','Design',...
0066 'Separator','on',...
0067 'Tag','DesRepUI',...
0068 'UserData',D,...
0069 'HandleVisibility','on');
0070
0071
0072
0073 hDesMtx = uimenu(hC,'Label','Design Matrix','Accelerator','D',...
0074 'CallBack',[cb,...
0075 'ui_report(tmp, ''DesMtx'')'],...
0076 'UserData',hC,...
0077 'HandleVisibility','off');
0078
0079
0080
0081 h = uimenu(hC,'Label','Design orthogonality','Accelerator','O',...
0082 'CallBack',[cb,...
0083 'ui_report(tmp, ''DesOrth'')'],...
0084 'UserData',hC,...
0085 'HandleVisibility','off');
0086
0087
0088
0089 hExplore = uimenu(hC,'Label','Explore','HandleVisibility','off');
0090
0091 switch modality(D)
0092 case 'pet'
0093 hFnF = uimenu(hExplore,'Label','Files and factors','Accelerator','F',...
0094 'CallBack',[cb,...
0095 'ui_report(tmp, ''Files&Factors'')'],...
0096 'UserData',hC,...
0097 'HandleVisibility','off');
0098 hCovs = uimenu(hExplore,'Label','Covariates','Accelerator','C',...
0099 'CallBack',[cb,...
0100 'ui_report(tmp, ''Covs'')'],...
0101 'UserData',hC,...
0102 'HandleVisibility','off');
0103 if isempty(SPM.xC), set(hCovs,'Enable','off'), end
0104 case 'fmri'
0105 for j = 1:length(SPM.Sess)
0106 h = uimenu(hExplore,'Label',sprintf('Session %.0f ',j),...
0107 'HandleVisibility','off');
0108 for k = 1:length(SPM.Sess(j).Fc)
0109 uimenu(h,'Label',SPM.Sess(j).Fc(k).name,...
0110 'CallBack',[cb,...
0111 sprintf('ui_report_fmri(tmp,%d,%d);',j,k)],...
0112 'UserData',hC,...
0113 'HandleVisibility','off')
0114 end
0115 end
0116 end
0117
0118
0119
0120
0121 uimenu(hC,'Label','Clear','Accelerator','L','Separator','on',...
0122 'CallBack','spm_results_ui(''Clear'')',...
0123 'HandleVisibility','off');
0124 uimenu(hC,'Label','Help','Separator','on',...
0125 'CallBack','spm_help(''spm_DesRep'')',...
0126 'HandleVisibility','off');
0127
0128
0129
0130 figure(Finter)
0131
0132
0133
0134 varargout = {hC};
0135
0136
0137
0138 case 'files&factors'
0139
0140
0141 fnames = image_names(D);
0142 if isempty(fnames)
0143 fnames = cell(size(SPM.xX.X, 1), 1);
0144 end
0145
0146 I = SPM.xX.I;
0147 xC = SPM.xC;
0148 sF = SPM.xX.sF;
0149 xs = SPM.xsDes;
0150
0151 [fnames,CPath] = spm_str_manip(fnames,'c');
0152 nScan = size(I,1);
0153 bL = any(diff(I,1),1);
0154
0155
0156 Fgraph = spm_figure('GetWin','Graphics');
0157 spm_results_ui('Clear',Fgraph,0)
0158 FS = spm('FontSizes');
0159
0160
0161
0162 hTax = axes('Position',[0.03,0.85,0.94,0.1],...
0163 'DefaultTextFontSize',FS(9),...
0164 'XLim',[0,1],'YLim',[0,1],...
0165 'Visible','off');
0166
0167 text(0.5,1,'Statistical analysis: Image files & covariates...',...
0168 'Fontsize',FS(14),'Fontweight','Bold',...
0169 'HorizontalAlignment','center')
0170
0171 dx1 = 0.05;
0172 dx2 = 0.08;
0173
0174 x = 0; text(x+.02,.1,'image #','Rotation',90)
0175 if bL(4), x=x+dx1; text(x+.01,.1,sF{4},'Rotation',90), end
0176 if bL(3), x=x+dx1; text(x+.01,.1,sF{3},'Rotation',90), end
0177 if bL(2), x=x+dx1; text(x+.01,.1,sF{2},'Rotation',90), end
0178 if bL(1), x=x+dx1; text(x+.01,.1,sF{1},'Rotation',90), end
0179
0180 for j = 1:length(xC)
0181 n = size(xC(j).rc,2);
0182 if n>1, tmp=xC(j).cname; else, tmp={xC(j).rcname}; end
0183 for k=1:n
0184 x=x+dx2;
0185 text(x,.1,tmp{k},'Rotation',90,'Interpreter','TeX')
0186 end
0187 end
0188
0189 x=x+dx2;
0190 text(x,0.65,'Base directory:','FontWeight','Bold')
0191 text(x,0.5,CPath,'FontSize',FS(8))
0192 text(x,0.2,'filename tails...')
0193
0194 line('XData',[0 1],'YData',[0 0],'LineWidth',3,'Color','r')
0195
0196
0197
0198 hAx = axes('Position',[0.03,0.05,0.94,0.8],...
0199 'DefaultTextFontSize',FS(8),...
0200 'Units','points',...
0201 'Visible','off');
0202 AxPos = get(hAx,'Position'); set(hAx,'YLim',[0,AxPos(4)])
0203
0204 dy = FS(9); y0 = floor(AxPos(4)) -dy; y = y0;
0205
0206 for i = 1:nScan
0207
0208
0209 x = 0; text(x,y,sprintf('%03d',i))
0210 if bL(4), x=x+dx1; text(x,y,sprintf('%02d',I(i,4))), end
0211 if bL(3), x=x+dx1; text(x,y,sprintf('%02d',I(i,3))), end
0212 if bL(2), x=x+dx1; text(x,y,sprintf('%02d',I(i,2))), end
0213 if bL(1), x=x+dx1; text(x,y,sprintf('%02d',I(i,1))), end
0214
0215
0216 for j = 1:length(xC)
0217 for k=1:size(xC(j).rc,2)
0218 x=x+dx2;
0219 text(x,y,sprintf('%6g',xC(j).rc(i,k)),...
0220 'HorizontalAlignment','Center')
0221 end
0222 end
0223
0224
0225 x=x+dx2;
0226 text(x,y,fnames{i})
0227 y=y-dy;
0228
0229
0230 if y<dy
0231 text(0.5,0,sprintf('Page %d',spm_figure('#page')),...
0232 'FontSize',FS(8),'FontAngle','italic')
0233 spm_figure('NewPage',[hAx;get(hAx,'Children')])
0234 hAx = axes('Units','points','Position',AxPos,...
0235 'DefaultTextFontSize',FS(8),'YLim',[0,AxPos(4)],...
0236 'Visible','off');
0237 y = y0;
0238 text(y,0,'continued...','FontAngle','Italic')
0239 end
0240 end
0241
0242 line('XData',[0 1],'YData',[y y],'LineWidth',3,'Color','r')
0243
0244
0245
0246
0247
0248 if ~isempty(xs)
0249 y = y - 2*dy;
0250 for sf = fieldnames(xs)'
0251 text(0.3,y,[strrep(sf{1},'_',' '),' :'],...
0252 'HorizontalAlignment','Right','FontWeight','Bold',...
0253 'FontSize',FS(9))
0254 s = getfield(xs,sf{1});
0255 if ~iscellstr(s), s={s}; end
0256 for i=1:prod(size(s))
0257 text(0.31,y,s{i},'FontSize',FS(9))
0258 y=y-dy;
0259 end
0260 end
0261 end
0262
0263
0264 if spm_figure('#page')>1
0265 text(0.5,0,sprintf('Page %d/%d',spm_figure('#page')*[1,1]),...
0266 'FontSize',FS(8),'FontAngle','italic')
0267 spm_figure('NewPage',[hAx;get(hAx,'Children')])
0268 end
0269
0270
0271
0272 figure(Fgraph)
0273
0274
0275
0276
0277 case {'desmtx','desorth'}
0278
0279
0280
0281
0282 xX = SPM.xX;
0283 fnames = image_names(D);
0284 xs = SPM.xsDes;
0285
0286 desmtx = strcmp(lower(varargin{1}),'desmtx');
0287
0288
0289
0290
0291 if isfield(xX,'xKXs') & ...
0292 ~isempty(xX.xKXs) & isstruct(xX.xKXs)
0293 iX = 1;
0294 [nScan,nPar] = size(xX.xKXs.X);
0295 elseif isfield(xX,'X') & ~isempty(xX.X)
0296 iX = 0;
0297 [nScan,nPar] = size(xX.X);
0298 else
0299 error('Can''t find DesMtx in this structure!')
0300 end
0301
0302 if isfield(xX,'nKX') & ~isempty(xX.nKX)
0303 inX = 1; else, inX = 0; end
0304
0305 if isfield(xX,'name') & ~isempty(xX.name)
0306 Xnames = xX.name; else, Xnames = {}; end
0307
0308
0309
0310
0311 if ~desmtx
0312 if iX
0313 tmp = sqrt(sum(xX.xKXs.X.^2));
0314 O = xX.xKXs.X'*xX.xKXs.X./kron(tmp',tmp);
0315 tmp = sum(xX.xKXs.X);
0316 else
0317 tmp = sqrt(sum(xX.X.^2));
0318 O = xX.X'*xX.X./kron(tmp',tmp);
0319 tmp = sum(xX.X);
0320 end
0321 tmp = abs(tmp)<eps*1e5;
0322 bC = kron(tmp',tmp);
0323 end
0324
0325
0326
0327
0328
0329
0330
0331 Fgraph = spm_figure('GetWin','Graphics');
0332 spm_results_ui('Clear',Fgraph,0)
0333 FS = spm('FontSizes');
0334
0335
0336
0337
0338 hTax = axes('Position',[0.03,0,0.94,1],...
0339 'DefaultTextFontSize',FS(9),...
0340 'XLim',[0,1],'YLim',[0,1],...
0341 'Visible','off');
0342
0343 str='Statistical analysis: Design'; if ~desmtx, str=[str,' orthogonality']; end
0344 text(0.5,0.95,str,'Fontsize',FS(14),'Fontweight','Bold',...
0345 'HorizontalAlignment','center')
0346
0347 line('Parent',hTax,...
0348 'XData',[0.3 0.7],'YData',[0.92 0.92],'LineWidth',3,'Color','r')
0349
0350
0351
0352
0353 hDesMtx = axes('Position',[.07 .4 .6 .4]);
0354 if inX
0355 hDesMtxIm = image((xX.nKX + 1)*32);
0356 elseif iX
0357 hDesMtxIm = image((spm_DesMtx('sca',xX.xKXs.X,Xnames) + 1)*32);
0358 else
0359 hDesMtxIm = image((spm_DesMtx('sca',xX.X, Xnames) + 1)*32);
0360 end
0361
0362 STick = ui_report(D, 'ScanTick',nScan,32);
0363 PTick = ui_report(D, 'ScanTick',nPar,32);
0364
0365 set(hDesMtx,'TickDir','out',...
0366 'XTick',PTick,'XTickLabel','',...
0367 'YTick',STick,'YTickLabel','')
0368 if desmtx
0369 xlabel('parameters'), ylabel('images')
0370 else
0371 set(get(hDesMtx,'Xlabel'),...
0372 'Position',get(get(hDesMtx,'Ylabel'),'Position'),...
0373 'Rotation',90')
0374 xlabel('design matrix')
0375 end
0376
0377
0378 if ~isempty(Xnames)
0379 axes('Position',[.07 .8 .6 .1],'Visible','off',...
0380 'DefaultTextFontSize',FS(8),'DefaultTextInterpreter','TeX',...
0381 'XLim',[0,nPar]+0.5)
0382 for i=PTick, text(i,.05,Xnames{i},'Rotation',90), end
0383 end
0384
0385
0386
0387
0388 if desmtx & ~isempty(fnames)
0389 axes('Position',[.68 .4 .3 .4],'Visible','off',...
0390 'DefaultTextFontSize',FS(8),...
0391 'YLim',[0,nScan]+0.5,'YDir','Reverse')
0392 for i = STick
0393 try
0394 str = fnames(i,:);
0395 catch
0396 str = fnames{i};
0397 end
0398 text(0,i,spm_str_manip(str,'Ca35'));
0399 end
0400 end
0401
0402
0403
0404 if iX, set(hDesMtxIm,'UserData',...
0405 struct('X',xX.xKXs.X,'Xnames',{Xnames},'fnames',{fnames}))
0406 else, set(hDesMtxIm,'UserData',...
0407 struct('X',xX.X, 'Xnames',{Xnames},'fnames',{fnames}))
0408 end
0409 set(hDesMtxIm,'ButtonDownFcn',[cb 'ui_report(tmp, ''SurfDesMtx_CB'')'])
0410
0411
0412 if desmtx
0413
0414
0415 hPEstAx = axes('Position',[.07 .315 .6 .025],...
0416 'DefaultTextInterpreter','TeX');
0417 if iX, est = spm_SpUtil('IsCon',xX.xKXs);
0418 else, est = spm_SpUtil('IsCon',xX.X); end
0419 hParEstIm = image((est+1)*32);
0420 set(hPEstAx,...
0421 'XLim',[0,nPar]+.5,'XTick',[1:nPar-1]+.5,'XTickLabel','',...
0422 'YLim',[0,1]+.5,'YDir','reverse','YTick',[],...
0423 'Box','on','TickDir','in','XGrid','on','GridLineStyle','-');
0424 xlabel('parameter estimability')
0425 text((nPar+0.5 + nPar/30),1,...
0426 '(gray \rightarrow \beta not uniquely specified)',...
0427 'Interpreter','TeX','FontSize',FS(8))
0428 set(hParEstIm,'UserData',struct('est',est,'Xnames',{Xnames}))
0429 set(hParEstIm,'ButtonDownFcn',[cb 'ui_report(tmp, ''SurfEstIm_CB'')'])
0430 else
0431
0432
0433 hDesO = axes('Position',[.07 .18 .6 .2]);
0434 tmp = 1-abs(O); tmp(logical(tril(ones(nPar),-1))) = 1;
0435 hDesOIm = image(tmp*64);
0436
0437 set(hDesO,'Box','off','TickDir','out',...
0438 'XaxisLocation','top','XTick',PTick,'XTickLabel','',...
0439 'YaxisLocation','right','YTick',PTick,'YTickLabel','',...
0440 'YDir','reverse')
0441 tmp = [1,1]'*[[0:nPar]+0.5];
0442 line('Xdata',tmp(1:end-1)','Ydata',tmp(2:end)')
0443
0444 xlabel('design orthogonality')
0445 set(get(hDesO,'Xlabel'),'Position',[0.5,nPar,0],...
0446 'HorizontalAlignment','left',...
0447 'VerticalAlignment','top')
0448 set(hDesOIm,...
0449 'UserData',struct('O',O,'bC',bC,'Xnames',{Xnames}),...
0450 'ButtonDownFcn',[cb 'ui_report(tmp, ''SurfDesO_CB'')'])
0451
0452 if ~isempty(Xnames)
0453 axes('Position',[.69 .18 0.01 .2],'Visible','off',...
0454 'DefaultTextFontSize',FS(10),...
0455 'DefaultTextInterpreter','TeX',...
0456 'YDir','reverse','YLim',[0,nPar]+0.5)
0457 for i=PTick
0458 text(0,i,Xnames{i},'HorizontalAlignment','left')
0459 end
0460 end
0461
0462 end
0463
0464
0465
0466 if desmtx
0467 str = 'Design description...';
0468 line('Parent',hTax,...
0469 'XData',[0.3 0.7],'YData',[0.28 0.28],'LineWidth',3,'Color','r')
0470 hAx = axes('Position',[0.03,0.05,0.94,0.22],'Visible','off');
0471 else
0472 str = '';
0473 line('Parent',hTax,...
0474 'XData',[0.3 0.7],'YData',[0.14 0.14],'LineWidth',3,'Color','r')
0475 hAx = axes('Position',[0.03,0.05,0.94,0.08],'Visible','off');
0476 xs = struct('Measure', ['abs. value of cosine of angle between ',...
0477 'columns of design matrix'],...
0478 'Scale', {{ 'black - colinear (cos=+1/-1)';...
0479 'white - orthogonal (cos=0)';...
0480 'gray - not orthogonal or colinear'}});
0481 end
0482
0483
0484 if ~isempty(xs)
0485 set(hAx,'Units','points');
0486 AxPos = get(hAx,'Position');
0487 set(hAx,'YLim',[0,AxPos(4)])
0488
0489 dy = FS(9); y0 = floor(AxPos(4)) -dy; y = y0;
0490
0491 text(0.3,y,str,...
0492 'HorizontalAlignment','Center',...
0493 'FontWeight','Bold','FontSize',FS(11))
0494 y=y-2*dy;
0495
0496 for sf = fieldnames(xs)'
0497 text(0.3,y,[strrep(sf{1},'_',' '),' :'],...
0498 'HorizontalAlignment','Right','FontWeight','Bold',...
0499 'FontSize',FS(9))
0500 s = getfield(xs,sf{1});
0501 if ~iscellstr(s), s={s}; end
0502 for i=1:prod(size(s))
0503 text(0.31,y,s{i},'FontSize',FS(9))
0504 y=y-dy;
0505 end
0506 end
0507 end
0508
0509
0510
0511 figure(Fgraph)
0512
0513
0514
0515 case 'covs'
0516
0517
0518
0519 xX = SPM.xX;
0520 xC = SPM.xC;
0521
0522 if ~length(xC), spm('alert!','No covariates!',mfilename), return, end
0523
0524
0525 Fgraph = spm_figure('GetWin','Graphics');
0526 spm_results_ui('Clear',Fgraph,0)
0527 FS = spm('FontSizes');
0528
0529
0530
0531 hTax = axes('Position',[0.03,0,0.94,1],...
0532 'DefaultTextFontSize',FS(9),...
0533 'XLim',[0,1],'YLim',[0,1],...
0534 'Visible','off');
0535
0536 text(0.5,0.95,'Statistical analysis: Covariates',...
0537 'Fontsize',FS(14),'Fontweight','Bold',...
0538 'HorizontalAlignment','center')
0539
0540 text(0.5,0.82,'(covariates plotted over transposed design matrix)',...
0541 'FontSize',FS(8),'HorizontalAlignment','center')
0542
0543 line('XData',[0.3 0.7],'YData',[0.92 0.92],'LineWidth',3,'Color','r')
0544 line('XData',[0.3 0.7],'YData',[0.44 0.44],'LineWidth',3,'Color','r')
0545
0546
0547
0548
0549 [nScan,nPar] = size(xX.X);
0550 if isfield(xX,'name') & ~isempty(xX.name)
0551 Xnames = xX.name; else, Xnames = {}; end
0552
0553
0554 hDesMtx = axes('Position',[.1 .5 .7 .3]);
0555 if isfield(xX,'nKX') & ~isempty(xX.nKX)
0556 image(xX.nKX'*32+32)
0557 elseif isfield(xX,'xKXs') & ~isempty(xX.xKXs)
0558 image(spm_DesMtx('sca',xX.xKXs.X,Xnames)*32+32)
0559 else
0560 image(spm_DesMtx('sca',xX.X,Xnames)*32+32)
0561 end
0562 set(hDesMtx,'Visible','off')
0563
0564
0565 hParAx = axes('Position',[.8 .5 .2 .3],'Visible','off',...
0566 'DefaultTextFontSize',FS(8),'DefaultTextInterpreter','TeX',...
0567 'YLim',[0.5,nPar+0.5],'YDir','Reverse');
0568 hPNames = zeros(nPar,1);
0569 for i = 1:nPar, hPNames(i) = text(.05,i,Xnames{i}); end
0570
0571
0572
0573
0574 for i = 1:length(xC)
0575
0576
0577
0578 hSTitle = text(0.5,0.87,sprintf('%d : %s',i,xC(i).rcname),...
0579 'Parent',hTax,...
0580 'HorizontalAlignment','center',...
0581 'FontSize',FS(13),'FontWeight','Bold');
0582
0583
0584
0585 hAx = axes('Position',[.1 .5 .7 .3],...
0586 'TickDir','out','Box','off','Color','none',...
0587 'NextPlot','add',...
0588 'XLim',[0,nScan]+0.5);
0589 plot(xC(i).rc,'LineWidth',2)
0590 if nScan<48, plot(xC(i).rc,'.k','MarkerSize',20); end
0591 xlabel('image #')
0592 ylabel('covariate value')
0593
0594
0595
0596
0597 hDAx = axes('Position',[0.03,0.1,0.94,0.30],'Visible','off');
0598
0599 set(hDAx,'Units','points');
0600 tmp = get(hDAx,'Position');
0601 set(hDAx,'YLim',[0,tmp(4)])
0602
0603 dy = FS(9); y0 = floor(tmp(4)) -dy; y = y0;
0604
0605
0606 text(0.3,y,'Details :',...
0607 'HorizontalAlignment','Right',...
0608 'FontWeight','Bold','FontSize',FS(9))
0609 s = xC(i).descrip;
0610 if ~iscellstr(s), s={s}; end
0611 for j=1:prod(size(s))
0612 text(0.31,y,s{j},'FontSize',FS(9))
0613 y=y-dy;
0614 end
0615 y=y-dy;
0616
0617
0618
0619 if size(xC(i).rc,2)>1
0620 ColorOrder = get(hAx,'ColorOrder');
0621 text(0.3,y,'Key :',...
0622 'HorizontalAlignment','Right',...
0623 'FontWeight','Bold','FontSize',FS(9))
0624 for j = 1:size(xC(i).rc,2)
0625 color = ColorOrder(mod(j-1,size(ColorOrder,1))+1,:);
0626 if size(xC(i).rc,2)==length(xC(i).cname)
0627 str = xC(i).cname{j};
0628 else
0629 str = sprintf('column %d',j);
0630 end
0631 text(0.31,y,str,'FontSize',FS(9),...
0632 'Color',color)
0633 text(0.5,xC(i).rc(1,j),[str,' \rightarrow'],...
0634 'Parent',hAx,...
0635 'FontSize',FS(8),'FontWeight','Bold',...
0636 'HorizontalAlignment','Right',...
0637 'Interpreter','TeX',...
0638 'Color',color)
0639 y=y-dy;
0640 end
0641 y=y-dy;
0642 end
0643
0644
0645
0646
0647 text(0.3,y,'Design matrix columns :',...
0648 'HorizontalAlignment','Right',...
0649 'FontWeight','Bold','FontSize',FS(9))
0650 if isempty(xC(i).cols)
0651 text(0.31,y,'(none)','FontSize',FS(9))
0652 else
0653 for j = xC(i).cols
0654 text(0.31,y,sprintf('%d : %s',j,Xnames{j}),...
0655 'FontSize',FS(9),'Interpreter','TeX')
0656 y=y-dy;
0657 end
0658 end
0659 y=y-dy;
0660
0661
0662
0663
0664 hCurPNames = hPNames(xC(i).cols);
0665 set(hCurPNames,'Color','r','FontWeight','Bold','FontSize',FS(8))
0666
0667
0668
0669
0670 if length(xC)>1
0671 spm_figure('NewPage',[hSTitle; hAx; get(hAx,'Children');...
0672 hCurPNames; hDAx; get(hDAx,'Children')]);
0673 end
0674
0675 end
0676
0677
0678
0679 figure(Fgraph)
0680
0681
0682
0683 case 'scantick'
0684
0685
0686
0687
0688 if nargin<3, lim=32; else, lim=varargin{3}; end
0689 if nargin<2, error('insufficient arguments'), end
0690 nScan = varargin{2};
0691
0692 p = max(1,ceil(nScan/lim));
0693 s = 1:p:nScan; s(end)=nScan;
0694
0695 varargout = {s,lim};
0696
0697
0698
0699 case {'surfdesmtx_cb','surfdesmtxmo_cb','surfdesmtxup_cb'}
0700
0701
0702
0703
0704
0705 h = get(gca,'Xlabel');
0706
0707 if strcmp(lower(varargin{1}),'surfdesmtxup_cb')
0708 UD = get(h,'UserData');
0709 set(h,'String',UD.String,'Interpreter',UD.Interpreter,...
0710 'UserData',UD.UserData)
0711 set(gcbf,'WindowButtonMotionFcn','','WindowButtonUpFcn','')
0712 return
0713 end
0714
0715
0716 if strcmp(lower(varargin{1}),'surfdesmtx_cb')
0717 UD = struct( 'String', get(h,'String'),...
0718 'Interpreter', get(h,'Interpreter'),...
0719 'UserData', get(h,'UserData'));
0720 set(h,'UserData',UD)
0721 set(gcbf,'WindowButtonMotionFcn',[cb 'ui_report(tmp, ''SurfDesMtxMo_CB'')'],...
0722 'WindowButtonUpFcn', [cb 'ui_report(tmp, ''SurfDesMtxUp_CB'')'])
0723 end
0724
0725 mm = [get(gca,'YLim')',get(gca,'XLim')']+[.5,.5;-.5,-.5];
0726 ij = get(gca,'CurrentPoint');
0727 ij = round(min(max(ij(1,[2,1]),mm(1,:)),mm(2,:)));
0728
0729 istr = 'none';
0730 switch get(gcbf,'SelectionType')
0731 case 'normal'
0732 try, str = sprintf('X(%d,%d) = %g',ij(1),ij(2),...
0733 subsref(get(gco,'UserData'),...
0734 struct('type',{'.','()'},'subs',{'X',{ij(1),ij(2)}})));
0735 catch, str='(no cached design matrix to surf)'; end
0736 case 'extend'
0737 try, str = sprintf('Image %d: %s',ij(1),...
0738 spm_str_manip(...
0739 subsref(get(gco,'UserData'),...
0740 struct('type',{'.','()'},...
0741 'subs',{'fnames',{ij(1),':'}})),'Ca40'));
0742 catch, str='(no cached image filenames to surf)'; end
0743 case 'alt'
0744 try, str = sprintf('Parameter %d: %s',ij(2),...
0745 subsref(get(gco,'UserData'),...
0746 struct('type',{'.','{}'},'subs',{'Xnames',{ij(2)}})));
0747 istr = 'tex';
0748 catch, str='(no cached parameter names to surf)'; end
0749 case 'open'
0750 try, assignin('base','ans',subsref(get(gco,'UserData'),...
0751 struct('type',{'.'},'subs',{'X'})))
0752 evalin('base','ans')
0753 catch, fprintf('%s GUI: can''t find design matrix\n',mfilename)
0754 end
0755 return
0756 end
0757
0758 set(h,'String',str,'Interpreter',istr)
0759
0760
0761
0762 case {'surfestim_cb','surfestimmo_cb','surfestimup_cb'}
0763
0764
0765
0766
0767
0768 h = get(gca,'Xlabel');
0769
0770 if strcmp(lower(varargin{1}),'surfestimup_cb')
0771 UD = get(h,'UserData');
0772 set(h,'String',UD.String,'Interpreter',UD.Interpreter,...
0773 'UserData',UD.UserData)
0774 set(gcbf,'WindowButtonMotionFcn','','WindowButtonUpFcn','')
0775 return
0776 end
0777
0778 if strcmp(lower(varargin{1}),'surfestim_cb')
0779 UD = struct( 'String', get(h,'String'),...
0780 'Interpreter', get(h,'Interpreter'),...
0781 'UserData', get(h,'UserData'));
0782 set(h,'UserData',UD)
0783 set(gcbf,'WindowButtonMotionFcn',[cb 'ui_report(tmp, ''SurfEstImMo_CB'')'],...
0784 'WindowButtonUpFcn', [cb 'ui_report(tmp, ''SurfEstImUp_CB'')'])
0785 end
0786
0787 mm = [get(gca,'XLim')]+[.5,-.5];
0788 i = get(gca,'CurrentPoint');
0789 i = round(min(max(i(1,1),mm(1)),mm(2)));
0790
0791 istr = 'none';
0792 switch get(gcbf,'SelectionType')
0793 case 'normal'
0794 try, tmp = {' (not unique)',' (unique)'};
0795 str = sprintf('Parameter %d : %s%s',...
0796 i,...
0797 subsref(get(gco,'UserData'),...
0798 struct('type',{'.','{}'},'subs',{'Xnames',{i}})),...
0799 tmp{subsref(get(gco,'UserData'),...
0800 struct('type',{'.','()'},'subs',{'est',{i}}))+1});
0801 istr = 'tex';
0802 catch, str='(no cached data to surf)'; end
0803 case {'extend','alt'}
0804 return
0805 case 'open'
0806 try, UD = get(gco,'UserData');
0807 assignin('base','ans',...
0808 subsref(get(gco,'UserData'),...
0809 struct('type',{'.'},'subs',{'est'})))
0810 evalin('base','ans')
0811 catch, fprintf('%s GUI: can''t find design orthogonality\n',mfilename)
0812 end
0813 return
0814 end
0815
0816 set(h,'String',str,'Interpreter',istr)
0817
0818
0819
0820
0821 case {'surfdeso_cb','surfdesomo_cb','surfdesoup_cb'}
0822
0823
0824
0825
0826
0827 h = get(gca,'Xlabel');
0828
0829 if strcmp(lower(varargin{1}),'surfdesoup_cb')
0830 UD = get(h,'UserData');
0831 set(h,'String',UD.String,'Interpreter',UD.Interpreter,...
0832 'UserData',UD.UserData)
0833 set(gcbf,'WindowButtonMotionFcn','','WindowButtonUpFcn','')
0834 return
0835 end
0836
0837 if strcmp(lower(varargin{1}),'surfdeso_cb')
0838 UD = struct( 'String', get(h,'String'),...
0839 'Interpreter', get(h,'Interpreter'),...
0840 'UserData', get(h,'UserData'));
0841 set(h,'UserData',UD)
0842 set(gcbf,'WindowButtonMotionFcn',[cb 'ui_report(tmp, ''SurfDesOMo_CB'')'],...
0843 'WindowButtonUpFcn', [cb 'ui_report(tmp, ''SurfDesOUp_CB'')'])
0844 end
0845
0846 mm = [get(gca,'YLim')',get(gca,'XLim')']+[.5,.5;-.5,-.5];
0847 ij = get(gca,'CurrentPoint');
0848 ij = round(min(max(ij(1,[2,1]),mm(1,:)),mm(2,:)));
0849 if ij(1)>ij(2), return, end
0850
0851 istr = 'none';
0852 switch get(gcbf,'SelectionType')
0853 case 'normal'
0854 try
0855 UD = get(gco,'UserData');
0856 if abs(abs(UD.O(ij(1),ij(2)))-1) < eps*1e1
0857 str = '{\bf colinear}';
0858 elseif abs(UD.O(ij(1),ij(2))) < eps*1e1
0859 str = '{\bf orthogonal}';
0860 else
0861 str = '{\bf not orthogonal}';
0862 end
0863 if ~diff(ij), str=[str,' {\it(same column)}']; end
0864 if UD.bC(ij(1),ij(2)), tmp=' ={\it r}'; else, tmp=''; end
0865 str = { sprintf('{\\bf %s} (col %d) & {\\bf %s} (col %d)',...
0866 UD.Xnames{ij(1)},ij(1),...
0867 UD.Xnames{ij(2)},ij(2)),...
0868 sprintf('cos(\\theta)%s = %1.2f',...
0869 tmp,UD.O(ij(1),ij(2))),...
0870 ['\rightarrow ',str]};
0871 istr = 'tex';
0872 catch, str='(no cached data to surf)'; end
0873 case {'extend','alt'}
0874 return
0875 case 'open'
0876 try, UD = get(gco,'UserData');
0877 assignin('base','ans',UD.O)
0878 evalin('base','ans')
0879 catch, fprintf('%s GUI: can''t find design orthogonality\n',mfilename)
0880 end
0881 return
0882 end
0883
0884 set(h,'String',str,'Interpreter',istr)
0885
0886
0887
0888 case {'surfcon_cb','surfconmo_cb','surfconup_cb'}
0889
0890
0891
0892
0893
0894 cUD = get(gco,'UserData');
0895 if ~isstruct(cUD) | ~isfield(cUD,'h')
0896 warning('contrast GUI objects setup incorrectly'), return
0897 end
0898 h = cUD.h;
0899
0900 if strcmp(lower(varargin{1}),'surfconup_cb')
0901 UD = get(h,'UserData');
0902 set(h,'String',UD.String,'Interpreter',UD.Interpreter,...
0903 'UserData',UD.UserData)
0904 set(gcbf,'WindowButtonMotionFcn','','WindowButtonUpFcn','')
0905 return
0906 end
0907
0908 if strcmp(lower(varargin{1}),'surfcon_cb')
0909 UD = struct( 'String', get(h,'String'),...
0910 'Interpreter', get(h,'Interpreter'),...
0911 'UserData', get(h,'UserData'));
0912 set(h,'UserData',UD)
0913 set(gcbf,'WindowButtonMotionFcn',[cb 'ui_report(tmp, ''SurfConMo_CB'')'],...
0914 'WindowButtonUpFcn', [cb 'ui_report(tmp, ''SurfConUp_CB'')'])
0915 end
0916
0917 mm = [get(gca,'YLim')',get(gca,'XLim')']+[.5,.5;-.5,-.5];
0918 ij = get(gca,'CurrentPoint');
0919 ij = round(min(max(ij(1,[2,1]),mm(1,:)),mm(2,:)));
0920
0921 istr = 'none';
0922 switch get(gcbf,'SelectionType')
0923 case 'normal'
0924 try
0925 if cUD.i>0, str = sprintf('%d',cUD.i); else, str = ''; end
0926 switch get(gco,'Type')
0927 case 'image'
0928 str = sprintf('%s\\{F\\}: {\\bf%s} (%d,%d) = %.2f',...
0929 str,cUD.xCon.name,ij(2),ij(1),...
0930 cUD.xCon.c(ij(2),ij(1)));
0931 case 'patch'
0932 str = sprintf('%s\\{T\\}: {\\bf%s} (%d) = %.2f',...
0933 str,cUD.xCon.name,ij(2),...
0934 cUD.xCon.c(ij(2)));
0935 otherwise, error('unexpected object type')
0936 end
0937 istr = 'TeX';
0938 catch, str='(no cached data to surf)'; end
0939 case {'alt','extend'}
0940 return
0941 case 'open'
0942 try, assignin('base','ans',cUD.xCon.c')
0943 evalin('base','ans')
0944 catch, fprintf('%s GUI: can''t find contrast\n',mfilename)
0945 end
0946 return
0947 end
0948
0949 set(h,'String',str,'Interpreter',istr)
0950
0951
0952
0953 otherwise
0954
0955 error(['Unknown action string: ',varargin{1}])
0956
0957
0958
0959
0960 end