Hi Patrick, Yes. Otherwise you can look at the hyperparameters SPM.xVi.h estimated on a real dataset and use these as weights for a linear combination of the covariance components SPM.xVi.Vi. Best regards, Guillaume. On 03/02/18 21:23, Patrick Sadil wrote: > Hello Guillaume, > Ah, okay. Thanks for the clarifications (and the reference). So, to > get what they're calling /V, / I would call > > V = spm_Q(.3, n_scans); > > Best, > Patrick > > ****************************************** > % design matrix convolved with hrf. > X = SPM.xX.X; > n_scans = size(X,1); > > % assuming AR(1) process with rho = 0.3 > V = spm_Q(.3, n_scans); > > % set of contrasts (if want to detect each condition) > % no derivatives used, so each column is a beta of interest > % final column is intercept > n_contrasts = size(X,2)-1; > C = [eye(n_contrasts), zeros([n_scans,1])]; > > % frequency confounds (don't want to accidentally have events that will > ultimately be filtered away) > S = SPM.xX.K.X0; > > IPvs = eye(n_scans) - (V / (V' * V) * V' ) * (S / (S' * S) * S' ); > M = C * ((X' * V' * IPvs * V * X ) \ C' ); > > a_optimality = n_contrasts / trace(M); > d_optimality = det(M) ^ (1/n_contrasts); > > > > On Thu, Feb 1, 2018 at 7:52 AM Guillaume Flandin <[log in to unmask] > <mailto:[log in to unmask]>> wrote: > > Dear Patrick, > > I think I would keep the constant term in X. Note that K are the low > frequency confounds, not the whitening matrix. I don't think you should > use the covariance components SPM.xVi.Vi <http://SPM.xVi.Vi> but the > covariance matrix V is > only available in SPM.xVi.V after seeing data so what you can do is > impose its shape (eg use spm_Q); I see this is what they do in > Neurodesign where the assumed autocorrelation coefficient 'rho' is a > user-specified input: > https://www.biorxiv.org/content/biorxiv/early/2017/03/23/119594.full.pdf > > Best regards, > Guillaume. > > > On 20/01/18 15:51, Patrick Sadil wrote: > > I'm looking for some help in calculating the efficiency of a > design. I'm unsure about some of the components of an SPM.mat file. > If I generate an SPM structure using: > > > > SPM = spm_run_fmri_spec(matlabbatch{1}.spm.stats.fmri_design); > > > > where, matlabbatch is, say, a structure generated from entering a > design into the gui and saving the job script. Is it true that I'll > still need to whiten and detrend the design given in SPM.xX.X? So, > If I were calculating a- and d-optimality does the following look > correct? > > > > % design matrix convolved with hrf. exclude the intercept (does > this need to be done, or can I just have a contrast matrix that > excludes the final column?) > > X = SPM.xX.X(:,1:end-1); > > > > % autocorrelation to remove > > V1 = SPM.xVi.Vi <http://SPM.xVi.Vi>{1}; > > V2 = SPM.xVi.Vi <http://SPM.xVi.Vi>{2}; > > > > % set of contrasts (if want to detect each condition) > > % no derivatives used, so each column is a beta of interest > > n_contrasts = size(X,2); > > C = eye(n_contrasts); > > > > % whitening filter > > K = SPM.xX.K.X0; > > > > % detrended and whitened design > > IPvs = eye(size(K,1)) - ... > > ((V1 * inv(V1' * V1) * V1') * (V2 * inv(V2' * V2) * V2') * (K > * inv(K' * K) * K')); > > M = (X' * V' * IPvs * V * X ); > > > > a_optimality = n_contrasts / trace(M); > > d_optimality = det(C * M * C') ^ (1/n_contrasts); > > > > Thanks, > > Patrick > > > > -- > Guillaume Flandin, PhD > Wellcome Trust Centre for Neuroimaging > University College London > 12 Queen Square > London WC1N 3BG > > -- > Patrick Sadil, B.A. > Graduate Student > Department of Psychological and Brain Sciences > > Lab: http://people.umass.edu/cmap-lab/index.html > Personal: http://people.umass.edu/psadil/ > -- Guillaume Flandin, PhD Wellcome Trust Centre for Neuroimaging University College London 12 Queen Square London WC1N 3BG