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: loadCellMetrics.m
    path of file: ./repos/CellExplorer
    
    the code of the file until where you have to start completion: function [cell_metrics,cell_metrics_idxs] = loadCellMetrics(varargin)
% This function loads cell metrics for a given session
% Check the wiki of the CellExplorer for more details: https://cellexplorer.org/
%
% INPUTS
%   id                     - takes a database id as input
%   session                - takes a database sessionName as input
%   basepath               - path to session (base directory)
%
%   Filters:
%       brainRegion, synapticEffect, putativeCellType, labels, deepSuperficial, animal, tags, groups, groundTruthClassification
%
% OUTPUT
%   cell_metrics            - Cell_metrics matlab structure
%   cell_metrics_idxs       - indexes of cells fulfilling filters*
% 
% Example calls
%   cell_metrics = loadCellMetrics('basepath',pwd);
%   cell_metrics = loadCellMetrics('session',session);
%   cell_metrics = loadCellMetrics('fileFormat','json')
%   cell_metrics = loadCellMetrics('fileFormat','nwb')
%   [cell_metrics,Pyramidal_indexes] = loadCellMetrics('session',session,'putativeCellType',{'Pyramidal'});
% 

% By Peter Petersen
% petersen.peter@gmail.com
% Last edited: 06-07-2021

% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% Parsing parameters
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
p = inputParser;

% Load an existing cell metrics struct 
addParameter(p,'cell_metrics',{},@isstruct);

    
function [cell_metrics,cell_metrics_idxs] = loadCellMetrics(varargin)
% This function loads cell metrics for a given session
% Check the wiki of the CellExplorer for more details: https://cellexplorer.org/
%
% INPUTS
%   id                     - takes a database id as input
%   session                - takes a database sessionName as input
%   basepath               - path to session (base directory)
%
%   Filters:
%       brainRegion, synapticEffect, putativeCellType, labels, deepSuperficial, animal, tags, groups, groundTruthClassification
%
% OUTPUT
%   cell_metrics            - Cell_metrics matlab structure
%   cell_metrics_idxs       - indexes of cells fulfilling filters*
% 
% Example calls
%   cell_metrics = loadCellMetrics('basepath',pwd);
%   cell_metrics = loadCellMetrics('session',session);
%   cell_metrics = loadCellMetrics('fileFormat','json')
%   cell_metrics = loadCellMetrics('fileFormat','nwb')
%   [cell_metrics,Pyramidal_indexes] = loadCellMetrics('session',session,'putativeCellType',{'Pyramidal'});
% 

% By Peter Petersen
% petersen.peter@gmail.com
% Last edited: 06-07-2021

% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% Parsing parameters
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
p = inputParser;

% Load an existing cell metrics struct 
addParameter(p,'cell_metrics',{},@isstruct);

% Single session input
addParameter(p,'basepath',[],@isstr);
addParameter(p,'basename','',@isstr);
addParameter(p,'session',[],@isstruct);
addParameter(p,'sessionId',[],@isnumeric);
addParameter(p,'sessionName',[],@isstr);

% Batch input (not implemented)
addParameter(p,'sessionIDs',{},@iscell);
addParameter(p,'sessionNames',{},@iscell);
addParameter(p,'basepaths',{},@iscell);

% Extra inputs
addParameter(p,'saveAs','cell_metrics',@isstr); % Cell metrics name
addParameter(p,'fileFormat','mat',@isstr); % File format (options: mat,nwb,json)

% Filters
addParameter(p,'brainRegion',[],@iscell);
addParameter(p,'synapticEffect',[],@iscell);
addParameter(p,'putativeCellType',[],@iscell);
addParameter(p,'labels',[],@iscell);
addParameter(p,'deepSuperficial',[],@iscell);
addParameter(p,'animal',[],@iscell);
addParameter(p,'tags',[],@iscell);
addParameter(p,'groups',[],@iscell);
addParameter(p,'groundTruthClassification',[],@iscell);

parse(p,varargin{:})

% Provide existing cell metrics struct
cell_metrics = p.Results.cell_metrics;

% Single session input
sessionId = p.Results.sessionId; 

session = p.Results.session; 
basepath = p.Results.basepath;
basename = p.Results.basename;

% Batch
sessions = p.Results.sessionNames; 

params = p.Results;

% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% Loading metrics
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

if ~isempty(cell_metrics)
    
elseif ~isempty(session)
    basepath = session.general.basePath;
    basename = session.general.name;

elseif ~isempty(sessions)
    cell_metrics = loadCellMetricsBatch('sessions',sessions);
    
elseif ~isempty(sessionId) || ~isempty(params.sessionName)
    bz_database = db_credentials;
    if ~isempty(sessionId)
        [~, basename, basepath] = db_set_session('sessionId',sessionId);
    else
        [~, basename, basepath] = db_set_session('sessionName',params.sessionName);
    end