help > block-design onsets/durations
Showing 1-5 of 5 posts
Display:
Results per page:
Aug 10, 2015  01:08 PM | Daniel Yang
block-design onsets/durations
Dear CONN developers,

I am using conn15.d and have 48 subjects. It is a bit tedious when I need to enter the onsets/durations manually for each subject and each condition.
Is it possible to copy/paste into the conn15.d interface? Or into the .mat file directly?

Alternatively, are there more BATCH examples I can find somewhere?

Many thanks!
Daniel Yang
Aug 10, 2015  06:08 PM | Alfonso Nieto-Castanon - Boston University
RE: block-design onsets/durations
Dear Daniel,

There are several ways to minimize the "tediousness" of this task:

1) using the GUI. if many or all of your subjects share the same presentation order you can simply select all of those subjects simultaneously in the 'subjects' list and then enter the onset/duration information just once (and that will update simultaneously all of those subjects condition info)

2) using Project.Import. if you have already input this information in SPM (i.e. created first-level SPM.mat files containing your design info) you may use Projects.Import to load all those SPM.mat files (typically one SPM.mat file per subject or one SPMP.mat per subject and session) and CONN will read the condition names/onsets/durations from them (it will also read from these files the source of functional data, number of sessions per subject, acquisition TR, and any first-level covariates that you may have entered into those first-level design files). 

3) using batch scripts. if you are familiar with Matlab you may create a simple variable containing all of your condition onsets/durations and then load that into your CONN project using conn_batch. For example, if you have your project loaded in the CONN gui, and you have in Matlab two variables containing the onset/duration values for each condition/subject/session (i.e. onsets{ncond}{nsub}{nses} is a vector containing the onset times (in seconds) for every condition 'ncond', subject 'nsub' and session 'nses'), you could then simply use:

 clear batch;
 batch.Setup.conditions.names = {'taskA', 'taskB'};
 batch.Setup.conditions.onsets = onsets;
 batch.Setup.conditions.durations = durations;
 conn_batch(batch);

to load that information into your currently-open CONN project. 

Hope this helps


Originally posted by Daniel Yang:
Dear CONN developers,

I am using conn15.d and have 48 subjects. It is a bit tedious when I need to enter the onsets/durations manually for each subject and each condition.
Is it possible to copy/paste into the conn15.d interface? Or into the .mat file directly?

Alternatively, are there more BATCH examples I can find somewhere?

Many thanks!
Daniel Yang
Nov 11, 2019  10:11 PM | Sahil Bajaj
RE: block-design onsets/durations
Hi experts,

I am using 3rd option here and I defined my condition names, onsets and durations for 4 conditions for 5 subjects as following:

batch.Setup.conditions.names
ans =
4×5 cell array
{'Fdb_Rew'} {'Fdb_Rew'} {'Fdb_Rew'} {'Fdb_Rew'} {'Fdb_Rew'}
{'Fdb_Pun'} {'Fdb_Pun'} {'Fdb_Pun'} {'Fdb_Pun'} {'Fdb_Pun'}
{'Fdb_App'} {'Fdb_App'} {'Fdb_App'} {'Fdb_App'} {'Fdb_App'}
{'Fdb_Avo'} {'Fdb_Avo'} {'Fdb_Avo'} {'Fdb_Avo'} {'Fdb_Avo'}

>> batch.Setup.conditions.onsets
ans =
4×5 cell array
{1×42 double} {1×50 double} {1×44 double} {1×19 double} {1×16 double}
{1×15 double} {1×33 double} {1×16 double} {1×11 double} {1×20 double}
{1×57 double} {1×83 double} {1×60 double} {1×30 double} {1×36 double}
{1×51 double} {1×25 double} {1×48 double} {1×78 double} {1×72 double}

>> batch.Setup.conditions.durations
ans =
4×5 cell array
{[1516]} {[1516]} {[1516]} {[1516]} {[1516]}
{[1516]} {[1516]} {[1516]} {[1516]} {[1516]}
{[1516]} {[1516]} {[1516]} {[1516]} {[1516]}
{[1516]} {[1516]} {[1516]} {[1516]} {[1516]}

After I try to load this batch in conn as conn_batch(batch);

I get following error:
Brace indexing is not supported for variables of this type.

Error in conn_batch (line 1013)
CONN_x.Setup.conditions.values{nsub}{nl0+nconditions}{nses}={batch.Setup.conditions.onsets{nconditions}{isub}{nses},batch.Setup.conditions.durations{nconditions}{isub}{nses}};

Please have a look at the attached screen shot.

I would really appreciate your helping in fixing this error so that I can load the above conditions data to my existing con project.

Thanks
Sahil
Nov 12, 2019  02:11 AM | Alfonso Nieto-Castanon - Boston University
RE: block-design onsets/durations
Hi Sahil,

conditions.names should only contain the names of your 4 conditions (no need to repeat that across subjects), e.g.
batch.Setup.conditions.names={'Fdb_Rew','Fdb_Pun','Fdb_App','Fdb_Avo'};

and conditions.onsets and durations should be defined as a nested array instead of a double array, e.g.
batch.Setup.conditions.durations{ncondition}{nsubject}={[1516]};

instead of batch.Setup.conditions.durations{ncondition, nsubject}={[1516]}

Hope this helps
Alfonso
Originally posted by Sahil Bajaj:
Hi experts,

I am using 3rd option here and I defined my condition names, onsets and durations for 4 conditions for 5 subjects as following:

batch.Setup.conditions.names
ans =
4×5 cell array
{'Fdb_Rew'} {'Fdb_Rew'} {'Fdb_Rew'} {'Fdb_Rew'} {'Fdb_Rew'}
{'Fdb_Pun'} {'Fdb_Pun'} {'Fdb_Pun'} {'Fdb_Pun'} {'Fdb_Pun'}
{'Fdb_App'} {'Fdb_App'} {'Fdb_App'} {'Fdb_App'} {'Fdb_App'}
{'Fdb_Avo'} {'Fdb_Avo'} {'Fdb_Avo'} {'Fdb_Avo'} {'Fdb_Avo'}

>> batch.Setup.conditions.onsets
ans =
4×5 cell array
{1×42 double} {1×50 double} {1×44 double} {1×19 double} {1×16 double}
{1×15 double} {1×33 double} {1×16 double} {1×11 double} {1×20 double}
{1×57 double} {1×83 double} {1×60 double} {1×30 double} {1×36 double}
{1×51 double} {1×25 double} {1×48 double} {1×78 double} {1×72 double}

>> batch.Setup.conditions.durations
ans =
4×5 cell array
{[1516]} {[1516]} {[1516]} {[1516]} {[1516]}
{[1516]} {[1516]} {[1516]} {[1516]} {[1516]}
{[1516]} {[1516]} {[1516]} {[1516]} {[1516]}
{[1516]} {[1516]} {[1516]} {[1516]} {[1516]}

After I try to load this batch in conn as conn_batch(batch);

I get following error:
Brace indexing is not supported for variables of this type.

Error in conn_batch (line 1013)
CONN_x.Setup.conditions.values{nsub}{nl0+nconditions}{nses}={batch.Setup.conditions.onsets{nconditions}{isub}{nses},batch.Setup.conditions.durations{nconditions}{isub}{nses}};

Please have a look at the attached screen shot.

I would really appreciate your helping in fixing this error so that I can load the above conditions data to my existing con project.

Thanks
Sahil
Nov 12, 2019  06:11 PM | Sahil Bajaj
RE: block-design onsets/durations
Hi Alfonso,

Thanks for your reply. Yes, it's working now.

I was also wondering if there is a way to extract voxel-wise time-series from batch. I think it should work if I click 'create confound-corrected time-series' in SETUP, but I am not sure how to extract this from batch/script.

Thanks.