help > CONN batch scripting: How to skip already-done things?
Showing 1-9 of 9 posts
Display:
Results per page:
Apr 15, 2021  05:04 PM | Karl Lerud
CONN batch scripting: How to skip already-done things?
Hi Alfonso et al. I am working on using a script to maintain a fairly large CONN project, using v 20b. I only have one preprocessing step specified: Setup.preprocessing.steps={'functional_art'}; (functional data is otherwise already preprocessed). The processing got pretty far, but errored out because of a small mistake in my Results second-level specifications. I fixed this (I think) and switched Setup.isnew, Setup.overwrite, and Denoising.overwrite to 0 thinking that it would skip the preprocessing etc. that it already did and move right to the Analysis and results, but it appears to be starting over and doing all that again. What is the correct way to skip the things it already did? Should I also set Setup.done and Denoising.done to 0? Also if I add just one or two new subjects, I want it to start at the beginning for only the new subjects. I seem to remember in the GUI this worked pretty intuitively with a pull-down that just said "Do not overwrite already-processed subjects/ROIs" or something to that effect. Thanks, 

Karl
Apr 27, 2021  04:04 PM | Karl Lerud
RE: CONN batch scripting: How to skip already-done things?
Could I bump this? My question is basically just how to skip already-processed subjects/ROIs in a CONN batch script. Thanks,

Karl
May 3, 2021  05:05 PM | Alfonso Nieto-Castanon - Boston University
RE: CONN batch scripting: How to skip already-done things?
Hi Karl,

The options are batch.Setup.overwrite, batch.Denoising.overwrite, and batch.Analysis.overwrite (set those fields to 0 when running the Setup, Denoising, or first-level analysis steps, respectively, in order to skip already-processed subject/ROIs; see all conn_batch field details in https://web.conn-toolbox.org/resources/c...)

Best
Alfonso
Originally posted by Karl Lerud:
Could I bump this? My question is basically just how to skip already-processed subjects/ROIs in a CONN batch script. Thanks,

Karl
May 12, 2021  08:05 PM | Karl Lerud
RE: CONN batch scripting: How to skip already-done things?
Thanks for the reply Alfonso. I have a project with ~95 subjects, and the only preprocessing I am using CONN for is functional_art. All other preprocessing is done before import to CONN. So I executed my script, and everything seems to run correctly to completion. Then I added 4 more subjects to the project, and simply changed Setup.isnew, Setup.overwrite, Denoising.overwrite, and Analysis.overwrite all to 0 (which were all 1 the first time around), and ran the script. This seems like the correct way to go according to what you said and the documentation. 

The first thing that happened is that it ran the art preprocessing on all 99 subjects, overwriting and redoing this for the first 95. It also correctly did the art preprocessing for the 4 new subjects, but of course I didn't need to spend all that time redoing the first 95.

Then it did the rest fairly quickly, so I think telling it not to overwrite the rest of the analysis worked. Is there a way I can tell if it only processed the 4 recent subjects, or if it re-processed everything? And at the very least, it seems like it shouldn't have to redo the art preprocessing for everyone. Is there anything I am doing wrong, and is there a way to make this work as expected? Thanks,

Karl






Originally posted by Alfonso Nieto-Castanon:
Hi Karl,

The options are batch.Setup.overwrite, batch.Denoising.overwrite, and batch.Analysis.overwrite (set those fields to 0 when running the Setup, Denoising, or first-level analysis steps, respectively, in order to skip already-processed subject/ROIs; see all conn_batch field details in https://web.conn-toolbox.org/resources/c...)

Best
Alfonso
Originally posted by Karl Lerud:
Could I bump this? My question is basically just how to skip already-processed subjects/ROIs in a CONN batch script. Thanks,

Karl
May 12, 2021  11:05 PM | Alfonso Nieto-Castanon - Boston University
RE: CONN batch scripting: How to skip already-done things?
Hi Karl,

Sorry about that, the batch.Setup.overwrite field only applies to the Setup step, similarly for the batch.Denoising.overwrite and batch.Analysis.overwrite fields. Unfortunately there is no equivalent 'overwrite' option for preprocessing, but you could either use the batch.Setup.add field to explicitly add/preprocess new subjects to an existing project, or manually select which subjects you want to preprocess/analyze using the general batch.subjects field.

In your case I believe the simplest way would have been to modify your script to only include the information about your new 4 subjects (e.g. change the contents of Setup.functionals, Setup.structurals, etc.), and then use Setup.isnew=0 and Setup.add=1 so that CONN adds this new information to your project and preprocesses only those new subjects (and then for the Setup/Denoising/First-level steps, the overwrite option would suffice so there is no need to change anything else in the scripts there) 

Hope this helps
Alfonso

Originally posted by Karl Lerud:
Thanks for the reply Alfonso. I have a project with ~95 subjects, and the only preprocessing I am using CONN for is functional_art. All other preprocessing is done before import to CONN. So I executed my script, and everything seems to run correctly to completion. Then I added 4 more subjects to the project, and simply changed Setup.isnew, Setup.overwrite, Denoising.overwrite, and Analysis.overwrite all to 0 (which were all 1 the first time around), and ran the script. This seems like the correct way to go according to what you said and the documentation. 

The first thing that happened is that it ran the art preprocessing on all 99 subjects, overwriting and redoing this for the first 95. It also correctly did the art preprocessing for the 4 new subjects, but of course I didn't need to spend all that time redoing the first 95.

Then it did the rest fairly quickly, so I think telling it not to overwrite the rest of the analysis worked. Is there a way I can tell if it only processed the 4 recent subjects, or if it re-processed everything? And at the very least, it seems like it shouldn't have to redo the art preprocessing for everyone. Is there anything I am doing wrong, and is there a way to make this work as expected? Thanks,

Karl






Originally posted by Alfonso Nieto-Castanon:
Hi Karl,

The options are batch.Setup.overwrite, batch.Denoising.overwrite, and batch.Analysis.overwrite (set those fields to 0 when running the Setup, Denoising, or first-level analysis steps, respectively, in order to skip already-processed subject/ROIs; see all conn_batch field details in https://web.conn-toolbox.org/resources/c...)

Best
Alfonso
Originally posted by Karl Lerud:
Could I bump this? My question is basically just how to skip already-processed subjects/ROIs in a CONN batch script. Thanks,

Karl
Nov 10, 2021  10:11 PM | Karl Lerud
RE: CONN batch scripting: How to skip already-done things?
Hi Alfonso, I wanted to follow up on this. I am trying to follow your advice about adding more subjects, and only preprocessing the new subjects. I have done what you suggest, also trying to follow the instructions for Setup.add in the batch documentation. In addition to what it says there, I have also set Setup.RT to only have the values for the new subjects, and also changed Setup.nsubjects to be the number of new subjects (as opposed to all in the project), hopefully that is all correct so far.

It is giving me the following error:


Index exceeds the number of array elements (6).

Error in conn_batch (line 1196)
CONN_x.Setup.l2covariates.values{nsub}{nl2covariates}=(batch.Setup.subjects.groups(nsub)==ngroup);
Error in multielectrodeCONNsetup_paper (line 331)
conn_batch(conn_x)


In this case, I am adding 6 new subjects, and that brings the total number in this project to 109. I checked, and internally to conn_batch, CONN_x.Setup.nsubjects is 109, not 6. I am not sure if that is right, or what to expect. I can provide more information or lines of code if that is necessary, hopefully this is enough information to diagnose what is going on. Thanks,

Karl




Originally posted by Alfonso Nieto-Castanon:
Hi Karl,

Sorry about that, the batch.Setup.overwrite field only applies to the Setup step, similarly for the batch.Denoising.overwrite and batch.Analysis.overwrite fields. Unfortunately there is no equivalent 'overwrite' option for preprocessing, but you could either use the batch.Setup.add field to explicitly add/preprocess new subjects to an existing project, or manually select which subjects you want to preprocess/analyze using the general batch.subjects field.

In your case I believe the simplest way would have been to modify your script to only include the information about your new 4 subjects (e.g. change the contents of Setup.functionals, Setup.structurals, etc.), and then use Setup.isnew=0 and Setup.add=1 so that CONN adds this new information to your project and preprocesses only those new subjects (and then for the Setup/Denoising/First-level steps, the overwrite option would suffice so there is no need to change anything else in the scripts there) 

Hope this helps
Alfonso

Originally posted by Karl Lerud:
Thanks for the reply Alfonso. I have a project with ~95 subjects, and the only preprocessing I am using CONN for is functional_art. All other preprocessing is done before import to CONN. So I executed my script, and everything seems to run correctly to completion. Then I added 4 more subjects to the project, and simply changed Setup.isnew, Setup.overwrite, Denoising.overwrite, and Analysis.overwrite all to 0 (which were all 1 the first time around), and ran the script. This seems like the correct way to go according to what you said and the documentation. 

The first thing that happened is that it ran the art preprocessing on all 99 subjects, overwriting and redoing this for the first 95. It also correctly did the art preprocessing for the 4 new subjects, but of course I didn't need to spend all that time redoing the first 95.

Then it did the rest fairly quickly, so I think telling it not to overwrite the rest of the analysis worked. Is there a way I can tell if it only processed the 4 recent subjects, or if it re-processed everything? And at the very least, it seems like it shouldn't have to redo the art preprocessing for everyone. Is there anything I am doing wrong, and is there a way to make this work as expected? Thanks,

Karl






Originally posted by Alfonso Nieto-Castanon:
Hi Karl,

The options are batch.Setup.overwrite, batch.Denoising.overwrite, and batch.Analysis.overwrite (set those fields to 0 when running the Setup, Denoising, or first-level analysis steps, respectively, in order to skip already-processed subject/ROIs; see all conn_batch field details in https://web.conn-toolbox.org/resources/c...)

Best
Alfonso
Originally posted by Karl Lerud:
Could I bump this? My question is basically just how to skip already-processed subjects/ROIs in a CONN batch script. Thanks,

Karl
Nov 11, 2021  12:11 AM | Alfonso Nieto-Castanon - Boston University
RE: CONN batch scripting: How to skip already-done things?
Hi Karl,

Sorry about that, and thanks for reporting this issue, that was a limitation/bug in the code where the batch fields Setup.subjects.groups and Setup.subjects.effects were not compatible with the Setup.add option.

I have fixed that in the attached patch (this patch is for release 20b, to install it copy the attached file to your conn distribution folder overwriting the file with the same name there). Please let me know if you still run into any issues

Best
Alfonso
Originally posted by Karl Lerud:
Hi Alfonso, I wanted to follow up on this. I am trying to follow your advice about adding more subjects, and only preprocessing the new subjects. I have done what you suggest, also trying to follow the instructions for Setup.add in the batch documentation. In addition to what it says there, I have also set Setup.RT to only have the values for the new subjects, and also changed Setup.nsubjects to be the number of new subjects (as opposed to all in the project), hopefully that is all correct so far.

It is giving me the following error:


Index exceeds the number of array elements (6).

Error in conn_batch (line 1196)
CONN_x.Setup.l2covariates.values{nsub}{nl2covariates}=(batch.Setup.subjects.groups(nsub)==ngroup);
Error in multielectrodeCONNsetup_paper (line 331)
conn_batch(conn_x)


In this case, I am adding 6 new subjects, and that brings the total number in this project to 109. I checked, and internally to conn_batch, CONN_x.Setup.nsubjects is 109, not 6. I am not sure if that is right, or what to expect. I can provide more information or lines of code if that is necessary, hopefully this is enough information to diagnose what is going on. Thanks,

Karl




Originally posted by Alfonso Nieto-Castanon:
Hi Karl,

Sorry about that, the batch.Setup.overwrite field only applies to the Setup step, similarly for the batch.Denoising.overwrite and batch.Analysis.overwrite fields. Unfortunately there is no equivalent 'overwrite' option for preprocessing, but you could either use the batch.Setup.add field to explicitly add/preprocess new subjects to an existing project, or manually select which subjects you want to preprocess/analyze using the general batch.subjects field.

In your case I believe the simplest way would have been to modify your script to only include the information about your new 4 subjects (e.g. change the contents of Setup.functionals, Setup.structurals, etc.), and then use Setup.isnew=0 and Setup.add=1 so that CONN adds this new information to your project and preprocesses only those new subjects (and then for the Setup/Denoising/First-level steps, the overwrite option would suffice so there is no need to change anything else in the scripts there) 

Hope this helps
Alfonso

Originally posted by Karl Lerud:
Thanks for the reply Alfonso. I have a project with ~95 subjects, and the only preprocessing I am using CONN for is functional_art. All other preprocessing is done before import to CONN. So I executed my script, and everything seems to run correctly to completion. Then I added 4 more subjects to the project, and simply changed Setup.isnew, Setup.overwrite, Denoising.overwrite, and Analysis.overwrite all to 0 (which were all 1 the first time around), and ran the script. This seems like the correct way to go according to what you said and the documentation. 

The first thing that happened is that it ran the art preprocessing on all 99 subjects, overwriting and redoing this for the first 95. It also correctly did the art preprocessing for the 4 new subjects, but of course I didn't need to spend all that time redoing the first 95.

Then it did the rest fairly quickly, so I think telling it not to overwrite the rest of the analysis worked. Is there a way I can tell if it only processed the 4 recent subjects, or if it re-processed everything? And at the very least, it seems like it shouldn't have to redo the art preprocessing for everyone. Is there anything I am doing wrong, and is there a way to make this work as expected? Thanks,

Karl






Originally posted by Alfonso Nieto-Castanon:
Hi Karl,

The options are batch.Setup.overwrite, batch.Denoising.overwrite, and batch.Analysis.overwrite (set those fields to 0 when running the Setup, Denoising, or first-level analysis steps, respectively, in order to skip already-processed subject/ROIs; see all conn_batch field details in https://web.conn-toolbox.org/resources/c...)

Best
Alfonso
Originally posted by Karl Lerud:
Could I bump this? My question is basically just how to skip already-processed subjects/ROIs in a CONN batch script. Thanks,

Karl
Attachment: conn_batch.m
Nov 11, 2021  09:11 PM | Karl Lerud
RE: CONN batch scripting: How to skip already-done things?
Thanks Alfonso. This seems to work, but shortly before it finishes, there is another error. I will paste it below, along with the last couple log lines before the error. Can you let me know how to fix this, whether you need more information, and whether this project is salvageable after this interruption?


Step 3/4: ROI-to-ROI first-level analyses
first-level data in /media/klerud/Elements/NIBE_tDCS/CONN_Karl/conn_multielectrode_paper/results/firstlevel/SBC_01
100.0% (Subject 109 Condition 2) processed 12 files

Step 4/4: Preparing second-level ROI analyses
100.0% (Subject 109 Condition 2)
saved /media/klerud/Elements/NIBE_tDCS/CONN_Karl/conn_multielectrode_paper.mat
Computing ROI-level results. Please wait...
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 0-by-0.
Error in conn_process (line 5270)
X(nsub,ncovariate)=CONN_x.Setup.l2covariates.values{nsub}{ncovariate};
Error in conn_process (line 61)
case 'results_roi', [varargout{1:nargout}]=conn_process(17,varargin{:});
Error in conn_batch (line 1768)
conn_process('results_roi');
Error in multielectrodeCONNsetup_paper (line 331)
conn_batch(conn_x)
>>


Thanks,

Karl




Originally posted by Alfonso Nieto-Castanon:
Hi Karl,

Sorry about that, and thanks for reporting this issue, that was a limitation/bug in the code where the batch fields Setup.subjects.groups and Setup.subjects.effects were not compatible with the Setup.add option.

I have fixed that in the attached patch (this patch is for release 20b, to install it copy the attached file to your conn distribution folder overwriting the file with the same name there). Please let me know if you still run into any issues

Best
Alfonso
Originally posted by Karl Lerud:
Hi Alfonso, I wanted to follow up on this. I am trying to follow your advice about adding more subjects, and only preprocessing the new subjects. I have done what you suggest, also trying to follow the instructions for Setup.add in the batch documentation. In addition to what it says there, I have also set Setup.RT to only have the values for the new subjects, and also changed Setup.nsubjects to be the number of new subjects (as opposed to all in the project), hopefully that is all correct so far.

It is giving me the following error:


Index exceeds the number of array elements (6).

Error in conn_batch (line 1196)
CONN_x.Setup.l2covariates.values{nsub}{nl2covariates}=(batch.Setup.subjects.groups(nsub)==ngroup);
Error in multielectrodeCONNsetup_paper (line 331)
conn_batch(conn_x)


In this case, I am adding 6 new subjects, and that brings the total number in this project to 109. I checked, and internally to conn_batch, CONN_x.Setup.nsubjects is 109, not 6. I am not sure if that is right, or what to expect. I can provide more information or lines of code if that is necessary, hopefully this is enough information to diagnose what is going on. Thanks,

Karl




Originally posted by Alfonso Nieto-Castanon:
Hi Karl,

Sorry about that, the batch.Setup.overwrite field only applies to the Setup step, similarly for the batch.Denoising.overwrite and batch.Analysis.overwrite fields. Unfortunately there is no equivalent 'overwrite' option for preprocessing, but you could either use the batch.Setup.add field to explicitly add/preprocess new subjects to an existing project, or manually select which subjects you want to preprocess/analyze using the general batch.subjects field.

In your case I believe the simplest way would have been to modify your script to only include the information about your new 4 subjects (e.g. change the contents of Setup.functionals, Setup.structurals, etc.), and then use Setup.isnew=0 and Setup.add=1 so that CONN adds this new information to your project and preprocesses only those new subjects (and then for the Setup/Denoising/First-level steps, the overwrite option would suffice so there is no need to change anything else in the scripts there) 

Hope this helps
Alfonso

Originally posted by Karl Lerud:
Thanks for the reply Alfonso. I have a project with ~95 subjects, and the only preprocessing I am using CONN for is functional_art. All other preprocessing is done before import to CONN. So I executed my script, and everything seems to run correctly to completion. Then I added 4 more subjects to the project, and simply changed Setup.isnew, Setup.overwrite, Denoising.overwrite, and Analysis.overwrite all to 0 (which were all 1 the first time around), and ran the script. This seems like the correct way to go according to what you said and the documentation. 

The first thing that happened is that it ran the art preprocessing on all 99 subjects, overwriting and redoing this for the first 95. It also correctly did the art preprocessing for the 4 new subjects, but of course I didn't need to spend all that time redoing the first 95.

Then it did the rest fairly quickly, so I think telling it not to overwrite the rest of the analysis worked. Is there a way I can tell if it only processed the 4 recent subjects, or if it re-processed everything? And at the very least, it seems like it shouldn't have to redo the art preprocessing for everyone. Is there anything I am doing wrong, and is there a way to make this work as expected? Thanks,

Karl






Originally posted by Alfonso Nieto-Castanon:
Hi Karl,

The options are batch.Setup.overwrite, batch.Denoising.overwrite, and batch.Analysis.overwrite (set those fields to 0 when running the Setup, Denoising, or first-level analysis steps, respectively, in order to skip already-processed subject/ROIs; see all conn_batch field details in https://web.conn-toolbox.org/resources/c...)

Best
Alfonso
Originally posted by Karl Lerud:
Could I bump this? My question is basically just how to skip already-processed subjects/ROIs in a CONN batch script. Thanks,

Karl
Apr 22, 2025  07:04 AM | vaishali
RE: CONN batch scripting: How to skip already-done things?

Greetings Alfonso and Karl!


 


I am using CONN for preprocessing of some rs-fMRI data using batch scripting in MATLAB. During the preprocessing of around 200 subjects, the process stopped due to an external interruption. Now in the gui, i am familiar that if i load the existing project, it will resume execution. How to ensure this in the batch script? I tried batch.Setup.isnew=0, along with setting overwrite and done to 0. However, the preprocessing steps began again for all subjects. 


 


Where am I going wrong? Kindly suggest a solution to this. Thanks!


 


Originally posted by Alfonso Nieto-Castanon:


Hi Karl, Sorry about that, and thanks for reporting this issue, that was a limitation/bug in the code where the batch fields Setup.subjects.groups and Setup.subjects.effects were not compatible with the Setup.add option. I have fixed that in the attached patch (this patch is for release 20b, to install it copy the attached file to your conn distribution folder overwriting the file with the same name there). Please let me know if you still run into any issues Best Alfonso Originally posted by Karl Lerud:
Hi Alfonso, I wanted to follow up on this. I am trying to follow your advice about adding more subjects, and only preprocessing the new subjects. I have done what you suggest, also trying to follow the instructions for Setup.add in the batch documentation. In addition to what it says there, I have also set Setup.RT to only have the values for the new subjects, and also changed Setup.nsubjects to be the number of new subjects (as opposed to all in the project), hopefully that is all correct so far. It is giving me the following error: Index exceeds the number of array elements (6). Error in conn_batch (line 1196) CONN_x.Setup.l2covariates.values{nsub}{nl2covariates}=(batch.Setup.subjects.groups(nsub)==ngroup); Error in multielectrodeCONNsetup_paper (line 331) conn_batch(conn_x) In this case, I am adding 6 new subjects, and that brings the total number in this project to 109. I checked, and internally to conn_batch, CONN_x.Setup.nsubjects is 109, not 6. I am not sure if that is right, or what to expect. I can provide more information or lines of code if that is necessary, hopefully this is enough information to diagnose what is going on. Thanks, Karl Originally posted by Alfonso Nieto-Castanon:
Hi Karl, Sorry about that, the batch.Setup.overwrite field only applies to the Setup step, similarly for the batch.Denoising.overwrite and batch.Analysis.overwrite fields. Unfortunately there is no equivalent 'overwrite' option for preprocessing, but you could either use the batch.Setup.add field to explicitly add/preprocess new subjects to an existing project, or manually select which subjects you want to preprocess/analyze using the general batch.subjects field. In your case I believe the simplest way would have been to modify your script to only include the information about your new 4 subjects (e.g. change the contents of Setup.functionals, Setup.structurals, etc.), and then use Setup.isnew=0 and Setup.add=1 so that CONN adds this new information to your project and preprocesses only those new subjects (and then for the Setup/Denoising/First-level steps, the overwrite option would suffice so there is no need to change anything else in the scripts there)  Hope this helps Alfonso Originally posted by Karl Lerud:
Thanks for the reply Alfonso. I have a project with ~95 subjects, and the only preprocessing I am using CONN for is functional_art. All other preprocessing is done before import to CONN. So I executed my script, and everything seems to run correctly to completion. Then I added 4 more subjects to the project, and simply changed Setup.isnew, Setup.overwrite, Denoising.overwrite, and Analysis.overwrite all to 0 (which were all 1 the first time around), and ran the script. This seems like the correct way to go according to what you said and the documentation.  The first thing that happened is that it ran the art preprocessing on all 99 subjects, overwriting and redoing this for the first 95. It also correctly did the art preprocessing for the 4 new subjects, but of course I didn't need to spend all that time redoing the first 95. Then it did the rest fairly quickly, so I think telling it not to overwrite the rest of the analysis worked. Is there a way I can tell if it only processed the 4 recent subjects, or if it re-processed everything? And at the very least, it seems like it shouldn't have to redo the art preprocessing for everyone. Is there anything I am doing wrong, and is there a way to make this work as expected? Thanks, Karl Originally posted by Alfonso Nieto-Castanon:
Hi Karl, The options are batch.Setup.overwrite, batch.Denoising.overwrite, and batch.Analysis.overwrite (set those fields to 0 when running the Setup, Denoising, or first-level analysis steps, respectively, in order to skip already-processed subject/ROIs; see all conn_batch field details in https://web.conn-toolbox.org/resources/c...) Best Alfonso Originally posted by Karl Lerud:
Could I bump this? My question is basically just how to skip already-processed subjects/ROIs in a CONN batch script. Thanks, Karl