SPM batch script--multiple sessions; SYNTAX ERROR?

9 Ansichten (letzte 30 Tage)
Kathleen Hupfeld
Kathleen Hupfeld am 12 Dez. 2017
Bearbeitet: Elfriede Diestel am 23 Dez. 2021
Hi, I'm thinking that I have a quick syntax error fix, but I cannot figure it out. I'm working with SPM12 batch scripts for preprocessing fMRI images.
Previously, I ran slice time correction using this code. I was just selecting 66 volumes for a file that ended in 005a001 for each person. This code worked fine for one run per person.
data_path = ['/Research Projects/flight/02_Nifti/',subjID,'/',timepoint,'/04_VEMP/combined_L_R'];
% Initialise SPM
spm('Defaults','fMRI');
spm_jobman('initcfg');
%select 66 volumes for first run
a = spm_select('ExtFPList', fullfile(data_path),'^.*005a001\.nii$',1:66);
clear matlabbatch
%Run slice timing
matlabbatch{1}.spm.temporal.st.scans = {cellstr(a)};
matlabbatch{1}.spm.temporal.st.nslices = 36;
matlabbatch{1}.spm.temporal.st.tr = 3.66;
matlabbatch{1}.spm.temporal.st.ta = 3.5583333333333;
matlabbatch{1}.spm.temporal.st.so = [2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35];
matlabbatch{1}.spm.temporal.st.refslice = 18;
matlabbatch{1}.spm.temporal.st.prefix = 'a';
spm_jobman('run',matlabbatch);
However, I wanted to edit this code to include two "sessions" (i.e., runs)--the first run ending in 005a001 and the second run ending in 007a001. Saving the batch code from clicking through the SPM GUI led me to believe that something like this would work:
data_path = ['/Research Projects/flight/02_Nifti/',subjID,'/',timepoint,'/04_VEMP/combined_L_R'];
%select 66 volumes for first run
a = spm_select('ExtFPList', fullfile(data_path),'^.*005a001\.nii$',1:66);
%select 66 volumes for second run
b = spm_select('ExtFPList', fullfile(data_path),'^.*007a001\.nii$',1:66);
clear matlabbatch
%Run slice timing
matlabbatch{1}.spm.temporal.st.scans = {
{cellstr(a)}
{cellstr(b)}
}';
matlabbatch{1}.spm.temporal.st.nslices = 36;
matlabbatch{1}.spm.temporal.st.tr = 3.66;
matlabbatch{1}.spm.temporal.st.ta = 3.5583333333333;
matlabbatch{1}.spm.temporal.st.so = [2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35];
matlabbatch{1}.spm.temporal.st.refslice = 18;
matlabbatch{1}.spm.temporal.st.prefix = 'a';
spm_jobman('run',matlabbatch);
However, when I run this I get the error that seems to indicate I'm not inputting the cell strings correctly, so this is likely just a syntax error on my fault?
Item 'Session', field 'val': Value must be either empty, a cellstr or a cfg_dep object.
Item 'Session', field 'val': Value must be either empty, a cellstr or a cfg_dep object.
  2 Kommentare
Cas Teurlings
Cas Teurlings am 29 Jun. 2021
Bearbeitet: Cas Teurlings am 29 Jun. 2021
Please gods of Matlab, give an answer to this question. I have exact the same!
Marie Levorsen
Marie Levorsen am 11 Okt. 2021
Hi,
Did you find out?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Feng Lin
Feng Lin am 15 Jan. 2019
Hey, I have the same problem with you. I am wondering have you solved the issue or not? My scripts get errors all the time

Elfriede Diestel
Elfriede Diestel am 23 Dez. 2021
Bearbeitet: Elfriede Diestel am 23 Dez. 2021
I was able to solve this by creating a for loop around the first matlabbatch step. If, for example, their are two sessions (so sessions = {'1', '2'}), this is what the for loop would look like:
for i_data = 1:size(a,1)
for i_sess = 1:length(sessions)
if strcmp(sessions{i_sess}, '1')
matlabbatch{1}.spm.temporal.st.scans{i_sess}(i_data,1) = {a(i_data,:)};
end
if strcmp(sessions{i_sess}, '2')
matlabbatch{1}.spm.temporal.st.scans{i_sess}(i_data,1) = {b(i_data,:)};
end
end
end

Kategorien

Mehr zu Neuroimaging finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by