All,
Apologies if this is obvious, but I have checked the documentation
and forum but have not found a clear answer.
I would appreciate being able to run this using script in order to
batch different analyses. This is the only one i can get to run,
but still produces errors on the size of C not being 2D.
If there is example script code to run a glm comparing two unpaired groups while adjusting for covariates, that would be very welcome.
%%
n_perm=1000;
age = %continuous but demeaned
sex %coded 0 and 1
group = % 1 = Group, 0 = Control
X = [ones(size(group)) group age sex ];
C1= [0 1 0 0]; % Group over Control
C2= [0 1 0 0]; % Control over Group
%%
global NBS
NBS=struct()
NBS.GLM.perms=n_perm;
NBS.GLM.X=X_w120;
NBS.GLM.y=C_w120;
NBS.GLM.contrast=C1;
NBS.GLM.test='ttest';
NBSglm(NBS.GLM)
NBS_1=NBS %stores NBS result
Check out the example in the header of the script NBSglm.m
It is possible to run as a script to facilitate batch processing with the GUI.
Originally posted by jtanne98:
All,
Apologies if this is obvious, but I have checked the documentation and forum but have not found a clear answer.
I would appreciate being able to run this using script in order to batch different analyses. This is the only one i can get to run, but still produces errors on the size of C not being 2D.
If there is example script code to run a glm comparing two unpaired groups while adjusting for covariates, that would be very welcome.
%%
n_perm=1000;
age = %continuous but demeaned
sex %coded 0 and 1
group = % 1 = Group, 0 = Control
X = [ones(size(group)) group age sex ];
C1= [0 1 0 0]; % Group over Control
C2= [0 1 0 0]; % Control over Group
%%
global NBS
NBS=struct()
NBS.GLM.perms=n_perm;
NBS.GLM.X=X_w120;
NBS.GLM.y=C_w120;
NBS.GLM.contrast=C1;
NBS.GLM.test='ttest';
NBSglm(NBS.GLM)
NBS_1=NBS %stores NBS result
Thank you!
I tried that with the below code and generated an error. Should the
connectivity matrix be NxNxM where N is number of nodes and M is
number of subjects?
GLM.perms=1000;
GLM.X =X_use; % nsubjx4
GLM.y = C_use; % nnode x nnode x
nsubj
GLM.contrast =contrast_use; %[ 0 1 0
0]
GLM.test =
'ttest';
Test_Stat=NBSglm(GLM)
But received the following error
Error using \
Arguments must be 2-D, or at least one argument must be scalar. Use
LDIVIDE (.) for elementwise left divide or use PAGEMLDIVIDE to
apply left matrix division
to the pages of N-D arrays.
Error in NBSglm (line 88)
b=GLM.X(:,ind_nuisance)\GLM.y;
An example dataset is provided. I recommend getting the example dataset running and then evaluating how your dataset differs from the example dataset.
Best,
Andrew
Originally posted by jtanne98:
Thank you!
I tried that with the below code and generated an error. Should the connectivity matrix be NxNxM where N is number of nodes and M is number of subjects?
GLM.perms=1000;
GLM.X =X_use; % nsubjx4
GLM.y = C_use; % nnode x nnode x nsubj
GLM.contrast =contrast_use; %[ 0 1 0 0]
GLM.test = 'ttest';
Test_Stat=NBSglm(GLM)
But received the following error
Error using \
Arguments must be 2-D, or at least one argument must be scalar. Use LDIVIDE (.) for elementwise left divide or use PAGEMLDIVIDE to apply left matrix division
to the pages of N-D arrays.
Error in NBSglm (line 88)
b=GLM.X(:,ind_nuisance)\GLM.y;
Thank you for the reminder about the example dataset. I worked
with it and can get it running with the same results as the
GUI.
For anyone else reading this in the future:
Ensure that GLM.y is an [n X M] structure where M is the
number of dependent variables for the GLM (which would be the
number of unique edges in your correlation matrix). I
believe the attached code and .mat files illustrate this
clearly. I used the Schizophrenia example data with randomly
generated ages and sex variables to illustrate it.
While no significant networks result, I am just using this
as an example for scripting a GLM in NBS.
