help > CONN scripting: specify the gPPI 1st level contrasts & 2nd level models (in a pre- post- design: 2 sessions x 2 runs)
Showing 1-3 of 3 posts
Display:
Results per page:
Jan 13, 2022  07:01 PM | Panagiotis Iliopoulos
CONN scripting: specify the gPPI 1st level contrasts & 2nd level models (in a pre- post- design: 2 sessions x 2 runs)
Hello CONN experts,

I would like to use batch scripting for a gPPI analysis on task fMRI data.

-I have 2 groups (training, control) with a pre- post- design (2 sessions x 2 runs each)
-onsets in a .mat file from 9 trial types
('first','repeats', lures_correct, 'lures_incorrect' x 2 stimuli categories, & 'scrambled' (baseline)

I want to run seed-based gPPI to check differential connectivity, specifically for the training vs control condition for certain contrasts (e.g. lures vs repeats).

I am not sure how I can define the 1st level and 2nd level contrasts in the conn.batch:

1)  to assign the variables/onsets to be used for the 1st levels contrasts -> I do this at the setup.conditions.
(right?)

But which field do I have to specify to define the 1st level contrasts (between the trial types e.g. lures vs repeats), to create 1st level gPPIs?

2) How one can define the 2nd-level contrasts to represent the 2 different sessions X 2 runs each?
i.e.,how do I point to the different sessions, runs for my intended design?


MY CODE SO FAR:
A) to define the 9 trial types onsets via the set.conditions: 
for nsub=1:NSUBJECTS
for nses=1:2
clear onsets
load(EVENTS_FILE{nses,nsub}) %loads onsets+CondNames
batch.Setup.conditions.names=CondNames;

for ncon=1:9 %size(CondNames,2) %9 cons i.e.
for nrun=1:2
batch.Setup.conditions.onsets {ncon}{nsub}{nses+nrun} =onsets{nrun,ncon} %thus nses goes to =4; (1-2=ses1(runs1-2); 3-4=ses2);
batch.Setup.conditions.durations{ncon}{nsub}{nses+nrun} =0; % session-specific conditions
end
end; end; end
*******************************************************************

B)for group-level contrasts:
%create group indicators
group_train=participants.group(participants.complete==1); %is it ==1 training?
group_control=group_train; %copy first.
group_control(group_train==1)=0;
group_control(group_train==0)=1; %code control cond with 1s (to use in the design matrix)

BATCH.Setup.done=1; %(runs the initial data extraction steps)
%DEFINE
BATCH.Setup.subjects.names={'group_train','group_control','age'};
BATCH.Setup.subjects.effects{1}=group_train;
BATCH.Setup.subjects.effects{2}=group_control;
BATCH.Setup.subjects.effects{3}=subs_age;
%between subjects
BATCH.Results.between_subjects.effect_names={'group_train','group_control','age'} %cell array of second-level effect names
BATCH.Results.between_subjects.contrast=[1 -1 0]; % % contrast vector (same size as effect_names)
%betw. conditions (within-subjects i.e.)
BATCH.Results.between_conditions.effect_names=CondNames; %cell array of condition names (as in Setup.conditions.names)
BATCH.Results.between_conditions.contrast=[0 -0.5 0.5 0 0 -0.5 0.5 0 0] %lures correct - repeats across object&scenes (9 trial types thus 9 columns)
**************************************

Any help would be very welcome! :)
Jan 17, 2022  07:01 PM | Alfonso Nieto-Castanon - Boston University
RE: CONN scripting: specify the gPPI 1st level contrasts & 2nd level models (in a pre- post- design: 2 sessions x 2 runs)
Hi Panagiotis,

Your script looks perfectly fine, just a minor observation: in your code where you have "nses+nrun" it should really read something like "2*nses+nrun-2" (so that ses1run1 = 1, ses1run2 = 2, ses2run1 = 3, and ses2run2 = 4; otherwise with your original formula ses1run1 = 2, ses1run2 = 3, ses2run1 = 3, ses2run2 = 4). In any see below as well, as this formulation assumes that you want to aggregate across both sessions and runs, which may not be exactly what you are intending to do (?)

Regarding your question (1), yes, that is perfectly fine as well, but keep in mind that CONN will compute a separate connectivity measure per condition, so if you want to be able to compare connectivity measures across different sessions (e.g. pre- vs. post-) you need to make that explicit in batch.Setup.conditions by defining instead 18 conditions (e.g. pre_first, post_first, pre_repeats, post_repeats, etc.) so that later you can compare connectivity across those 18 conditions. You could do this, for example, using instead of the above something like:

  batch.Setup.conditions.names=...
      {'pre_firstA','pre_repeatsA', 'pre_lcorrectA', 'pre_lincorrectA', 'pre_firstB','pre_repeatsB', 'pre_lcorrectB', 'pre_lincorrectB','pre_baseline', ...
       'post_firstA','post_repeatsA', 'post_lcorrectA', 'post_lincorrectA', 'post_firstB','post_repeatsB', 'post_lcorrectB', 'post_lincorrectB','post_baseline'}; 

  batch.Setup.conditions.onsets{nses,ncon}{nsub}{nrun} = onsets{nrun,ncon};
  batch.Setup.conditions.durations{nses,ncon}{nsub}{nrun} =0;

Similarly, if you wanted to be able to evaluate differences in connectivity between runs you would also need to break down the above conditions by runs in order to let CONN know that you would like it to compute separate connectivity measures per run (e.g. define 9x2x2 conditions to be able to later define any contrast across conditions-by-sessions-by-runs)

Regarding your question (2), once you have defined the separate conditions in your experimental design (each condition corresponds to an individual cell in your within-subjects design) then you can define a contrast at the 2nd-level simply by specifying the associated weights for each condition/cell

Best
Alfonso

Originally posted by Panagiotis Iliopoulos:
Hello CONN experts,

I would like to use batch scripting for a gPPI analysis on task fMRI data.

-I have 2 groups (training, control) with a pre- post- design (2 sessions x 2 runs each)
-onsets in a .mat file from 9 trial types
('first','repeats', lures_correct, 'lures_incorrect' x 2 stimuli categories, & 'scrambled' (baseline)

I want to run seed-based gPPI to check differential connectivity, specifically for the training vs control condition for certain contrasts (e.g. lures vs repeats).

I am not sure how I can define the 1st level and 2nd level contrasts in the conn.batch:

1)  to assign the variables/onsets to be used for the 1st levels contrasts -> I do this at the setup.conditions.
(right?)

But which field do I have to specify to define the 1st level contrasts (between the trial types e.g. lures vs repeats), to create 1st level gPPIs?

2) How one can define the 2nd-level contrasts to represent the 2 different sessions X 2 runs each?
i.e.,how do I point to the different sessions, runs for my intended design?


MY CODE SO FAR:
A) to define the 9 trial types onsets via the set.conditions: 
for nsub=1:NSUBJECTS
for nses=1:2
clear onsets
load(EVENTS_FILE{nses,nsub}) %loads onsets+CondNames
batch.Setup.conditions.names=CondNames;

for ncon=1:9 %size(CondNames,2) %9 cons i.e.
for nrun=1:2
batch.Setup.conditions.onsets {ncon}{nsub}{nses+nrun} =onsets{nrun,ncon} %thus nses goes to =4; (1-2=ses1(runs1-2); 3-4=ses2);
batch.Setup.conditions.durations{ncon}{nsub}{nses+nrun} =0; % session-specific conditions
end
end; end; end
*******************************************************************

B)for group-level contrasts:
%create group indicators
group_train=participants.group(participants.complete==1); %is it ==1 training?
group_control=group_train; %copy first.
group_control(group_train==1)=0;
group_control(group_train==0)=1; %code control cond with 1s (to use in the design matrix)

BATCH.Setup.done=1; %(runs the initial data extraction steps)
%DEFINE
BATCH.Setup.subjects.names={'group_train','group_control','age'};
BATCH.Setup.subjects.effects{1}=group_train;
BATCH.Setup.subjects.effects{2}=group_control;
BATCH.Setup.subjects.effects{3}=subs_age;
%between subjects
BATCH.Results.between_subjects.effect_names={'group_train','group_control','age'} %cell array of second-level effect names
BATCH.Results.between_subjects.contrast=[1 -1 0]; % % contrast vector (same size as effect_names)
%betw. conditions (within-subjects i.e.)
BATCH.Results.between_conditions.effect_names=CondNames; %cell array of condition names (as in Setup.conditions.names)
BATCH.Results.between_conditions.contrast=[0 -0.5 0.5 0 0 -0.5 0.5 0 0] %lures correct - repeats across object&scenes (9 trial types thus 9 columns)
**************************************

Any help would be very welcome! :)
Jan 19, 2022  01:01 PM | Panagiotis Iliopoulos
RE: CONN scripting: specify the gPPI 1st level contrasts & 2nd level models (in a pre- post- design: 2 sessions x 2 runs)
Dear Alfonso,

Thank you very much.

-code: good catch! (indexing was erroneous)

"... this formulation assumes that you want to aggregate across both sessions and runs, which may not be exactly what you are intending to do (?)"

You mean that I shouldn't aggreagate at the 1st level both the sessions and runs?
-Probably instead I should run the code twice, once for each time point/session. Right?

I plan to do this and then represent the 2 different time points(sessions i.e.) at the 2nd level, e.g. by transfering the gPPI beta values results to SPM.
********************************************************************************************

1) I see that all conds combinations have to be specified at the Setup.conditions.

-Do I understand correctly that in this way 18 regressors will be created at the 1st level (see 18 conds)?

Would it be better to analyze each session separately and get 9 conds/regressors at the 1st level and account for the different sessions at the 2nd level?

Having many 1st level regressors could mess up my stat model (consuming degrees of freedom i.e.).

Runs: I do not plan to compare run1 vs run2 but rather account for them.

A) I am thinking to run the code for each session separately and just add 2 additional regressors for the 2 runs in each session (i.e. run1, run2 regressor using the setup.cond)
--> then represent sessions at the 2nd level in SPM.

Is this all making sense? or could I achieve the same with CONN (without having to add too many regressors, 18 as explained above)?


Thank you very much for your help :)