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: T2starAndFieldCalc.m
    path of file: ./repos/sepia/utils
    
    the code of the file until where you have to start completion: function [fieldMap T2map M0map Confidence]=T2starAndFieldCalc(Magnitude,Phase,te,varargin);
% usage
%[fieldMap T2correctmap M0map Confidence] =T2starAndFieldCalc(Magnitude,Phase,te,varargin);
% if a varagin is not introduced the method used for T2* calculations is
% a simple integral method.
% varargin{1} is the method used to perform the calculation:

    
function [fieldMap T2map M0map Confidence]=T2starAndFieldCalc(Magnitude,Phase,te,varargin);
% usage
%[fieldMap T2correctmap M0map Confidence] =T2starAndFieldCalc(Magnitude,Phase,te,varargin);
% if a varagin is not introduced the method used for T2* calculations is
% a simple integral method.
% varargin{1} is the method used to perform the calculation:
% 'fast'- uses the integral of the curve to esimtate T2*
% 'pinv_reweight'- uses the log of the data to perform the line fit, but uses a reweighting of the points to make it sensitive to the lack of confidence on points with smaller intensities or bigger phase rolls
% 'lsqr_reweight'- uses the log of the data to perform the line fit, but uses a reweighting of the points to make it sensitive to the lack of confidence on points with smaller intensities or bigger phase rolls
% 'else'- it simply does the Mathworks recommend