‘!invalid contrast’ when running contrasts using SPM
Hey all,
I am trying to run a contrast using SPM (SPM12) in order to determine whether brain activation differs between two conditions, using the code snippet below:
%% Contrasts
matlabbatch{3}.spm.stats.con.consess{1}.tcon.name = ‘nav-follow’;
disp(length(names));
disp(size(confounds_matrix,2));
initial_convec = [0 0 -1 0 0 1 0 0 0 0 0 0 0];
num_confounds = size(confounds_matrix, 2);
additional_convec = zeros(1, num_confounds+1);
convec = [initial_convec, additional_convec];
matlabbatch{3}.spm.stats.con.consess{1}.tcon.convec = convec;
matlabbatch{3}.spm.stats.con.consess{1}.tcon.sessrep = ‘replsc’; % ‘none’;
matlabbatch{3}.spm.stats.con.delete = 0;
spm_jobman(‘run’, matlabbatch);
However, I keep getting the error message ‘!invalid contrast’.
Contrasts folder : ./GroupHunt/spm_output/sub-01
0 0 -1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <- !invalid contrast
01-Jun-2024 14:03:55 – Failed ‘Contrast Manager’
Error using spm_run_con (line 254)
Error in contrast specification
In file "/mnt/data/fMRI/GroupHunt/spm12/config/spm_run_con.m" (v7738), function "spm_run_con" at line 254.
The following modules did not run:
Failed: Contrast Manager
However, I can’t understand why this contrast is invalid. There are 26 values in the ‘convec’ vector which specifies the contrast and 26 regressors in my design matrix.
The variable ‘convec’ looks as follows:
convec =
Columns 1 through 10
0 0 -1 0 0 1 0 0 0 0
Columns 11 through 20
0 0 0 0 0 0 0 0 0 0
Columns 21 through 26
0 0 0 0 0 0
My design matrix has 26 regressors as follows:
load(fullfile(subdir, ‘SPM.mat’));
numRegressors = size(SPM.xX.X, 2);
disp([‘Number of regressors: ‘, num2str(numRegressors)]);
Number of regressors: 26
I would be so so grateful for a helping hand! :DHey all,
I am trying to run a contrast using SPM (SPM12) in order to determine whether brain activation differs between two conditions, using the code snippet below:
%% Contrasts
matlabbatch{3}.spm.stats.con.consess{1}.tcon.name = ‘nav-follow’;
disp(length(names));
disp(size(confounds_matrix,2));
initial_convec = [0 0 -1 0 0 1 0 0 0 0 0 0 0];
num_confounds = size(confounds_matrix, 2);
additional_convec = zeros(1, num_confounds+1);
convec = [initial_convec, additional_convec];
matlabbatch{3}.spm.stats.con.consess{1}.tcon.convec = convec;
matlabbatch{3}.spm.stats.con.consess{1}.tcon.sessrep = ‘replsc’; % ‘none’;
matlabbatch{3}.spm.stats.con.delete = 0;
spm_jobman(‘run’, matlabbatch);
However, I keep getting the error message ‘!invalid contrast’.
Contrasts folder : ./GroupHunt/spm_output/sub-01
0 0 -1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <- !invalid contrast
01-Jun-2024 14:03:55 – Failed ‘Contrast Manager’
Error using spm_run_con (line 254)
Error in contrast specification
In file "/mnt/data/fMRI/GroupHunt/spm12/config/spm_run_con.m" (v7738), function "spm_run_con" at line 254.
The following modules did not run:
Failed: Contrast Manager
However, I can’t understand why this contrast is invalid. There are 26 values in the ‘convec’ vector which specifies the contrast and 26 regressors in my design matrix.
The variable ‘convec’ looks as follows:
convec =
Columns 1 through 10
0 0 -1 0 0 1 0 0 0 0
Columns 11 through 20
0 0 0 0 0 0 0 0 0 0
Columns 21 through 26
0 0 0 0 0 0
My design matrix has 26 regressors as follows:
load(fullfile(subdir, ‘SPM.mat’));
numRegressors = size(SPM.xX.X, 2);
disp([‘Number of regressors: ‘, num2str(numRegressors)]);
Number of regressors: 26
I would be so so grateful for a helping hand! 😀 Hey all,
I am trying to run a contrast using SPM (SPM12) in order to determine whether brain activation differs between two conditions, using the code snippet below:
%% Contrasts
matlabbatch{3}.spm.stats.con.consess{1}.tcon.name = ‘nav-follow’;
disp(length(names));
disp(size(confounds_matrix,2));
initial_convec = [0 0 -1 0 0 1 0 0 0 0 0 0 0];
num_confounds = size(confounds_matrix, 2);
additional_convec = zeros(1, num_confounds+1);
convec = [initial_convec, additional_convec];
matlabbatch{3}.spm.stats.con.consess{1}.tcon.convec = convec;
matlabbatch{3}.spm.stats.con.consess{1}.tcon.sessrep = ‘replsc’; % ‘none’;
matlabbatch{3}.spm.stats.con.delete = 0;
spm_jobman(‘run’, matlabbatch);
However, I keep getting the error message ‘!invalid contrast’.
Contrasts folder : ./GroupHunt/spm_output/sub-01
0 0 -1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <- !invalid contrast
01-Jun-2024 14:03:55 – Failed ‘Contrast Manager’
Error using spm_run_con (line 254)
Error in contrast specification
In file "/mnt/data/fMRI/GroupHunt/spm12/config/spm_run_con.m" (v7738), function "spm_run_con" at line 254.
The following modules did not run:
Failed: Contrast Manager
However, I can’t understand why this contrast is invalid. There are 26 values in the ‘convec’ vector which specifies the contrast and 26 regressors in my design matrix.
The variable ‘convec’ looks as follows:
convec =
Columns 1 through 10
0 0 -1 0 0 1 0 0 0 0
Columns 11 through 20
0 0 0 0 0 0 0 0 0 0
Columns 21 through 26
0 0 0 0 0 0
My design matrix has 26 regressors as follows:
load(fullfile(subdir, ‘SPM.mat’));
numRegressors = size(SPM.xX.X, 2);
disp([‘Number of regressors: ‘, num2str(numRegressors)]);
Number of regressors: 26
I would be so so grateful for a helping hand! 😀 contrasts, spm, matlab, fmri, brain MATLAB Answers — New Questions
​