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: bct_toolbox_undirected_graph_metrics.m
    path of file: ./repos/CanlabCore/CanlabCore/Statistics_tools
    
    the code of the file until where you have to start completion: function [graph_prop, graph_prop_glob] = bct_toolbox_undirected_graph_metrics(r, thresh, varargin)
% Calculate some Sporns BCT toolbox functions
%
% graph_prop = bct_toolbox_undirected_graph_metrics(r, [threshold_input])
% 
% Inputs:
% r = correlation matrix
% thresh = 0 to 1 value. (.1 is a common value)
%
% optional: 
%   'doplots' - show matrices
%   'doweighted' -- this increase compute time by several orders of
%   magnitude. Default = false
%
% Outputs:
% graph_prop = A table of node-level graph metrics 
% graph_prop_glob = A table of global graph metrics
% 
% For BCT toolbox, see:
% https://sites.google.com/site/bctnet/
%
% For descriptions of metrics, see:
% https://sites.google.com/site/bctnet/measures/list
%
% Notes:
% - Some metrics are calculated on thresholded, weighted (continuous valued) matrix r
%   Sig matrix or link density threshold will be applied. 
%   To use without any thresholding, sig mat should be all ones, or link density 100
% - Others are calculated on thresholded, binarized matrix (positive connections only)
%   If you enter a sig matrix, this will be used as the input to graph metric functions
%   If you enter a link density, a binary matrix will be calculated

    
function [graph_prop, graph_prop_glob] = bct_toolbox_undirected_graph_metrics(r, thresh, varargin)
% Calculate some Sporns BCT toolbox functions
%
% graph_prop = bct_toolbox_undirected_graph_metrics(r, [threshold_input])
% 
% Inputs:
% r = correlation matrix
% thresh = 0 to 1 value. (.1 is a common value)
%
% optional: 
%   'doplots' - show matrices
%   'doweighted' -- this increase compute time by several orders of
%   magnitude. Default = false
%
% Outputs:
% graph_prop = A table of node-level graph metrics 
% graph_prop_glob = A table of global graph metrics
% 
% For BCT toolbox, see:
% https://sites.google.com/site/bctnet/
%
% For descriptions of metrics, see:
% https://sites.google.com/site/bctnet/measures/list
%
% Notes:
% - Some metrics are calculated on thresholded, weighted (continuous valued) matrix r
%   Sig matrix or link density threshold will be applied. 
%   To use without any thresholding, sig mat should be all ones, or link density 100
% - Others are calculated on thresholded, binarized matrix (positive connections only)
%   If you enter a sig matrix, this will be used as the input to graph metric functions
%   If you enter a link density, a binary matrix will be calculated
% - Fisher r to Z is computed, which will have little impact in many cases
%   but may help in some cases
% - Many BCT functions will not use negative values and ignore weights, so require thresholding. 
%   P-values/statistical significance is one way to threshold.
%   Another way would be using multiple arbitrary thresholds (e.g., 10% link density)
%   The latter may be practical for individual subjects, unless individual-subject stats are calculated and saved
% - This function prioritizes 
% - Degree, etc. may possibly be related to confounds (head motion), and may want to adjust/test for this.
%
% Examples:
% -------------------------------------------------------
% % start with r, a series of correlation matrices, one per subject (k x k x n_subjects)
% OUT = ttest3d(r);                                             % Get some basic stats
% graph_prop = bct_toolbox_undirected_graph_metrics(OUT.r);     % input group mean correlation matrix
%
% rr = corr(table2array(graph_prop));                           % correlate the metrics
% plot_correlation_matrix(rr, 'names', graph_prop.Properties.VariableNames)
%
% % Note: correlations among community vectors are not meaningful. 
% % for similarity among communities/modules detected with different methods, see partition_distance.m

% Check path
if isempty(which('threshold_proportional.m'))
    error('The BCT toolbox does not seem to be on your Matlab path. See https://sites.google.com/site/bctnet/');
end