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