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: aa_init.m
    path of file: ./repos/automaticanalysis/aa_engine
    
    the code of the file until where you have to start completion: % Automatic analysis - initialise paths from recipe
function [aap]=aa_init(aap)

global aa

% detect running aa
if isobject(aa)
    aas_log(aap,false,'WARNING: Previous execution of aa was not closed! Killing jobs...\n')
    aas_log(aap,false,'WARNING: The path settings for both linux and MATLAB may have been modified! You m
    
function
if exist('utc_time','file')
    utc_timeFunc = @utc_time;
else
    aas_log(aap,false,'INFO: utc_time is not found. java function will be used\n')
    utc_timeFunc = @java.lang.System.currentTimeMillis;
end
aas_cache_put(aap,'utc_time',utc_timeFunc,'utils');

%% Set Paths
aas_cache_put(aap,'bcp_path',path,'system');
aas_cache_put(aap,'bcp_shellpath',getenv('PATH'),'system');

% Path for SPM
SPMDIR = '';
% - backward compatibility
if isfield(aap.directory_conventions,'spmdir') && ~isempty(aap.directory_conventions.spmdir)
    SPMDIR = aap.directory_conventions.spmdir;
end
% toolboxes
if isfield(aap.directory_conventions,'toolbox')
    tbxInd = strcmp({aap.directory_conventions.toolbox.name},'spm');
    if any(tbxInd)
        SPMDIR = aap.directory_conventions.toolbox(tbxInd).dir;
    end