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_spatialSorting.m
    path of file: ./repos/bspm/thirdparty/MIALAB/GroupICATv4.0a/icatb/icatb_scripts
    
    the code of the file until where you have to start completion: function icatb_spatialSorting(param_file, selectedStr, templateFiles, dispParameters)
% Function to do spatial sorting of all data-sets. See
% icatb_example_spatial_sorting for running through batch mode

try
    icatb_defaults;
    global PARAMETER_INFO_MAT_FILE;
    %% Pass parameters for display
    global DETRENDNUMBER;
    global SMOOTHPARA;
    global SMOOTHINGVALUE;

    
function icatb_spatialSorting(param_file, selectedStr, templateFiles, dispParameters)
% Function to do spatial sorting of all data-sets. See
% icatb_example_spatial_sorting for running through batch mode

try
    icatb_defaults;
    global PARAMETER_INFO_MAT_FILE;
    %% Pass parameters for display
    global DETRENDNUMBER;
    global SMOOTHPARA;
    global SMOOTHINGVALUE;

    if ~exist('param_file', 'var')
        param_file = icatb_selectEntry('typeSelection', 'single', 'typeEntity', 'file', 'title', 'Select a valid ICA parameter file', ...
            'filter', ['*', PARAMETER_INFO_MAT_FILE, '*']);
    end