Home > marsbar > @mardo_99 > ui_report_fmri.m

ui_report_fmri

PURPOSE ^

Interactive review of fMRI design matrix

SYNOPSIS ^

function ui_report_fmri(D,s,i)

DESCRIPTION ^

 Interactive review of fMRI design matrix
 FORMAT ui_report_fmri(D,s,i)

 Copied with minor edits from:
 @(#)spm_fMRI_design_show.m    2.17    2.16 Karl Friston 99/09/20
 see that file for comments
 
 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ui_report_fmri(D,s,i)
0002 % Interactive review of fMRI design matrix
0003 % FORMAT ui_report_fmri(D,s,i)
0004 %
0005 % Copied with minor edits from:
0006 % @(#)spm_fMRI_design_show.m    2.17    2.16 Karl Friston 99/09/20
0007 % see that file for comments
0008 %
0009 % $Id$
0010 
0011 SPM = des_struct(D);
0012 xX   = SPM.xX;
0013 Sess = SPM.Sess;
0014 
0015 %-Generic CallBack code
0016 %-----------------------------------------------------------------------
0017 cb = 'tmp = get(findobj(''Tag'', ''DesRepUI''),''UserData''); ';
0018 
0019 % Do not proceed unless there are trials specified
0020 %-----------------------------------------------------------------------
0021 for j = 1:length(Sess)
0022     if ~length(Sess{j}.name)
0023         spm('alert*','User-specifed regressors only!',mfilename,sqrt(-1));
0024         return
0025     end
0026 end
0027 
0028 
0029 %-Defaults: Setup GUI
0030 %-----------------------------------------------------------------------
0031 if nargin < 3
0032     s = 1;
0033     i = 1;
0034 
0035     %-Get Interactive window and delete any previous DesRepUI menu
0036     %---------------------------------------------------------------
0037     Finter = spm_figure('GetWin','Interactive');
0038     delete(findobj(get(Finter,'Children'),'flat','Tag','DesRepUI'))
0039 
0040     %-Add a scaled design matrix to the design data structure
0041     %---------------------------------------------------------------
0042     if ~isfield(xX,'nKX'), xX.nKX = spm_DesMtx('Sca',xX.X,xX.Xnames); end
0043 
0044     %-Draw menu
0045     %---------------------------------------------------------------
0046     hC     = uimenu(Finter,'Label','Explore fMRI design',...
0047         'Separator','on',...
0048         'Tag','DesRepUI',...
0049         'UserData',D,...
0050         'HandleVisibility','on');
0051     for j = 1:length(Sess)
0052         h     = uimenu(hC,'Label',sprintf('Session %.0f ',j),...
0053             'HandleVisibility','off');
0054         for k = 1:length(Sess{j}.name)
0055             cb = ['tmp = get(get(gcbo,''UserData''),',...
0056                              '''UserData''); ',...
0057                 sprintf(['ui_report_fmri(',...
0058                     'tmp,%d,%d);'],j,k)];
0059             uimenu(h,'Label',Sess{j}.name{k},...
0060                              'CallBack',cb,...
0061                              'UserData',hC,...
0062                              'HandleVisibility','off')
0063         end
0064     end
0065 end
0066 
0067 
0068 %-Graphics...
0069 %=======================================================================
0070 
0071 %-Get Graphics window
0072 %-----------------------------------------------------------------------
0073 Fgraph = spm_figure('GetWin','Graphics');
0074 spm_results_ui('Clear',Fgraph,0)
0075 
0076 
0077 % Display design matrix X
0078 %-----------------------------------------------------------------------
0079 axes('Position',[0.125,0.700,0.155,0.225])
0080 if isfield(xX,'nKX')
0081     hDesMtxIm = image(xX.nKX*32+32);
0082 else
0083     hDesMtxIm = imagesc(spm_en(xX.X));
0084 end
0085 xlabel('effect')
0086 ylabel('scan')
0087 title('Design Matrix','FontSize',16)
0088 
0089 %-Setup callbacks to allow interrogation of design matrix
0090 %-----------------------------------------------------------------------
0091 set(hDesMtxIm,'UserData',struct('X',xX.X,'Xnames',{xX.Xnames}))
0092 set(hDesMtxIm,'ButtonDownFcn',[cb 'ui_report(tmp, ''SurfDesMtx_CB'')'])
0093 
0094 
0095 
0096 % Session subpartition
0097 %-----------------------------------------------------------------------
0098 axes('Position',[0.550,0.700,0.155,0.225])
0099 sX   = xX.X(Sess{s}.row,Sess{s}.col);
0100 imagesc(spm_en(sX)')
0101 set(gca,'YTick',[1:size(sX,1)])
0102 set(gca,'YTickLabel',xX.Xnames(Sess{s}.col)')
0103 title({sprintf('Session %d',s) Sess{s}.DSstr})
0104 
0105 % Collinearity
0106 %-----------------------------------------------------------------------
0107 tmp     = sqrt(sum(sX.^2));
0108 O       = sX'*sX./kron(tmp',tmp);
0109 tmp     = abs(sum(sX))<eps*1e5;
0110 bC      = kron(tmp',tmp);
0111 tmp     = 1-abs(O); tmp(logical(tril(ones(size(sX,2)),-1))) = 1;
0112 hDesO   = axes('Position',[0.750,0.700,0.155,0.225]);
0113 hDesOIm = image(tmp*64);
0114 tmp     = [1,1]'*[[0:size(sX,2)]+0.5];
0115 line('Xdata',tmp(1:end-1)','Ydata',tmp(2:end)')
0116 set(hDesO,'Box','off','TickDir','out',...
0117     'XaxisLocation','top','XTick',[],...
0118     'YaxisLocation','right','YTick',[],'YDir','reverse')
0119 axis square
0120 xlabel('design orthogonality')
0121 set(hDesOIm,...
0122     'UserData',struct('O',O,'bC',bC,'Xnames',{xX.Xnames}),...
0123     'ButtonDownFcn',[cb 'ui_report(tmp, ''SurfDesO_CB'')'])
0124 
0125 % Trial-specific regressors - time domain
0126 %-----------------------------------------------------------------------
0127 rX    = sX(:,Sess{s}.ind{i});
0128 axes('Position',[0.125,0.405,0.325,0.225])
0129 plot(Sess{s}.row,rX)
0130 xlabel('scan')
0131 ylabel('regressor[s]')
0132 title({['Regressors for ' Sess{s}.name{i}] })
0133 axis tight
0134 
0135 % Trial-specific regressors - frequency domain
0136 %-----------------------------------------------------------------------
0137 axes('Position',[0.580,0.405,0.325,0.225])
0138 gX    = abs(fft(rX)).^2;
0139 gX    = gX*diag(1./sum(gX));
0140 q     = size(gX,1);
0141 Hz    = [0:(q - 1)]/(q*xX.RT);
0142 q     = 2:fix(q/2);
0143 plot(Hz(q),gX(q,:))
0144 xlabel('Frequency (Hz)')
0145 ylabel('spectral density')
0146 title('Frequency domain')
0147 grid on
0148 axis tight
0149 
0150 
0151 % if trial (as opposed to trial x trial interaction)
0152 %-----------------------------------------------------------------------
0153 if length(Sess{s}.ons) >= i
0154 
0155     % Basis set and peristimulus sampling
0156     %---------------------------------------------------------------
0157     axes('Position',[0.125,0.110,0.325,0.225])
0158     t    = [1:size(Sess{s}.bf{i},1)]*xX.dt;
0159     pst  = Sess{s}.pst{i};
0160     plot(t,Sess{s}.bf{i},pst,0*pst,'.','MarkerSize',16)
0161     str  = sprintf('TR = %0.0fsecs',xX.RT);
0162     xlabel({'time (secs)' str sprintf('%0.0fms time bins',1000*xX.dt)})
0163     title({'Basis set and peristimulus sampling' Sess{s}.BFstr})
0164     axis tight
0165     grid on
0166 
0167     % if a paramteric variate is specified
0168     %---------------------------------------------------------------
0169     if length(Sess{s}.Pv{i})
0170 
0171         % onsets and parametric modulation
0172         %-------------------------------------------------------
0173         axes('Position',[0.580,0.110,0.325,0.225])
0174         plot(Sess{s}.ons{i},Sess{s}.Pv{i},'.','MarkerSize',8)
0175         title({'trial specific parameters' Sess{s}.Pname{i}})
0176         xlabel('time (secs}')
0177         ylabel(Sess{s}.Pname{i})
0178         grid on
0179     end
0180 end
0181 
0182 %-Pop up Graphics figure window
0183 %-----------------------------------------------------------------------
0184 figure(Fgraph);

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019