help > RE: import two session data
Dec 2, 2013  03:12 AM | Alfonso Nieto-Castanon - Boston University
RE: import two session data
Hi Mengyu Tian,

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


Originally posted by Mengyu Tian:
Hi Alfonso,


I have tried your way to import data but I have two SPM.mat (because I did the first level analysis separately for each run).When I setup for 2 session and import the second run ,it overwrite the first one's functional image.And 2 session I set before turned to 1 session again. So I can't import two SPM.mat in one project.

Is it a appropratiate way to directly do the paired t test between two condition using the first level result(the fisher's z score) If I only want to know whether the difference of the connectivity of two ROI between two condition is significant ?

Thank you very much for your help!

Mengyu Tian




Originally posted by Alfonso Nieto-Castanon:
Hi

It is perfectly possible and acceptable to compare two conditions defined in two separate runs/sessions. To do that you typically simply associate (in the Setup->Conditions tab) each condition with one specific session (and leave the 'onsets'/'durations' fields for the rest of the sessions empty). In your case it will be simpler to simply/directly import the SPM.mat files into the conn toolbox and that will import all of your specific conditions and block orderings so you do not have to retype those values. To do this click on the Setup->Import button, then select the SPM.mat files (one per subject), and click on the 'Done' button, and the toolbox will import all the relevant information from there.

Let me know if this helps and/or if you run into any issues
Best
Alfonso


Originally posted by Mengyu Tian:
Hi experts,
I have a problem in import data from SPM.mat. I have two session for each subject and each session have several conditions. I want to compare one condition in first session with another condition in second session. Because I random the block order(onsets of each condition differ between subjects), it will take a long time for enter the onset for each subject manually. I have already do the first level analysis in SPM, so I want  to import the SPM.mat .

But I can not define two sesseion in conn GUI and can not find the batch in conn batch manual. and I want to know is that acceptable to compare two condition in two separate run directly?

Appreciate any help, Thanks a lot for your tim

Mengyu Tian

Threaded View

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