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_coreg.m
    path of file: ./repos/ExploreASL/Functions/SPM
    
    the code of the file until where you have to start completion: function xASL_spm_coreg(refPath, srcPath, OtherList, x, sep, FastReg)
%xASL_spm_coreg ExploreASL wrapper for SPM coregistration function (a.k.a. 'coreg')
%
% FORMAT: xASL_spm_coreg(refPath, srcPath[, OtherList, x, sep, FastReg])
%
% INPUT:
%   refPath             - path to reference space (NifTI image) you want to register the source image to (REQUIRED)
%   srcPath             - path to source image (NifTI image) you want to register (REQUIRED)
%   OtherList           - cell list with paths to NIfTI images that you want to apply the calculated transformation to (OPTIONAL)
%                         the srcPath NIfTI orientation header is always adapted with the calculated transformation
%   x                   - ExploreASL structure containing fields with global information about the pipeline environment
%                         and settings (e.g. x.settings.Quality), useful when you want this script to copy the options of an ExploreASL pipeline run (OPTIONAL)
%   sep                 - separation setting used by SPM coregistration, that defines the average distance between sampled points (in mm)
%                         can also have a vector of multiple values to allow a coarse registration with increasingly finer ones (OPTIONAL, DEFAULT=[4 2])
%   FastReg             - New experimental feature to speed up registration of low resolution images.
%                         When low resolution images are registered to high resolution images, the high resolution matrix and
%                         sep values can unnecessarily increase the precision and duration of the coregistration (e.g. from 10 to 55 seconds)
%                         This parameter is WIP, so please leave it at default setting for now(OPTIONAL, default=false)
%
% OUTPUT: n/a
%
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: This SPM wrapper runs SPMs coregister-estimate function, which calculates the 6 parameter rigid-body transformation (a.k.a. linear) that is required to
% align the source image with the reference image. This 6 parameter transformation (i.e. 3 XYZ translations and 3 rotations) is applied to
% the orientation header of the source NIfTI image, and also to the images provided in OtherList (optional).
% Note that this SPM registration function uses a normalized mutual information (NMI) by default, enabling registration between two images
% with different contrast.
% Note that this algorithm will use the first volume of a multi-volume NIfTI
%
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% EXAMPLE: xASL_spm_coreg('/MyStudy/Subject1/T1.nii.gz', '/MyStudy/Subject1/mean_control.nii', {'/MyStudy/Subject1/M0.nii'});
% __________________________________
% Copyright 2015-2019 ExploreASL

%%  ------------------------------------------------------------------------------------------
%%   Admin, manage input, unzipping if needed
[~, refFile, refExt] = xASL_fileparts(refPath);

    
function xASL_spm_coreg(refPath, srcPath, OtherList, x, sep, FastReg)
%xASL_spm_coreg ExploreASL wrapper for SPM coregistration function (a.k.a. 'coreg')
%
% FORMAT: xASL_spm_coreg(refPath, srcPath[, OtherList, x, sep, FastReg])
%
% INPUT:
%   refPath             - path to reference space (NifTI image) you want to register the source image to (REQUIRED)
%   srcPath             - path to source image (NifTI image) you want to register (REQUIRED)
%   OtherList           - cell list with paths to NIfTI images that you want to apply the calculated transformation to (OPTIONAL)
%                         the srcPath NIfTI orientation header is always adapted with the calculated transformation
%   x                   - ExploreASL structure containing fields with global information about the pipeline environment
%                         and settings (e.g. x.settings.Quality), useful when you want this script to copy the options of an ExploreASL pipeline run (OPTIONAL)
%   sep                 - separation setting used by SPM coregistration, that defines the average distance between sampled points (in mm)
%                         can also have a vector of multiple values to allow a coarse registration with increasingly finer ones (OPTIONAL, DEFAULT=[4 2])
%   FastReg             - New experimental feature to speed up registration of low resolution images.
%                         When low resolution images are registered to high resolution images, the high resolution matrix and
%                         sep values can unnecessarily increase the precision and duration of the coregistration (e.g. from 10 to 55 seconds)
%                         This parameter is WIP, so please leave it at default setting for now(OPTIONAL, default=false)
%
% OUTPUT: n/a
%
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: This SPM wrapper runs SPMs coregister-estimate function, which calculates the 6 parameter rigid-body transformation (a.k.a. linear) that is required to
% align the source image with the reference image. This 6 parameter transformation (i.e. 3 XYZ translations and 3 rotations) is applied to
% the orientation header of the source NIfTI image, and also to the images provided in OtherList (optional).
% Note that this SPM registration function uses a normalized mutual information (NMI) by default, enabling registration between two images
% with different contrast.
% Note that this algorithm will use the first volume of a multi-volume NIfTI
%
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% EXAMPLE: xASL_spm_coreg('/MyStudy/Subject1/T1.nii.gz', '/MyStudy/Subject1/mean_control.nii', {'/MyStudy/Subject1/M0.nii'});
% __________________________________
% Copyright 2015-2019 ExploreASL

%%  ------------------------------------------------------------------------------------------
%%   Admin, manage input, unzipping if needed
[~, refFile, refExt] = xASL_fileparts(refPath);
[~, srcFile, srcExt] = xASL_fileparts(srcPath);

refFile = [refFile refExt];
srcFile = [srcFile srcExt];

if nargin<4 || isempty(x) || ~isfield(x,'settings') || ~isfield(x.settings,'Quality') || isempty(x.settings.Quality)
    x.settings.Quality = true; % default quality is high
    x.settings.DELETETEMP = true;
end