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: CBIG_pMFM_dwell_time_empirical.m
    path of file: ./repos/CBIG/stable_projects/fMRI_dynamics/Kong2021_pMFM/part2_pMFM_control_analysis/Dwell_time/scripts
    
    the code of the file until where you have to start completion: function CBIG_pMFM_dwell_time_empirical()

% This function is used to compute the dwell time distirbution for empirial
% data
%
% Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

load('../../../part1_pMFM_main/output/step5_STDFCD_results/STD_FCD_empirical_rundata.mat', ...
    'FCD_emp_allrun')
load('../../../part1_pMFM_main/output/step6_SWSTD_state/FCD_threshold_empirical.mat', ...
    'th_all_emp')

FCD_std = std(FCD_emp_allrun,1,2);
run_num = size(FCD_std,1);

count_up = [];
count_down = [];


for i = 1:run_num
    FCD_mean = FCD_emp_allrun(i,:);
    threshold = th_all_emp(i);
    
    if threshold ~= 0
        FCD_up = 1*(FCD_mean>threshold);
        FCD_down = 1*(FCD_mean<threshold);

        FCD_up_count = CBIG_pMFM_count_func(FCD_up);
        FCD_down_count = CBIG_pMFM_count_func(FCD_down);

    
function CBIG_pMFM_dwell_time_empirical()

% This function is used to compute the dwell time distirbution for empirial
% data
%
% Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

load('../../../part1_pMFM_main/output/step5_STDFCD_results/STD_FCD_empirical_rundata.mat', ...
    'FCD_emp_allrun')
load('../../../part1_pMFM_main/output/step6_SWSTD_state/FCD_threshold_empirical.mat', ...
    'th_all_emp')

FCD_std = std(FCD_emp_allrun,1,2);
run_num = size(FCD_std,1);

count_up = [];
count_down = [];


for i = 1:run_num
    FCD_mean = FCD_emp_allrun(i,:);
    threshold = th_all_emp(i);
    
    if threshold ~= 0
        FCD_up = 1*(FCD_mean>threshold);
        FCD_down = 1*(FCD_mean<threshold);

        FCD_up_count = CBIG_pMFM_count_func(FCD_up);
        FCD_down_count = CBIG_pMFM_count_func(FCD_down);

        count_up = [count_up;FCD_up_count];
        count_down = [count_down;FCD_down_count];
    end