Home > marsbar > @mardo_2 > 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.22 Karl Friston 03/02/21

 $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.22 Karl Friston 03/02/21
0007 %
0008 % $Id$
0009 
0010 SPM = des_struct(D);
0011 Sess  = SPM.Sess;
0012 
0013 % Do not proceed unless there are trials specified
0014 %-----------------------------------------------------------------------
0015 for j = 1:length(Sess)
0016     if ~length(Sess(j).U)
0017         spm('alert*','User-specifed regressors only!',mfilename,sqrt(-1));
0018         return
0019     end
0020 end
0021 
0022 %-Defaults: Setup GUI if not called by spm_DesRep (with s and i)
0023 %-----------------------------------------------------------------------
0024 if nargin < 3
0025     s = 1;
0026     i = 1;
0027 
0028     %-Get Interactive window and delete any previous DesRepUI menu
0029     %---------------------------------------------------------------
0030     Finter = spm_figure('GetWin','Interactive');
0031     delete(findobj(get(Finter,'Children'),'flat','Tag','DesRepUI'))
0032 
0033     %-Create menu
0034     %---------------------------------------------------------------
0035     hC     = uimenu(Finter,'Label','Explore fMRI design',...
0036         'Separator','on',...
0037         'Tag','DesRepUI',...
0038         'UserData',D,...
0039         'HandleVisibility','on');
0040     for j = 1:length(Sess)
0041         h     = uimenu(hC,'Label',sprintf('Session %.0f ',j),...
0042             'HandleVisibility','off');
0043         for k = 1:length(Sess(j).Fc)
0044             cb = ['tmp = get(get(gcbo,''UserData''),',...
0045                              '''UserData''); ',...
0046                 sprintf(['ui_report_fmri(',...
0047                     'tmp,%d,%d);'],j,k)];
0048             uimenu(h,'Label',Sess(j).Fc(k).name,...
0049                              'CallBack',cb,...
0050                              'UserData',hC,...
0051                              'HandleVisibility','off')
0052         end
0053     end
0054 end
0055 
0056 
0057 %-Graphics...
0058 %=======================================================================
0059 
0060 %-Get Graphics window
0061 %-----------------------------------------------------------------------
0062 Fgraph = spm_figure('GetWin','Graphics');
0063 spm_results_ui('Clear',Fgraph,0)
0064 
0065 
0066 % Trial-specific regressors - time domain
0067 %-----------------------------------------------------------------------
0068 sX    = SPM.xX.X(Sess(s).row,Sess(s).col);
0069 rX    = sX(:,Sess(s).Fc(i).i);
0070 subplot(2,2,1)
0071 plot(Sess(s).row,rX)
0072 xlabel('scan')
0073 ylabel('regressor[s]')
0074 title({'Time domain',['regressors for ' Sess(s).Fc(i).name]})
0075 grid on
0076 axis tight
0077 
0078 % Trial-specific regressors - frequency domain
0079 %-----------------------------------------------------------------------
0080 subplot(2,2,2)
0081 gX    = abs(fft(rX)).^2;
0082 gX    = gX*diag(1./sum(gX));
0083 q     = size(gX,1);
0084 Hz    = [0:(q - 1)]/(q*SPM.xY.RT);
0085 q     = 2:fix(q/2);
0086 plot(Hz(q),gX(q,:))
0087 patch([0 1 1 0]/128,[0 0 1 1]*max(max(gX)),[1 1 1]*.9)
0088 xlabel('Frequency (Hz)')
0089 ylabel('relative spectral density')
0090 title({'Frequency domain','128 second High-pass filter'})
0091 grid on
0092 axis tight
0093 
0094 
0095 % if trial (as opposed to trial x trial interaction)
0096 %-----------------------------------------------------------------------
0097 if length(Sess(s).U) >= i
0098 
0099     % Basis set and peristimulus sampling
0100     %---------------------------------------------------------------
0101     subplot(2,2,3)
0102     dt   = Sess(s).U(i).dt;
0103     RT   = SPM.xY.RT;
0104     t    = [1:size(SPM.xBF.bf,1)]*dt;
0105     pst  = Sess(s).U(i).pst;
0106     plot(t,SPM.xBF.bf,pst,0*pst,'.','MarkerSize',16)
0107     str  = sprintf('TR = %0.2fsecs',RT);
0108     xlabel({'time (secs)' str sprintf('%0.0fms time bins',1000*dt)})
0109     title({'Basis set and peristimulus sampling' SPM.xBF.name})
0110     axis tight
0111     grid on
0112 
0113     % if a paramteric variate is specified
0114     %---------------------------------------------------------------
0115     for p = 1:length(Sess(s).U(i).P)
0116 
0117         if Sess(s).U(i).P(p).h
0118 
0119         % onsets and parametric modulation
0120         %-------------------------------------------------------
0121         subplot(2,2,4)
0122         ons = Sess(s).U(i).ons;
0123         plot(ons,Sess(s).U(i).P(p).P,'.','MarkerSize',8)
0124         xlabel('time {secs}')
0125         title('parameters')
0126         grid on
0127         hold on
0128 
0129         end
0130     end
0131 end
0132 
0133 %-Pop up Graphics figure window
0134 %-----------------------------------------------------------------------
0135 figure(Fgraph);

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