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_preproc_motion_outliers.m
    path of file: ./repos/CBIG/stable_projects/preprocessing/CBIG_fMRI_Preproc2016/utilities
    
    the code of the file until where you have to start completion: function CBIG_preproc_motion_outliers(DVARS_file,FDRMS_file,FD_th,DV_th,discard_seg,output_dir_name)

% CBIG_preproc_motion_outliers(DVARS_file,FDRMS_file,FD_th,DV_th,discard_seg,output_dir_name)
%
% This function is used to find the outliers with DVARS threshold DV_th and
% FDRMS threshold FD_th. After threholding, one frame before two frame after
% will also be removed. The default DV_th is 50, default FD_th is 0.2
% INPUT:
%   - DVARS_file:
%       a file contains DVARS values as a TX1 column, T is the number of
%       frames (include the first frame, whose value supposed to be 0)
%
%   - FDRMS_file:
%       a file contains FDRMS values as a TX1 column, T is the number of
%       frames (include the first frame, whose value supposed to be 0)
%
%   - FD_th:
%       the threshold of FDRMS, default is 0.2
%
%   - DV_th:
%       the threshold of DVARS, default is 50
%

    
function CBIG_preproc_motion_outliers(DVARS_file,FDRMS_file,FD_th,DV_th,discard_seg,output_dir_name)

% CBIG_preproc_motion_outliers(DVARS_file,FDRMS_file,FD_th,DV_th,discard_seg,output_dir_name)
%
% This function is used to find the outliers with DVARS threshold DV_th and
% FDRMS threshold FD_th. After threholding, one frame before two frame after
% will also be removed. The default DV_th is 50, default FD_th is 0.2
% INPUT:
%   - DVARS_file:
%       a file contains DVARS values as a TX1 column, T is the number of
%       frames (include the first frame, whose value supposed to be 0)
%
%   - FDRMS_file:
%       a file contains FDRMS values as a TX1 column, T is the number of
%       frames (include the first frame, whose value supposed to be 0)
%
%   - FD_th:
%       the threshold of FDRMS, default is 0.2
%
%   - DV_th:
%       the threshold of DVARS, default is 50
%
%   - discard_seg:
%       uncensored segments of data lasting fewer than discard_seg
%       contiguous frames will be removed, default is 5.
%
%   - output_dir_name:
%       the directory to store all output figures (full path).
%
% OUTPUT:
%   txt file: SUBJECT_bldXXX_FDRMSxxx_DVARSxxx_motion_outliers.txt, this file contains a Tx1
%             vector where 1 means kept, 0 means removed.
%   Figure: SUBJECT_bldXXX_FDRMSxxx_DVARSxxx.png
%
% Written by CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md



%% Read in file and construct DVARS. FDRMS vectors
fd = dlmread(FDRMS_file);
dvars = dlmread(DVARS_file);

%% Check input variables
if size(fd,2) > 1
    error('Input argument ''FDRMS_file'' should list values in columns');
end