SPM 12 Second-level GLM of multi-session fmri

Dear all,

I am running into a strange problem while running second-level GLM (using SPM12) of multi-session fMRI from first-level. I am getting the following error –

Error using betainc
X must be in the interval [0,1].

Error in spm_Tcdf (line 109)
F(Q) = xQxPos -(xQxPos*2-1).*0.5.*betainc(v(Qv)./(v(Qv)+x(Qx).^2),v(Qv)/2,1/2);

Error in spm_ECdensity (line 38)
    EC(1,:) = 1 - spm_Tcdf(t,v);

Error in spm_P_RF (line 63)
EC  = spm_ECdensity(STAT,Z,df);

Error in spm_uc_RF (line 37)
    [P, P, p] = spm_P_RF(1,0,u,df,STAT,R,n);

Error in spm_uc (line 31)
u = spm_uc_RF(a,df,STAT,R,n);

Error in spm_getSPM (line 790)
    uu      = spm_uc(0.05,df,STAT,R,n,S);

Error in spm_results_ui (line 261)
        [SPM,xSPM] = spm_getSPM;
 
Error while evaluating UIControl Callback.

This error pops up for both script and GUI.

I have attached the deisgn_matrix image below…

I have no issues in computing the contrasts in the first-level. I am attaching the snippet of the script I used to compute the first-level contrast…

%---------------------
    % 4. Compute contrasts
    %---------------------
    % Double check which regressors are in which columns
    cd(model_path);
    load('SPM.mat');
    colnames = SPM.xX.name';
    disp('Design matrix columns are:')
    disp(colnames)
    
    % Read in the contrast table
    c_path = 'E:\Simba\Contrast_table_GLM_pmod4.xlsx'
    t = readtable(c_path);
    cnames = t.Var1;  % contrast names
    cvecs  = table2array(t(:,2:end));  % contrast matrix
    ncon   = numel(cnames);  % number of contrasts
    
    % Create a batch
    matlabbatch = {};
    matlabbatch{1}.spm.stats.con.spmmat= {spmMatPath};
    for j = 1:ncon
        matlabbatch{1}.spm.stats.con.consess{j}.tcon.name = cnames{j};
        matlabbatch{1}.spm.stats.con.consess{j}.tcon.weights = cvecs(j,:);
        matlabbatch{1}.spm.stats.con.consess{j}.tcon.sessrep = 'none';
    end
    % Loop over contrasts
    matlabbatch{1}.spm.stats.con.delete = 0;
    
    
    matlabbatch{1}.spm.stats.con.spmmat = {spmMatPath};

The same second-level script works perfectly for single-session contrasts…

Any help would be hugely appreciated…

Thank you…

EDIT : This is solved! It was due to SPM not being able to compute the t statistic due to low sample size at the 2nd level.

This issue has been resolved. I was testing this out on 2 subjects and obviously, it was unable to compute – hence the error. Works perfectly on the whole group.