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: fcPreproc.m
    path of file: ./repos/bspm/thirdparty/MRtools_2015-08-21/fcMRI_scripts
    
    the code of the file until where you have to start completion: function nfn = fcPreproc(fn,pname,ord)
%%% All configuration options should be specified in the Param file.
%%%
%%% FN: is a 4D nifti file containing the resti
    
function nfn = motion_regress(fn)
        fprintf('\n%s\n', 'REMOVING MOTION VARIANCE:');
        eval(['P = ' pname ';']);
        P1 = load([pname '.mat']);

        nfn = fn;
        
        if P.mot.do == 1
            fprintf('\n%s\n', 'Loading Image Data.');
            for zz = 1:numel(fn);
                %%% Load in the actual Resting State Data                
                ti = find(fn{zz}=='_');
                nn = dir([P.bv.RealignPrefix fn{zz}(ti(2)+1:end