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: icatb_calculate_stats.m
    path of file: ./repos/gift/GroupICAT/icatb/icatb_helper_functions
    
    the code of the file until where you have to start completion: function icatb_calculate_stats
% GUI for calculates stats like mean, std and t-map for
% data-sets selected

% load defaults
icatb_defaults;
global PARAMETER_INFO_MAT_FILE;
global MEAN_ALL_AN3_FILE;
global MEAN_AN3_FILE;
global TMAP_AN3_FILE;
global STD_AN3_FILE;
global COMPONENT_NAMING;
global SESSION_POSTFIX;
global TIMECOURSE_NAMING;
global FUNCTIONAL_DATA_FILTER;


imageExtns = FUNCTIONAL_DATA_FILTER(2:end);

% filter for parameter file
filterP = ['*', PARAMETER_INFO_MAT_FILE, '*.mat'];

% select the parameter file
param_file = icatb_selectEntry('typeEntity', 'file', 'typeSelection', 'single', 'filter', ...
    filterP, 'title', 'Select a valid parameter file');

drawnow;

% output directory
[outputDir, fileName, extn] = fileparts(param_file);

    
function icatb_calculate_stats
% GUI for calculates stats like mean, std and t-map for
% data-sets selected

% load defaults
icatb_defaults;
global PARAMETER_INFO_MAT_FILE;
global MEAN_ALL_AN3_FILE;
global MEAN_AN3_FILE;
global TMAP_AN3_FILE;
global STD_AN3_FILE;
global COMPONENT_NAMING;
global SESSION_POSTFIX;
global TIMECOURSE_NAMING;
global FUNCTIONAL_DATA_FILTER;


imageExtns = FUNCTIONAL_DATA_FILTER(2:end);

% filter for parameter file
filterP = ['*', PARAMETER_INFO_MAT_FILE, '*.mat'];

% select the parameter file
param_file = icatb_selectEntry('typeEntity', 'file', 'typeSelection', 'single', 'filter', ...
    filterP, 'title', 'Select a valid parameter file');

drawnow;

% output directory
[outputDir, fileName, extn] = fileparts(param_file);

% change directory
cd(outputDir);

% load the parameter file
load(param_file);

if ~exist('sesInfo', 'var')
    error(['Selected file: ', param_file, ' is not a valid parameter file']);
end