help > RE: import two session data
Jan 26, 2015  04:01 PM | Natalia Egorova - MGH
RE: import two session data
Hi,

I am trying to do analysis comparing 2 sessions preprocessed as separate SPM.mat files. I found the following discussion on this forum that seems relevant to my question but I have a few additional questions. 

The solution suggested below allows comparing 2 sessions in all subjects. However, I have two groups of subjects and would like to include the comparison of 2 sessions between the two groups. Would you please advise on how to set up the 2nd level results analysis. 

Thank you in advance,
Natalia 
 

Originally posted by Alfonso Nieto-Castanon:

I see what you mean, yes, typically you would have had one single SPM.mat file per subject (and each SPM.mat file would have defined two sessions worth of data), this would have made the setup/definition a bit simpler.

In any way, there is a work-around for the case when you have defined your sessions in separate SPM.mat files (two SPM.mat files per subjects, each having a single session, instead of one SPM.mat file per subject, each having two sessions). The trick would be to import all of the individual SPM.mat files as if they correspond to different subjects (so for example if you have two session for 10 subjects, you would enter "20" as the number of subjects, and then select the 20 SPM.mat files -the order of selection is important, for this example I will assume you select first the 10 SPM.mat files for the first session, and then the 10 SPM.mat files for the second session). Then you would run the normal analyses (through the setup, preprocessing, and first-level analysis tabs) as if you actually had 20 subjects.

Once you are done, and in order to be able to perform a paired t-test (treating some subset of subjects as 'repeated measures') you need to define a few new second-level covariates (one for each session, plus one for each subject). The simplest way to do this is using batch commands, so simply go to the Matlab command window and copy and paste the following (change first the number 10 to your actual number of original subjects):

 n=10;
 X=[kron(eye(2),ones(n,1)),kron(ones(2,1),eye(n))];
 clear batch; 
 batch.Setup.subjects.effect_names=[{'Session1'},{'Session2'},arrayfun(@(n)sprintf('within%d',n),1:n,'uni',0)];
 batch.Setup.subjects.effects=num2cell(X,1);
 conn_batch(batch);

Then in the conn gui go to the 'Setup->Covariates->Second-level' and confirm that you have now 12 (your number of subjects+2) new covariates, named 'Session1', 'Session2', 'within1','within2',...'within10'. The first two effects correspond to your individual sessions effects (across all subjects), and the 'within*' effects correspond to the within-subject effects (one per subject). You can then click 'save' on the 'setup' tab to save these newly defined covariates for future reference. 

And that's it. To run your paired t-test (comparing the connectivity values between the two sessions) you would go to the 'Second-level results' tab, in the 'between-subject effects' list select all of your new covariates (12), and in the 'between-subjects contrast' field enter [1 -1 zeros(1,10)] (again change '10' here with the actual number of subjects in your study), and that would perform a paired t-test on your connectivity data comparing the two sessions within subjects (first session minus second session; change the +-1 signs for the opposite effect). 

Hope this helps
Alfonso

Threaded View

TitleAuthorDate
Mengyu Tian Nov 30, 2013
Alfonso Nieto-Castanon Nov 30, 2013
Mengyu Tian Dec 2, 2013
Laura Case Oct 6, 2015
Alfonso Nieto-Castanon Dec 2, 2013
RE: import two session data
Natalia Egorova Jan 26, 2015
Alfonso Nieto-Castanon Jan 27, 2015
Natalia Egorova Jan 28, 2015