help > How to add new subjects to existing project with a batch script (or merge)?
Showing 1-1 of 1 posts
Display:
Results per page:
Sep 13, 2019  01:09 PM | emdoyle
How to add new subjects to existing project with a batch script (or merge)?
Hi,
I've been trying for 2 weeks to figure out how to add in subjects with out having to use the GUI to input the file names. Once I get the files imported, I would like to use the GUI to run preprocessing steps, as it is already set up in my project. This seems like it should be very simple to do, but I have tried 3 different methods and none have been working (see below). Help with any of these methods would be greatly appreciated! Thanks!
~Em

1.  I was going off a post saying that I could merge the new subjects with the project file using this method: https://www.nitrc.org/forum/message.php?msg_id=8613
So far this has not been able to work for me even after taking out the line in the merge file and opening in the GUI as it still gives me these problems:

Merging projects... please wait
loading info from project File_Pathnew_subs/190905_newsubs/conn_addsubs.mat
Mismatched ROI names with project File_Pathnew_subs/190905_newsubs/conn_addsubs.mat
Mismatched condition names with project File_Pathnew_subs/190905_newsubs/conn_addsubs.mat
Mismatched first-level covariate names with project File_Pathnew_subs/190905_newsubs/conn_addsubs.mat
Mismatched second-level covariate names with project File_Pathnew_subs/190905_newsubs/conn_addsubs.mat
There were problems importing the new subject data. See log or Matlab command window for details

The next two methods are in the same script (see below)

2. Using the BATCH.Setup function in the script, it gives me the following errors:
Error when using setup:
Brace indexing is not supported for variables of this type.

Error in conn_batch (line 842)
else CONN_x.Setup.structural{nsub}{nses}=conn_file(temp{min(numel(temp),nses)});
Error in Add_sub_190912 (line 79)
conn_batch(BATCH)

3. When using the New function (these are commented out in the script), it doesn't error, and it seems to be doing something, but it ultimately doesn't add the subject files and they are just the last subjects files as if I just changed the number of subjects with out changing the files.


THis is the script:
function [BATCH]=Add_sub_190912(sublist)

%This is a script for adding new subjects to the script
%Existing subs
subs_existing=24
len=length(sublist)
clear BATCH
BATCH.Setup.done=1 %setup is already done
BATCH.Setup.overwrite='No'
%BATCH.Setup.nsubjects=27 %set up total number of subjects (adding 3)
%for each subject
for i=1:len;
sub=sublist(i)
numsub=i+subs_existing
%Add in paths for structural data
T1path=strcat('Path_to_T1',sub,'/T1_data_office')
filelistT1=dir(string(T1path)); %create list of files in directory folder
filelistT1={filelistT1.name} %make an array of the file names that can be searched by regular expressions
filelistT1_str=strjoin(filelistT1) %make into single string
T1file=regexp(filelistT1_str,'\<20\d\d...._......T1MPRAGEsagisos........\.nii','match')
T1fullfile=char(fullfile(T1path,T1file))
3. %BATCH.New.structurals{numsub}=fullfile(T1path,T1file)
2. BATCH.Setup.structurals{numsub}=fullfile(T1path,T1file)
%for each run of the fMRI data
for r=1:3;
rr=string(r)
fMRIpath=strcat('Path_to_fMRI',sub,'/fMRI_data_office/task2_run',rr)
filelistfMRI=dir(string(fMRIpath)); %create list of files in directory folder
filelistfMRI={filelistfMRI.name} %make an array of the file names that can be searched by regular expressions
filelistfMRI_str=strjoin(filelistfMRI) %make into single string
fMRIfile=regexp(filelistfMRI_str,'\<20......_......ep2dbold2x2x2task2run.........\.nii','match') %get file name
fMRIfullfile=fullfile(fMRIpath,fMRIfile) %make a printed file path
fMRIfullfile=char(fMRIfullfile) %it wants you to convert it to characters from some reason from string
2. BATCH.Setup.functionals{numsub}{r}=fMRIfullfile
%BATCH.Setup.voxelresolution=1; %This is the default value, probably don't need
3. % BATCH.New.functionals{numsub}{r}=fullfile(fMRIpath,fMRIfullfile)
end
end
conn_batch(BATCH)