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: FANSI_4sepia.m
    path of file: ./repos/sepia/misc/qsm_algorithm/FANSI
    
    the code of the file until where you have to start completion: %% chi = FANSI_4sepia(phase,magn,spatial_res,alpha,mu,noise,options,B0_dir)
%
% Description: Wrapper to use FANSI under Sepia 
%
% Kwok-shing Chan @ DCCN
% k.chan@donders.ru.nl
% Date created: 1 April 2019
% 
    
function chi = FANSI_4sepia(phase,magn,spatial_res,alpha,noise,options,B0_dir)

params = [];

% additional parameters for sepia
params.maxOuterIter = options.iterations;
params.tol_update   = options.update;

% original FANSI function 
N = size(phase);
params.N = N;


if nargin > 5
    if isfield(options,'kernel_mode')
         kmode = options.kernel_mode;
    else
        kmode = 0;
    end