help > RE: batch & multiple between conditions contrasts
Dec 5, 2014  01:12 PM | h i
RE: batch & multiple between conditions contrasts
Alfonso.

Thanks you for reply. I have some more follow-up questions.


I successfully ran a batch script for the entire process, setup, preprocess, analysis, results. In my the script, I called conn_batch twice. I assigned everything to a BATCH (all caps) variable from setup through analysis. Then, I ran the command conn_batch(BATCH). I set up another batch (lower case) variable  and then ran the 2nd level analysis with the steps you outlined in your first replay as such for the 3 contrasts with parenthesis and not the curly brackets. In the second batch variable, in included batch(ncondition).Results.filename line specifying the Batch.filename created in the setup. So, that was my work around before I read you latest reply. The output provided the 3 different contrasts, CondA vs CondB, CondA vs CondC, CondB vs CondC.

I tried running the entire script with the curly  brackets you suggested in your most recent reply. I received an error message.

Cell contents assignment to a non-cell array object.

Error in batch_conn (line 255)
BATCH{1}.Results.between_subjects.effect_names={'AllSubjects'};


but then I realized you had a clear BATCH line before setting the BATCH{} variables. Is this the step needed to run multiple contrasts? It appears similar to my workaround where I just created a 2nd variable to assign values for my 3 contrasts and calling conn_batch a second time in my script. If so, I would also need to provide the *.mat filename (BATCH{1}.Results.filename ='name_file.mat') containing all of the preproc/setup/analysis/ information, no? 

...

A separate question about the batch process is when I don't specify a contrast at all. The manual states it will run a 2nd-level analysis for each condition. However, my output only gives one 2nd-level result for one condition. It runs the analysis 3 times, but overwrites the results file. Should I just exclude the overwrite command below? Would that provide a results output folder for each condition if I excluded that line?

BATCH.Results.between_subjects.effect_names={'AllSubjects'};
BATCH.Results.between_subjects.contrast=[1];
BATCH.Results.done=1;
BATCH.Results.overwrite='Yes';  %Excluded This line????
BATCH.Results.foldername =conn_results_folder;

Thanks again for all of your help.

h.
Originally posted by Alfonso Nieto-Castanon:
Hi h.

Sorry about this, my example was incorrect and you should instead use curly brackets { } instead of parenthesis (since the latter replicates all of the field-names of the batch structure and creates some unnecessary complications; conn_batch accepts both forms of multiple batch structures but in this example -since you are including a lot of additional functionality and not just the second-level analyses in your first batch structure- it makes more sense to use curly brackets instead so that the second batch structure is created from scratch instead of keeping the same field-names as the first batch structure), so something like:

clear BATCH;
...
BATCH{1}.Results.between_subjects.effect_names={'AllSubjects'};
BATCH{1}.Results.between_subjects.contrast=[1];
BATCH{1).Results.between_conditions.effect_names={'Cond_A','Cond_B','Cond_C'};
BATCH{1).Results.between_conditions.contrast=[1 0 -1];
...
BATCH{2}.Results.between_subjects.effect_names={'AllSubjects'};
BATCH{2}.Results.between_subjects.contrast=[1];
BATCH{2}.Results.between_conditions.effect_names={'Cond_A','Cond_B','Cond_C'};
BATCH{2}.Results.between_conditions.contrast=[1 -1 0];

...

Should work just fine (please let me know otherwise)
Best
Alfonso

Originally posted by h i:
Alfonso,

Thanks for your suggestions.

If I'm running an entire batch procedure in one script, (setup, preprocess, analysis, results), would I have to designate the BATCH file in 3 parts as below?

I ran everything as such:

BATCH.Setup= 
.
.
BATCH.Preprocess
.
.
.

But then I created the 3 part setup for the Results

BATCH(1).Results...
.
.
.
BATCH(2).Results...
.
.
.
BATCH(3).Results.

I ran the batch procedure and it successfully excuted my first contrast Cond_A vs Cond_B, but when it tried to execute the 2nd contrast, Cond_A vs Cond_C:

I received an error message stating:

Error using dir
Function is not defined for 'double' inputs.


I think the problem is the 2nd and 3rd elements of the BATCH structure array. It contains the Results field information for the remaining 2 elements, but no *.mat filename, Setup, Preprocss, or Analysis information in the respective fields. Should I just  include two additional lines in the batch script:

BATCH(2).Results.filename="name_of_conn_mat_file.mat";
BATCH(3).Results.filename="name_of_conn_mat_file.mat";

Would this solve the problem? Or do I need to include additional code?

Thanks again,

h.
Originally posted by Alfonso Nieto-Castanon:
Hi h

Yes, you can enter an array of BATCH processes simply by having the variable 'BATCH' defined as a structure array. For example:

clear BATCH;
BATCH(1).Results.between_subjects.effect_names={'AllSubjects'};
BATCH(1).Results.between_subjects.contrast=[1];
BATCH(1).Results.between_conditions.effect_names={'Cond_A','Cond_B','Cond_C'};
BATCH(1).Results.between_conditions.contrast=[1 0 -1];
...
BATCH(2).Results.between_subjects.effect_names={'AllSubjects'};
BATCH(2).Results.between_subjects.contrast=[1];
BATCH(2).Results.between_conditions.effect_names={'Cond_A','Cond_B','Cond_C'};
BATCH(2).Results.between_conditions.contrast=[1 -1 0];

...
conn_batch(BATCH);

Hope this helps
Alfonso
Originally posted by h i:
Hello,

I have question regarding multiple between conditions contrasts using a batch script, is this possible?

We have 3 conditions, A, B, and C.

Here is an example setup:

BATCH.Results.between_subjects.effect_names={'AllSubjects'};
BATCH.Results.between_subjects.contrast=[1];
BATCH.Results.between_conditions.effect_names={'Cond_A','Cond_B','Cond_C'};

For the contrast, Cond_A > Cond_C, I choose the following:

BATCH.Results.between_conditions.contrast=[1,0,-1];

This is correct, no?

If so, is there a way to set up the BATCH.Results.between_conditions.contrast file where 3 contrasts are provided as input:

Cond_A vs Cond_C   [1 0 -1]
Cond_A vs Cond_B    [1 -1 0]
Cond_B vs Cond_C  [0 1 -1]

And the output folder contains 3 subfolders, one for subfolder for each contrast?

Essentially, can we setup the batch to run similar to SPM's contrast manager where you can enter several contrasts as opposed to just one described in the conn toolbox manual?

Thank you,


h.

Threaded View

TitleAuthorDate
h i Dec 2, 2014
h i Dec 15, 2014
Alfonso Nieto-Castanon Dec 16, 2014
h i Dec 16, 2014
Alfonso Nieto-Castanon Dec 17, 2014
h i Jan 5, 2015
Alfonso Nieto-Castanon Dec 3, 2014
h i Dec 3, 2014
Alfonso Nieto-Castanon Dec 5, 2014
RE: batch & multiple between conditions contrasts
h i Dec 5, 2014
Alfonso Nieto-Castanon Dec 10, 2014