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_meg_epochs.m
    path of file: ./repos/automaticanalysis/aa_modules
    
    the code of the file until where you have to start completion: function [aap, resp] = aamod_meg_epochs(aap,task,subj,sess)

resp='';

switch task
    case 'report'
        
    case 'doit'
        %% Initialise
        [junk, SPMtool] = aas_cache_get(aap,'spm');
        SPMtool.addCollection('meeg');
        
        sessdir = aas_getsesspath(aap,subj,sess);
        infname = aas_getfiles_bystream(aap,'meeg_session',[subj sess],'meg'); infname = infname(1,:);

    
function [aap, resp] = aamod_meg_epochs(aap,task,subj,sess)

resp='';

switch task
    case 'report'
        
    case 'doit'
        %% Initialise
        [junk, SPMtool] = aas_cache_get(aap,'spm');
        SPMtool.addCollection('meeg');
        
        sessdir = aas_getsesspath(aap,subj,sess);
        infname = aas_getfiles_bystream(aap,'meeg_session',[subj sess],'meg'); infname = infname(1,:);
        S.D = spm_eeg_load(infname);
        
        S.bc = aap.tasklist.currenttask.settings.baselinecorrection;
        S.timewin = aap.tasklist.currenttask.settings.timewindow;
        
        %% Conditions
        subjmatches=strcmp(aap.acq_details.subjects(subj).subjname,{aap.tasklist.currenttask.settings.condition.subject});
        sessmatches=strcmp(aap.acq_details.meeg_sessions(sess).name,{aap.tasklist.currenttask.settings.condition.session});
        % If no exact spec found, try session wildcard, then subject
        % wildcard, then wildcard for both
        if (~any(sessmatches & subjmatches))
            sesswild=strcmp('*',{aap.tasklist.currenttask.settings.condition.session});
            if (any(sesswild & subjmatches))
                sessmatches=sesswild;
            else
                subjwild=strcmp('*',{aap.tasklist.currenttask.settings.condition.subject});
                if (any(sessmatches & subjwild))
                    subjmatches=subjwild;
                else
                    subjmatches=subjwild;
                    sessmatches=sesswild;
                end