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_reslice.m
    path of file: ./repos/ExploreASL/External/SPMmodified/xASL
    
    the code of the file until where you have to start completion: function xASL_spm_reslice(refPath, srcPath, srcAffinePath, bInvAffine, bQuality, NewName, InterpolationPar)
% ExploreASL wrapper for SPM reslice function (coreg-write).
%
% FORMAT: xASL_spm_reslice(refPath, srcPath[, srcAffinePath, bInvAffine, bQuality, NewName, InterpolationPar])
%
% INPUT:
%   refPath             - path to reference space you want to resample the source image into (REQUIRED)
%                         entered either as 'path.nii' or as 'path.nii,1'
%                         can be a cell as well, but only the first cell is used
%   srcPath             - path to source image you want to resample (REQUIRED)
%                         entered either as 'path.nii' or as 'path.nii,1'
%                         can be a cell as well, but only the first cell is used
%   srcAffinePath       - path to the '*_sn.mat' that describes the Affine transformation matrix related
%                         to the source image and describing the src->ref transformation.
%   bInvAffine          - Do the inverse of the affine transform (OPTIONAL, default = FALSE)
%                         if the affine goes from src->ref, then FALSE. For ref-src, we need to use the inversion = TRUE

    
function xASL_spm_reslice(refPath, srcPath, srcAffinePath, bInvAffine, bQuality, NewName, InterpolationPar)
% ExploreASL wrapper for SPM reslice function (coreg-write).
%
% FORMAT: xASL_spm_reslice(refPath, srcPath[, srcAffinePath, bInvAffine, bQuality, NewName, InterpolationPar])
%
% INPUT:
%   refPath             - path to reference space you want to resample the source image into (REQUIRED)
%                         entered either as 'path.nii' or as 'path.nii,1'
%                         can be a cell as well, but only the first cell is used
%   srcPath             - path to source image you want to resample (REQUIRED)
%                         entered either as 'path.nii' or as 'path.nii,1'
%                         can be a cell as well, but only the first cell is used
%   srcAffinePath       - path to the '*_sn.mat' that describes the Affine transformation matrix related
%                         to the source image and describing the src->ref transformation.
%   bInvAffine          - Do the inverse of the affine transform (OPTIONAL, default = FALSE)
%                         if the affine goes from src->ref, then FALSE. For ref-src, we need to use the inversion = TRUE
%   bQuality            - Quality setting affecting the speed of calculation (OPTIONAL, default = TRUE)
%   NewName             - Output name of the resampled NIfTI (OPTIONAL, default = uses srcPath but prefixes the input filename with 'r')
%   InterpolationPar    - interpolation method used for resampling (integer 0-7), higher is usually better quality but also slower
%                         options are 0) Nearest Neighbor 1) Trilinear 2-7) 2nd to 7th degree B-spline (OPTIONAL, default = 2)
%                         For bQuality==false, it resets it to maximum of 1.
%
% OUTPUT: n/a
%
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: This wrapper runs SPM's reslice function (a.k.a. coregister: reslice) which resamples a source image into the space of a reference image,
% taking into account any orientation differences between the two images that are defined in the orientation matrix in the NIfTI header.
% When the source image contains multiple volumes, they are all resampled.
% The source image will get the same orientation matrix as the reference image,
% as it is now in the same space as the reference image. This can be useful when two images are to be compared voxel-by-voxel, e.g. when
% overlaying a CBF image over a structural image, or when wanting to use a mask from a different space. When after running this function, the
% reference and source images are not in alignment, they need to be registered first (i.e. xASL_spm_register).
% Resampling/reslicing needs an interpolation method to know from which voxels of the source image, a voxel in the new image will be computed.
% A simplistic explanation is that this determines the number of surrounding neighborhood voxels it uses to determine the new voxel value.
% The example syntax below would reslice/resample the CBF image to the T1w space (assuming the Affine was done to register CBF to T1w)
% It also works with the external .mat file of the source file that has the same name as the source file. It also can optionally take a _sn.mat containing the
% affine transformation information.
%
% EXAMPLE: xASL_spm_reslice('/TestDataSet/Sub-001/c1T1.nii', {'/TestDataSet/Sub-001/CBF.nii'}, {'xxx_sn.mat'},0,[], 0, '/TestDataSet/Sub-001/CBF_resampled.nii')
%          xASL_spm_reslice('/TestDataSet/Sub-001/c1T1.nii,3', '/TestDataSet/Sub-001/CBF.nii,2', '/TestDataSet/Sub-001/CBF_sn.mat')
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% __________________________________
% Copyright 2015-2019 ExploreASL
%
% 2019-08-01 HJM

    % ------------------------------------------------------------------------------------------
    % Admin, manage input
	% ------------------------------------------------------------------------------------------
	if (nargin < 2) || isempty(refPath) || isempty(srcPath)
		error('Needs two input arguments with input and output paths.');
	end

	% Input can be char or cell, in case of cell, take only the first input
	if iscell(srcPath)
		if length(srcPath) > 1
			warning('srcPath contains multiple cells, using the first only.');
		end
		srcPath = srcPath{1};
	end

	if iscell(refPath)
		if length(refPath) > 1
			warning('refPath contains multiple cells, using the first only.');
		end
		refPath = refPath{1};
	end

    [~, refFile, refExt] = xASL_fileparts(refPath);
    [~, srcFile, srcExt] = xASL_fileparts(srcPath);
    refFile = [refFile refExt];
    srcFile = [srcFile srcExt];
    refPath = xASL_spm_admin(refPath);
    srcPath = xASL_spm_admin(srcPath);

	if nargin < 3 || isempty(srcAffinePath)
		srcAffinePath = [];
    elseif iscell(srcAffinePath)
		srcAffinePath = srcAffinePath{1};
	end