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: scnlab_filter_fmri_data.m
    path of file: ./repos/CanlabCore/CanlabCore/Data_processing_tools
    
    the code of the file until where you have to start completion: function names = scnlab_filter_fmri_data(imgs, mvmt, mask, tr, spersess, hp)
% Outlier and artifact removal for one subject
% Writes new output images for timeseries
%
% :Usage:
% ::
%
%     names = scnlab_filter_fmri_data(imgs, mvmt, mask, tr, spersess, hp)
%
% :Examples:
% ::
%
%    OUT = mean_image(imgs, 'mean_ravol.img',ones(size(imgs,1),1));
%    spm_imcalc_ui('mean_ravol.img', 'graymatter.img', 'i1 > 0');
%    spm_image('init', 'graymatter.img');
%    names = scnlab_filter_fmri_data(imgs, mvmt, 'graymatter.img', 2, repmat(184, 1, 6), 80);

    tic
    imgs = check_valid_imagename(imgs);

    disp('Loading data')
    [dat, volInfo] = iimg_get_data(mask, imgs);


    % -------------------------------------------------------

    disp('Setting up filtering, and logging to scn_filter_output.txt')
    diary scn_filter_output.txt

    
function names = scnlab_filter_fmri_data(imgs, mvmt, mask, tr, spersess, hp)
% Outlier and artifact removal for one subject
% Writes new output images for timeseries
%
% :Usage:
% ::
%
%     names = scnlab_filter_fmri_data(imgs, mvmt, mask, tr, spersess, hp)
%
% :Examples:
% ::
%
%    OUT = mean_image(imgs, 'mean_ravol.img',ones(size(imgs,1),1));
%    spm_imcalc_ui('mean_ravol.img', 'graymatter.img', 'i1 > 0');
%    spm_image('init', 'graymatter.img');
%    names = scnlab_filter_fmri_data(imgs, mvmt, 'graymatter.img', 2, repmat(184, 1, 6), 80);

    tic
    imgs = check_valid_imagename(imgs);

    disp('Loading data')
    [dat, volInfo] = iimg_get_data(mask, imgs);


    % -------------------------------------------------------

    disp('Setting up filtering, and logging to scn_filter_output.txt')
    diary scn_filter_output.txt
    OPT = scnlab_outlier_id('setup', 'tr', tr, 'spersess', spersess, 'dummy', 1:2, 'hp', hp, 'mad', 4, 'niter', 5, 'mvmt', mvmt);
    OPT.volInfo = volInfo;
    diary off

    % -------------------------------------------------------

    disp('Test run...')
    fhandle = @(y) scnlab_outlier_id('data', y, 'options', OPT);
    fhandle(dat(:,1));

    disp('Saving OPT structure in scnlab_filter_setup.mat')
    save scnlab_filter_setup OPT

    disp('Printing graphics image to scnlab_filter_output.ps');
    h = findobj('Tag', 'Data Detail');
    if ~isempty(h) && ishandle(h)
        print(h, '-dpsc','-r200','scnlab_filter_output.ps','-append