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: bf_regularise_roi.m
    path of file: ./repos/spm/toolbox/DAiSS
    
    the code of the file until where you have to start completion: function res = bf_regularise_roi(BF, S)
% ROI regularisation

% See: Oswal et al. Optimising beamformer regions of interest analysis
% Neuroimage, 2014
%__________________________________________________________________________

% Ashwini Oswal, Vladimir Litvak
% Copyright (C) 2014-2023 Wellcome Centre for Human Neuroimaging


if nargin == 0   
    pos = cfg_entry;
    pos.tag = 'pos';
    pos.name = 'MNI coordinates';
    pos.strtype = 'r';
    pos.num = [1 3];
    pos.help = {'Locations for the VOI in MNI coordinates'};
    pos.val = {};
    
    radius = cfg_entry;
    radius.tag = 'radius';
    radius.name = 'Radius';
    radius.strtype = 'r';
    radius.num = [1 1];
    radius.val = {0};
    radius.help = {'Radius (in mm) for the VOIs (leave 0 for single point)'};
    
    voidef = cfg_branch;
    voidef.tag = 'voidef';
    voidef.name = 'VOI';
    voidef.val = {pos, radius};
    
    vois = cfg_repeat;
    vois.tag = 'vois';
    vois.name = 'ROI(s)';
    vois.num  = [1 Inf];
    vois.values = {voidef};
    vois.val  = {}; 
    vois.help = {'This makes it possible to define new VOIs when the original source space was mesh or grid.',...
        'Only the sources present in the original source space can be used at this stage'};    
    
    manual = cfg_entry;
    manual.tag = 'manual';
    manual.name = 'User-specified';
    manual.strtype = 'n';
    manual.num = [1 1];
    manual.help = {'User-specified number of dimensions'};
    
    original      = cfg_const;
    original.tag  = 'original';
    original.name = 'Keep original';
    original.help = {'Keep the original dimensionality of the ROI'};
    original.val  = {1};
    
    minka      = cfg_const;
    minka.tag  = 'minka';
    minka.name = 'Minka truncation';
    minka.help = {'Use Bayesian algorithm to determine dimensionality'};
    minka.val  = {1};
    
    dimred        = cfg_choice;
    dimred.tag    = 'dimred';
    dimred.name   = 'Dimension choice';
    dimred.values = {original, manual, minka}; 
    dimred.val    = {original};
           
    res      = cfg_branch;
    res.tag  = 'roi';
    res.name = 'ROI regularisation';
    res.val  = {vois, dimred};
    

    
function res = bf_regularise_roi(BF, S)
% ROI regularisation

% See: Oswal et al. Optimising beamformer regions of interest analysis
% Neuroimage, 2014
%__________________________________________________________________________

% Ashwini Oswal, Vladimir Litvak
% Copyright (C) 2014-2023 Wellcome Centre for Human Neuroimaging


if nargin == 0   
    pos = cfg_entry;
    pos.tag = 'pos';
    pos.name = 'MNI coordinates';
    pos.strtype = 'r';
    pos.num = [1 3];
    pos.help = {'Locations for the VOI in MNI coordinates'};
    pos.val = {};
    
    radius = cfg_entry;
    radius.tag = 'radius';
    radius.name = 'Radius';
    radius.strtype = 'r';
    radius.num = [1 1];
    radius.val = {0};
    radius.help = {'Radius (in mm) for the VOIs (leave 0 for single point)'};
    
    voidef = cfg_branch;
    voidef.tag = 'voidef';
    voidef.name = 'VOI';
    voidef.val = {pos, radius};
    
    vois = cfg_repeat;
    vois.tag = 'vois';
    vois.name = 'ROI(s)';
    vois.num  = [1 Inf];
    vois.values = {voidef};
    vois.val  = {}; 
    vois.help = {'This makes it possible to define new VOIs when the original source space was mesh or grid.',...
        'Only the sources present in the original source space can be used at this stage'};    
    
    manual = cfg_entry;
    manual.tag = 'manual';
    manual.name = 'User-specified';
    manual.strtype = 'n';
    manual.num = [1 1];
    manual.help = {'User-specified number of dimensions'};
    
    original      = cfg_const;
    original.tag  = 'original';
    original.name = 'Keep original';
    original.help = {'Keep the original dimensionality of the ROI'};
    original.val  = {1};
    
    minka      = cfg_const;
    minka.tag  = 'minka';
    minka.name = 'Minka truncation';
    minka.help = {'Use Bayesian algorithm to determine dimensionality'};
    minka.val  = {1};
    
    dimred        = cfg_choice;
    dimred.tag    = 'dimred';
    dimred.name   = 'Dimension choice';
    dimred.values = {original, manual, minka}; 
    dimred.val    = {original};
           
    res      = cfg_branch;
    res.tag  = 'roi';
    res.name = 'ROI regularisation';
    res.val  = {vois, dimred};
    
    return
elseif nargin < 2
    error('Two input arguments are required');
end