You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: aamod_secondlevel_model.m
    path of file: ./repos/automaticanalysis/aa_modules
    
    the code of the file until where you have to start completion: % AA module - second level statistics
% Only runs if all contrasts present in same order in all subjects at first
% level. If so, makes model with basic t-test for each of contrasts.
% Second-level model from Rik Henson
% Modified for aa by Rhodri Cusack May 2006
    
function [aap,resp]=aamod_secondlevel_model(aap,task)

resp='';

switch task
    case 'report'
        [~, SPMtool] = aas_cache_get(aap,'spm');
        
        if numel(cellstr(spm_select('List',aas_getstudypath(aap),'^diagnostic.*'))) < 2 % two images expected
            % group mask
            for subj = 1:numel(aap.acq_details.subjects)
                mask{subj} = aas_getfiles_bystream(aap,'subject',subj,'firstlevel_brainmask');
            end