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: Wrapper_QSM_iLSQR.m
    path of file: ./repos/sepia/wrapper/WrapperQSM
    
    the code of the file until where you have to start completion: %% [chi] = Wrapper_QSM_iLSQR(localField,mask,matrixSize,voxelSize,algorParam, headerAndExtraData)
%
% Input
% ----
    
function to access iLSQR for SEPIA
%
% Kwok-shing Chan @ DCCN
% k.chan@donders.ru.nl
% Date created: 8 March 2020
% Date modified: 24 Feb 2021 (v1.0)
%
%
function [chi] = Wrapper_QSM_iLSQR(localField,mask,matrixSize,voxelSize,algorParam, headerAndExtraData)
sepia_universal_variables;

% get algorithm parameters
algorParam  = check_and_set_algorithm_default(algorParam);
method      = algorParam.qsm.method;
tol         = algorParam.qsm.tol;
maxiter     = algorParam.qsm.maxiter;
lambda      = algorParam.qsm.lambda;
optimise    = algorParam.qsm.optimise;

% get extra data such as magnitude/weights/B0 direction/TE/etc.
headerAndExtraData = check_and_set_SEPIA_header_data(headerAndExtraData);
b0dir       = headerAndExtraData.sepia_header.B0_dir;
b0          = headerAndExtraData.sepia_header.B0;
wmap        = get_variable_from_headerAndExtraData(headerAndExtraData, 'weights', matrixSize);
% bug fix 20220224: deprecated no initial guess option in SEPIA
% initGuess   = get_variable_from_headerAndExtraData(headerAndExtraData, 'initGuess', matrixSize);
initGuess   = zeros(matrixSize);

if isempty(wmap)
    wmap = ones(matrixSize);
end