Hi Peter, I am not sure why those files crashed your outlook. Please accept my apologies for that. I will use different mechanism to share files in future. Perfect, changing from structure to cell array resolved that issue. Thanks for that. Lastly, I performed following steps: M = struct(); M.alpha = 1; M.beta = 16; M.hE = 0; M.hC = 1/16; M.Q = 'single'; M.X = [1 1 1 -1]; PEB3 = spm_dcm_peb({PEB_A; PEB_B}, M); where my PEB_A is: PEB_A = struct with fields: Snames: {26×1 cell} Pnames: {16×1 cell} Pind: [16×1 double] Xnames: {'Covariate 1' 'Covariate 2' 'Covariate 3' 'Covariate 4' 'Covariate 5' 'Covariate 6'} M: [1×1 struct] Ep: [16×6 double] Eh: -6.2590 Ch: 0.0041 Cp: [96×96 double] Ce: [16×16 double] F: -2.5418e+04 and PEB_B is: struct with fields: Snames: {26×1 cell} Pnames: {16×1 cell} Pind: [16×1 double] Xnames: {'Covariate 1' 'Covariate 2' 'Covariate 3' 'Covariate 4' 'Covariate 5' 'Covariate 6'} M: [1×1 struct] Ep: [16×6 double] Eh: -6.2465 Ch: 0.0041 Cp: [96×96 double] Ce: [16×16 double] F: -728.5970 Here 'Covariate 1' and 'Covariate 2' for PEB_A and PEB_B represent means over pre- and post-treatment conditions and difference between pre- and post-treatment conditions for group A and group B. Covariates 3 to 6 are other covariates like age, sex, amount of dose and time since stroke. My PEB3 looks like: PEB3 = struct with fields: Snames: {2×1 cell} Pnames: {1×96 cell} Pind: [96×1 double] Xnames: {'Covariate 1' 'Covariate 2'} M: [1×1 struct] Ep: [96×2 double] Eh: 0.1460 Ch: 0.0518 Cp: [192×192 double] Ce: [96×96 double] F: -2.6137e+04 Then I ran: BMA = spm_dcm_peb_bmc(PEB3(1)); spm_dcm_peb_review(BMA,GCM_updated) As you notice, here I am getting just 2 covariates rather than 4 that we discussed in our previous conversation. I am not sure what I am doing wrong here, or if something is missing, or I am misunderstanding something. Thanks. On Wed, Mar 27, 2019 at 3:30 AM Zeidman, Peter <[log in to unmask]> wrote: > Dear Martin > > This turned out to be a simple problem – the function spm_dcm_peb expects > a cell array of DCMs or PEBs. However, you gave it a structure array. So, > simply change: > > > > PEB3 = spm_dcm_peb([PEB_A; PEB_B], M); > > > > To: > > > > PEB3 = spm_dcm_peb({PEB_A; PEB_B}, M); > > > > And it will work fine. > > > > Best > > Peter > > PS the email you sent me with the files crashes my Outlook every time I > click on it! Perhaps it would be better to share files through some other > mechanism. > > > > *From:* Zeidman, Peter > *Sent:* 21 March 2019 09:15 > *To:* 'Martin Juneja' <[log in to unmask]> > *Cc:* [log in to unmask] > *Subject:* RE: [SPM] Fwd: Defining covariates in DCM M.X matrix > > > > Dear Martin > > (1). Following your suggestion to model 2x2 design, after I performed > following steps: > > > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > load PEB_G1.mat % from pre-post comparison for group 1 > > PEB_G1 = PEB; > > load PEB_G2.mat % from pre-post comparison for group 2 > > PEB_G2 = PEB; > > > > N = 2; > > M = struct(); > > M.alpha = 1; > > M.beta = 16; > > M.hE = 0; > > M.hC = 1/16; > > M.Q = 'single'; > > > > M.X = [1 1 > > 1 -1]; > > > > fields = {'A'}; > > PEB3 = spm_dcm_peb([PEB_G1; PEB_G2], M,fields); > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > > > I am getting following error: > > Undefined function or variable 'pC'. > > > > Error in spm_find_pC (line 52) > > if isstruct(pC) > > > > Error in spm_dcm_peb (line 144) > > q = spm_find_pC(DCM,field); % parameter indices > > > > Error in A_Run_large_DCM_NextLevel (line 21) > > PEB3 = spm_dcm_peb([PEB_A; PEB_B], M,fields); > > > > Does it resolve it if you remove the ‘fields’ options from the > specification of PEB3? Otherwise, please can I check whether you are using > the latest release of SPM12, released 14ht November 2018? There were some > fixes in there for the PEB-of-PEBs approach. > https://www.fil.ion.ucl.ac.uk/spm/software/spm12/ > > > > (2). Also, as you mentioned that * "**in this final model, you’ll have > parameters quantifying the mean connectivity across all subjects, the group > difference in mean connectivity, the mean effect of treatment, and the > group difference in the effect of treatment (i.e. the interaction)", *I > was wondering how we are getting all of these i.e. mean connectivity > across all subjects, the group difference in mean connectivity, the mean > effect of treatment, and the group difference in the effect of treatment > (i.e. the interaction), because M.X is just [1 1 1-1], which should give me > only first two things (i.e., mean connectivity across all subjects and the > group difference in mean connectivity only), out of four you mentioned. I > apologize if I did not understand this correctly. > > > > I would really appreciate any additional clarification on these two issues. > > > > Excellent question. To recap, the vector of second level parameters that > your third level GLM is trying to explain are: > > > > Group 1 Mean > > Group 1 Treatment > > Group 2 Mean > > Group 2 Treatment > > > > There are two parts to the level design matrix. You specify the > between-groups design matrix Xb: > > > > 1 1 > > 1 -1 > > > > There’s also a within-groups design matrix, specified automatically by the > software: Xw = eye(n) where n is the number of effects being brought up > from the level below (n=2 in this example – mean and treatment): > > > > 1 0 > > 0 1 > > > > The actual design matrix is calculated by: X = kron(Xb, Xw): > > > > 1 0 1 0 > > 0 1 0 1 > > 1 0 -1 0 > > 0 1 0 -1 > > > > As you can see, the first regressor (column) is the mean of the group > means, the second regressor is the mean of the treatment effects, the third > regressor is the difference between group means and the fourth regressor is > the difference in treatment effects between groups. You’ll have one > parameter estimate for each of these four columns. > > > > For more about how the design matrices are specified, please see part 2 of > the tutorial paper at https://github.com/pzeidman/dcm-peb-example . > > > > Best > > Peter > > > > Thank you so much once again. > > > > On Tue, Mar 19, 2019 at 3:59 AM Zeidman, Peter <[log in to unmask]> > wrote: > > Dear Martin > > On second thoughts, an alternative and potentially more elegant way to > model your between-subjects 2x2 design would be to have a 3-level PEB > model: DCMs at the first level, group at the second level and treatment at > the third level. This would properly account for differences in > between-subject variability between groups. > > > > For example, say you have DCMs for each group: GCM1 and GCM2. At the > second level, model them using: > > > > PEB2a = spm_dcm_peb(GCM1, M1); > > PEB2b = spm_dcm_peb(GCM2, M2); > > > > Where the design matrix for first group, M1.X, has regressors for mean, > treatment (pre vs post) and covariates such as age (mean centred within > this group). Similarly for the second group. Then, take the mean > connectivity and effect of treatment from each group up to the third level: > > > > PEB3 = spm_dcm_peb([PEB2a; PEB2b], M3, fields); > > > > Where the design matrix M3 has regressors for the mean across both groups > and the difference between groups: > > > > M3.X = [1 1 > > 1 -1]; > > > > So, in this final model, you’ll have parameters quantifying the mean > connectivity across all subjects, the group difference in mean > connectivity, the mean effect of treatment, and the group difference in the > effect of treatment (i.e. the interaction). You can use the ‘fields’ option > in PEB3 to limit which parameters go up to the third level (i.e. no need > for uninteresting covariates such as age). > > > > I hope that helps > > Peter > > > > *From:* Zeidman, Peter > *Sent:* 19 March 2019 10:01 > *To:* 'Martin Juneja' <[log in to unmask]>; [log in to unmask] > *Subject:* RE: [SPM] Fwd: Defining covariates in DCM M.X matrix > > > > Dear Martin > > You have a 2x2 factorial design at the between-subjects level: treatment > (pre vs post) and group (subject set). So to fully encode this in your GLM, > you could model the mean (expected by the PEB system to the first column), > the two main effects (treatment and group) and their interaction. You could > code the main effects as 1s and -1s as you suggest, making sure you > mean-correct them, and to generate the interaction regressor you > element-wise multiply the mean-corrected main effect regressors. > > > > I am interested in determining whether its treatment 'A' which improves > effective connectivity within a network for set 1, or its treatment 'B' > which improves effective connectivity within a network for set 2. > > > > Those are the simple effects – an effect of treatment in group 1 and an > effect of treatment in group 2. If that’s all you want, you could just > include these in the design matrix as you suggest (and mean correct them) > but it doesn’t fully cover your factorial design without the interaction. > > > > *Q1:* Whether I mean center 'age', 'sex', 'amount of dose' and 'time > since stroke' from overall sample i.e., from both conditions together, or > calculate mean centered values separately for treatments A and B. > > > > From the overall sample (for age and sex). Just include non-zero values > for dose and time since stroke in the patient group. > > > > *Q2:* For M.X matrix, should I use mean centered 'dose used' values only > for post-treatment conditions and put 0's for pre-treatment condition, > because there was no dose used during pre-treatment condition? Correct? > > *Q3:* For M.X matrix, should I use mean centered 'time since stroke' only > for post-treatment condition and put 0's for pre-treatment condition? Or it > will be same values for pre- and post-treatment condition because 'time > since stroke' values are same for pre- and post conditions. > > > > Yes but note, for every covariate you add, there’s a new parameter added > for every DCM connection. So you’ll be using up your degrees of freedom for > each new covariate. You might want to keep the number of covariates at a > minimum. > > > > *Q4: *If I want to compare connectivity for controls with post-treatment > condition, then again should I mean center 'age' and 'sex' from overall > sample or separately for controls and patients? > > > > I think overall should be fine. > > > > Also, should I include 'time since stroke' and 'amount of dose' used also > as covariates, which will of course be zeros for controls. > > Or there is no need to include 'time since stroke' and 'amount of dose' as > covariates because I am comparing controls with patients. If so, I doubt > then how to incorporate the variance as the 'amount of dose used' and 'time > since stroke' values differ between treatments A and B. > > > > See above comments – yes you can model them, but there could be a big cost > in terms of model complexity. > > > > Best > > Peter > > > >