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: xASL_spm_GLMsaveMatlab_StatsFigures.m
    path of file: ./repos/ExploreASL/WorkInProgress/StatsAnalysis/SPM_VBA_Stats
    
    the code of the file until where you have to start completion: function xASL_spm_GLMsaveMatlab_StatsFigures(diff_view_mean, H_ttestCONTRAST,x)
%xASL_spm_GLMsaveMatlab_StatsFigures Print Figures into files, using matlab figure stuff
    
    if  x.S.nSets>2
        iDiff   = 1; % print only the f-maps (subtractions don't make sense here, or could do the SD)

    
function xASL_spm_GLMsaveMatlab_StatsFigures(diff_view_mean, H_ttestCONTRAST,x)
%xASL_spm_GLMsaveMatlab_StatsFigures Print Figures into files, using matlab figure stuff
    
    if  x.S.nSets>2
        iDiff   = 1; % print only the f-maps (subtractions don't make sense here, or could do the SD)
    else
        iDiff   = 2; % print only the significant subtraction maps
    end

%     for iDiff=1:length(diff_view_mean)

    H_ttest             = H_ttestCONTRAST;
    H_diff              = H_ttest .* diff_view_mean{iDiff};


    %% Determine window viewing/thresholding        
    hiThresh            = xASL_stat_MeanNan(nonzeros(H_diff)) + (4 * xASL_stat_StdNan(nonzeros(H_diff)));
    hiThresh            = ceil(hiThresh/2)*2;
    loThresh            = xASL_stat_MeanNan(nonzeros(H_diff)) - (4 * xASL_stat_StdNan(nonzeros(H_diff)));
    loThresh            = floor(loThresh/2)*2;        

    if      x.S.nSets==1 && ~S.RegressionCOVAR % 1-sample t-test
            ThreshPlus              = hiThresh;
            ThreshMin               = loThresh-(hiThresh-loThresh);
    elseif  x.S.RegressionCOVAR % regression
            ThreshPlus              = hiThresh;
            ThreshMin               = loThresh;


    else % Obtain reasonable clipping values for viewing (window level)
            % Window level should be same for increase & decrease
            ThreshStat              = max(abs([hiThresh loThresh]));
            ThreshPlus              = ThreshStat;
            ThreshMin               = -ThreshStat;
    end