Hi Alfonso,
Thank you very much for your help! Sorry for the late reply, at the time I found a twisted way to make it work and forgot I had posted this here.
Now I am working with the newest version 20.b, and I see that this has been solved there!
Thank you for your time!
Best,
Herberto
[i]Originally posted by Alfonso Nieto-Castanon:[/i][quote][color=#000000]Hi Herberto,[/color]
[color=#000000]That is a good point. If you could please try the attached patch, that should allow you to define that info more simply by: a) allowing you to simply enter a single empty array for the non-applicable 'functional_explicit' field info (e.g. when using type 2); and/or b) define the secondardataset field as a cell array of structures (instead of a vector array of structures), which allows different datasets to have different fields (so that it is no longer necessary to define empty functionals_explicit values) like in the example below:[/color]
clear batch;
[color=#000000] batch.Setup.secondarydatasets{1}=struct('functionals_type',2, 'functionals_label', 'unsmoothed volumes');[/color]
[color=#000000] batch.Setup.secondarydatasets{2}=struct('functionals_type',4, 'functionals_label', 'fmap', 'functionals_explicit',{{{{'magnitude.nii','phasediff.nii'}}}});[/color]
[color=#000000] conn_batch(batch);[/color]
[color=#000000]Best[/color]
[color=#000000]Alfonso[/color]
[color=#000000]note: this patch is for release 19c, to install it simply copy the attached file to the conn distribution folder overwriting the file with the same name there[/color]
[i]Originally posted by Herberto Dhanis:[/i][quote]Hi,
I am relatively new to CONN, and was trying to setup a batch pre-processing pipeline.
I came across something that I think might be a mistake in how conn_batch interprets the BATCH secondarydataset field that it is given.
It might also be that I am doing something wrong of course.
From the start, I want to define two secondary datasets.[list=1][*]A dataset from the unsmoothed volumes, which is of type 2[*]A dataset to hold magnitude and phase data, to create the fieldmap for later unwarping, which is of type 4[/list]
Here's the thing, functionals of type 2 (same as primary dataset but without the s) do not need to have their path detailed in the functionals_explicit field, as that is only for type 4.
When conn_batch is parsing the structure, it tries to copy the paths of the first dataset due to this (starting in line 781 of conn_batch):
if isfield(batch.Setup.secondarydatasets(nalt),'functionals_explicit')||isfield(batch.Setup.secondarydatasets(nalt),'roiextract_functionals')
[b] if isfield(batch.Setup.secondarydatasets(nalt),'functionals_explicit'),[/b]
temp=batch.Setup.secondarydatasets(nalt).functionals_explicit;
else
temp=batch.Setup.secondarydatasets(nalt).roiextract_functionals;
end
for isub=1:numel(SUBJECTS),
nsub=SUBJECTS(isub);
%CONN_x.Setup.nsessions(nsub)=length(batch.Setup.functionals_explicit{nsub});
for nses=1:CONN_x.Setup.nsessions(nsub),
if localcopy,
(…)
[b]else conn_set_functional(nsub,nses,nalt,temp{isub}{nses});[/b]
end
%[CONN_x.Setup.secondarydataset(nalt).functionals_explicit{nsub}{nses},nV]=conn_file(temp{isub}{nses});
end
The first if in bold will make your code pass to the for loop below, regardless of it's type. It will then arrive to the second line in BOLD which tries to access temp{isub}{nses}… This does not exist for a type 2 secondary dataset, and the conn_batch crashes.
I personally think that an if statement should surround the for loop, assessing the type. Which would then solve the problem by not trying to populate functionals_explicit in the CONN_x
The other way around this seems to be to still define the path for functionals_explicit of a dataset of type 2, by creating the adequate cell {nsubj}{nses} full of empty strings
Thanks for your help, I would really appreciate to know if someone has encountered a similar problem and found that something should be done differently.[/quote][/quote]
Thank you very much for your help! Sorry for the late reply, at the time I found a twisted way to make it work and forgot I had posted this here.
Now I am working with the newest version 20.b, and I see that this has been solved there!
Thank you for your time!
Best,
Herberto
[i]Originally posted by Alfonso Nieto-Castanon:[/i][quote][color=#000000]Hi Herberto,[/color]
[color=#000000]That is a good point. If you could please try the attached patch, that should allow you to define that info more simply by: a) allowing you to simply enter a single empty array for the non-applicable 'functional_explicit' field info (e.g. when using type 2); and/or b) define the secondardataset field as a cell array of structures (instead of a vector array of structures), which allows different datasets to have different fields (so that it is no longer necessary to define empty functionals_explicit values) like in the example below:[/color]
clear batch;
[color=#000000] batch.Setup.secondarydatasets{1}=struct('functionals_type',2, 'functionals_label', 'unsmoothed volumes');[/color]
[color=#000000] batch.Setup.secondarydatasets{2}=struct('functionals_type',4, 'functionals_label', 'fmap', 'functionals_explicit',{{{{'magnitude.nii','phasediff.nii'}}}});[/color]
[color=#000000] conn_batch(batch);[/color]
[color=#000000]Best[/color]
[color=#000000]Alfonso[/color]
[color=#000000]note: this patch is for release 19c, to install it simply copy the attached file to the conn distribution folder overwriting the file with the same name there[/color]
[i]Originally posted by Herberto Dhanis:[/i][quote]Hi,
I am relatively new to CONN, and was trying to setup a batch pre-processing pipeline.
I came across something that I think might be a mistake in how conn_batch interprets the BATCH secondarydataset field that it is given.
It might also be that I am doing something wrong of course.
From the start, I want to define two secondary datasets.[list=1][*]A dataset from the unsmoothed volumes, which is of type 2[*]A dataset to hold magnitude and phase data, to create the fieldmap for later unwarping, which is of type 4[/list]
Here's the thing, functionals of type 2 (same as primary dataset but without the s) do not need to have their path detailed in the functionals_explicit field, as that is only for type 4.
When conn_batch is parsing the structure, it tries to copy the paths of the first dataset due to this (starting in line 781 of conn_batch):
if isfield(batch.Setup.secondarydatasets(nalt),'functionals_explicit')||isfield(batch.Setup.secondarydatasets(nalt),'roiextract_functionals')
[b] if isfield(batch.Setup.secondarydatasets(nalt),'functionals_explicit'),[/b]
temp=batch.Setup.secondarydatasets(nalt).functionals_explicit;
else
temp=batch.Setup.secondarydatasets(nalt).roiextract_functionals;
end
for isub=1:numel(SUBJECTS),
nsub=SUBJECTS(isub);
%CONN_x.Setup.nsessions(nsub)=length(batch.Setup.functionals_explicit{nsub});
for nses=1:CONN_x.Setup.nsessions(nsub),
if localcopy,
(…)
[b]else conn_set_functional(nsub,nses,nalt,temp{isub}{nses});[/b]
end
%[CONN_x.Setup.secondarydataset(nalt).functionals_explicit{nsub}{nses},nV]=conn_file(temp{isub}{nses});
end
The first if in bold will make your code pass to the for loop below, regardless of it's type. It will then arrive to the second line in BOLD which tries to access temp{isub}{nses}… This does not exist for a type 2 secondary dataset, and the conn_batch crashes.
I personally think that an if statement should surround the for loop, assessing the type. Which would then solve the problem by not trying to populate functionals_explicit in the CONN_x
The other way around this seems to be to still define the path for functionals_explicit of a dataset of type 2, by creating the adequate cell {nsubj}{nses} full of empty strings
Thanks for your help, I would really appreciate to know if someone has encountered a similar problem and found that something should be done differently.[/quote][/quote]