Dear all,
I'm trying to script a conn batch to preprocess data with the following characteristics :
214 subjects
134 functional files (.nii) per subject
1 structural file per subject
1 session per subject
I am wondering if it is possible to load all the functional files (134) via command line, or if only one functional file per subject is expected.
Here's a portion of my script for only 2 subjects:
DATApath=pwd;
nsubjects=2;
clear FUNCTIONAL_FILE* STRUCTURAL_FILE*;
subs=dir(regexprep(DATApath,'%s.*$','*'));
subs=subs([subs.isdir]>0);
subs={subs.name};
subs=subs(cellfun(@(s)all(s>='0'&s<='9'),subs));
if isempty(nsubjects), nsubjects=numel(subs);
else subs=subs(1:nsubjects);
end
for n=1:numel(subs)
<span style="white-space: pre;"> </span>fprintf('Locating subject %s files\n',subs{n});
<span style="white-space: pre;"> </span>% files=conn_dir(fullfile(cwd,SubjectFolder{nsub},SessionSubFolder{nses},'functional*.img')); <- this is the structure I'm following
<span style="white-space: pre;"> </span>t1=conn_dir(fullfile(DATApath,subs{n},'structural','structural*.nii'));
<span style="white-space: pre;"> </span>f1=conn_dir(fullfile(DATApath,subs{n},'emotion','emotion*.nii')); % here's where I get an error saying "Pathname is too long"
<span style="white-space: pre;"> </span>if isempty(dir(t1)), error('file %s not found',t1); end
<span style="white-space: pre;"> </span>if isempty(dir(f1)), error('file %s not found',f1); end
<span style="white-space: pre;"> </span>STRUCTURAL_FILE{n,1}=t1;
<span style="white-space: pre;"> </span>FUNCTIONAL_FILE{n,1}=f1;
end
nsessions=1;
fprintf('%d subjects, %d sessions\n', nsubjects, nsessions);
{...}
clear batch;
batch.filename=fullfile(TARGETpath, 'conn_emotion.mat');
batch.Setup.functionals=repmat({{}},[nsubjects,1]); % Point to functional volumes for each subject/session
for nsub=1:nsubjects,for nses=1:nsessions, batch.Setup.functionals{nsub}{nses}{1}=FUNCTIONAL_FILE{nsub,nses}; end; end;
batch.Setup.structurals=STRUCTURAL_FILE; % Point to anatomical volumes for each subject
{...}
Thank you very much!
Emiliana
I'm trying to script a conn batch to preprocess data with the following characteristics :
214 subjects
134 functional files (.nii) per subject
1 structural file per subject
1 session per subject
I am wondering if it is possible to load all the functional files (134) via command line, or if only one functional file per subject is expected.
Here's a portion of my script for only 2 subjects:
DATApath=pwd;
nsubjects=2;
clear FUNCTIONAL_FILE* STRUCTURAL_FILE*;
subs=dir(regexprep(DATApath,'%s.*$','*'));
subs=subs([subs.isdir]>0);
subs={subs.name};
subs=subs(cellfun(@(s)all(s>='0'&s<='9'),subs));
if isempty(nsubjects), nsubjects=numel(subs);
else subs=subs(1:nsubjects);
end
for n=1:numel(subs)
<span style="white-space: pre;"> </span>fprintf('Locating subject %s files\n',subs{n});
<span style="white-space: pre;"> </span>% files=conn_dir(fullfile(cwd,SubjectFolder{nsub},SessionSubFolder{nses},'functional*.img')); <- this is the structure I'm following
<span style="white-space: pre;"> </span>t1=conn_dir(fullfile(DATApath,subs{n},'structural','structural*.nii'));
<span style="white-space: pre;"> </span>f1=conn_dir(fullfile(DATApath,subs{n},'emotion','emotion*.nii')); % here's where I get an error saying "Pathname is too long"
<span style="white-space: pre;"> </span>if isempty(dir(t1)), error('file %s not found',t1); end
<span style="white-space: pre;"> </span>if isempty(dir(f1)), error('file %s not found',f1); end
<span style="white-space: pre;"> </span>STRUCTURAL_FILE{n,1}=t1;
<span style="white-space: pre;"> </span>FUNCTIONAL_FILE{n,1}=f1;
end
nsessions=1;
fprintf('%d subjects, %d sessions\n', nsubjects, nsessions);
{...}
clear batch;
batch.filename=fullfile(TARGETpath, 'conn_emotion.mat');
batch.Setup.functionals=repmat({{}},[nsubjects,1]); % Point to functional volumes for each subject/session
for nsub=1:nsubjects,for nses=1:nsessions, batch.Setup.functionals{nsub}{nses}{1}=FUNCTIONAL_FILE{nsub,nses}; end; end;
batch.Setup.structurals=STRUCTURAL_FILE; % Point to anatomical volumes for each subject
{...}
Thank you very much!
Emiliana