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_gigicar.m
    path of file: ./repos/gift/GroupICAT/icatb/icatb_analysis_functions/icatb_algorithms
    
    the code of the file until where you have to start completion: % Contact ydu@mrn.org (yhdu@nlpr.ia.ac.cn) or yong.fan@ieee.org for bugs or questions
%
%======================================================================================
%
%  Copyright (c) 2012 Yuhui DU and Yong FAN
%  Al
    
function [ICOutMax, TCMax] = icatb_gigicar(FmriMatr, ICRefMax)
%written by Yuhui Du, CAS. 2012.

%Input:
%FmriMatr is the observed data with size of timepoints*voxelvolums£»
%ICRefMax includes the reference signals;

%Output£º
%ICOutMax includes the estimated ICs;
%TCMax is the obtained mixing matrix;


%thr = eps(class(FmriMatr)); %you can change the parameter. such as thr=0.02;

thr = eps(class(FmriMatr));
max_thr = 0.02;
stopping_tolerance = 1e-2;
thresholds = [thr, max_thr];

for ii = 1:length(thresholds)
    
    [ICOutMax, TCMax] = gig_icar(FmriMatr, ICRefMax, thresholds(ii));
    % make sure standard deviation of ic's to be 1
    std_ic = std(ICOutMax, 0, 2);
    err = norm(1 - std_ic);
    if (err > stopping_tolerance)
        disp('Standard deviation of the ic components are not unitary');
        if (ii == 1)
            disp(['Changing the min threshold of eigen values to ', num2str(thresholds(end