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_io_SplitASL.m
    path of file: ./repos/ExploreASL/Functions/InputOutput
    
    the code of the file until where you have to start completion: function xASL_io_SplitASL(inPath, iM0, iDummy)
%xASL_io_SplitASL Splits ASL & M0 & Dummy images, when they are within the same NIfTI
%
% FORMAT: xASL_io_SplitASL(inPath[, iM0, iDummy])
%
% INPUT:
%   inPath      - path to ASL NIfTI file (e.g. //analysis/ASL_1/ASL4D.nii) (REQUIRED)
%   iM0         - index/indices of volume(s) containing the M0 (OPTIONAL, DEFAULT = [])
%   iDummy      - index/indices of volume(s) containing the Dummy scans (OPTIONAL, DEFAULT = [])
%
% OUTPUT: n/a
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: This function splits ASL4D & M0 & Dummy images if they were in the same sequence.
%              If dcm2niiX has already splitted the ASL4D NIfTI, this is reconstructed first.
%              If no M0 exists, or only ASL splitting is desired, leave iM0 empty ([]).
%              The dummy scans can be excluded from the ASL sequence during the splitting. Both iM0 and iDummy
%              are the absolute positions of both in the original time series.
%              If cbf images are included and there is a single other image like deltaM or control or label, then
%              cbf image is excluded as a dummy.
%
%              Vendor product sequence examples:
%              GE 3D spiral sometimes puts the M0 at the last volume of the series -> iM0 = [2];
%              Philips 3D GRASE puts the M0 as control-label volume pair -> iM0 = [1 2];
%              Siemens 3D GRASE puts the M0 as the first volume -> iM0 = 1;
%              Some Siemens 3D GRASE puts a second Dummy control image -> iDummy = 2;
%
% 1. Input parameter admin 
% 2.  Prepare paths
% 3.  Check for dummy volumes
% 4.  First concatenate NIfTIs
% 5.  Save M0 NIfTI
% 6.  Determine ASL indices
% 7.  Save ASL4D NIfTI
% 8.  Split relevant JSON parameters/arrays
% 9.  Split ASL4Dcontext.tsv
% 10. Modify JSON fields
% 11. Copy sidecars
% 
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% EXAMPLE: for moving the first two volumes to M0.nii:
% xASL_io_SplitASL('/data/RAD/share/EPAD500/010EPAD00001/ASL_1/ASL4D.nii', [1 2]);
% EXAMPLE 2: for concatenating files only:

    
function xASL_io_SplitASL(inPath, iM0, iDummy)
%xASL_io_SplitASL Splits ASL & M0 & Dummy images, when they are within the same NIfTI
%
% FORMAT: xASL_io_SplitASL(inPath[, iM0, iDummy])
%
% INPUT:
%   inPath      - path to ASL NIfTI file (e.g. //analysis/ASL_1/ASL4D.nii) (REQUIRED)
%   iM0         - index/indices of volume(s) containing the M0 (OPTIONAL, DEFAULT = [])
%   iDummy      - index/indices of volume(s) containing the Dummy scans (OPTIONAL, DEFAULT = [])
%
% OUTPUT: n/a
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: This function splits ASL4D & M0 & Dummy images if they were in the same sequence.
%              If dcm2niiX has already splitted the ASL4D NIfTI, this is reconstructed first.
%              If no M0 exists, or only ASL splitting is desired, leave iM0 empty ([]).
%              The dummy scans can be excluded from the ASL sequence during the splitting. Both iM0 and iDummy
%              are the absolute positions of both in the original time series.
%              If cbf images are included and there is a single other image like deltaM or control or label, then
%              cbf image is excluded as a dummy.
%
%              Vendor product sequence examples:
%              GE 3D spiral sometimes puts the M0 at the last volume of the series -> iM0 = [2];
%              Philips 3D GRASE puts the M0 as control-label volume pair -> iM0 = [1 2];
%              Siemens 3D GRASE puts the M0 as the first volume -> iM0 = 1;
%              Some Siemens 3D GRASE puts a second Dummy control image -> iDummy = 2;
%
% 1. Input parameter admin 
% 2.  Prepare paths
% 3.  Check for dummy volumes
% 4.  First concatenate NIfTIs
% 5.  Save M0 NIfTI
% 6.  Determine ASL indices
% 7.  Save ASL4D NIfTI
% 8.  Split relevant JSON parameters/arrays
% 9.  Split ASL4Dcontext.tsv
% 10. Modify JSON fields
% 11. Copy sidecars
% 
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% EXAMPLE: for moving the first two volumes to M0.nii:
% xASL_io_SplitASL('/data/RAD/share/EPAD500/010EPAD00001/ASL_1/ASL4D.nii', [1 2]);
% EXAMPLE 2: for concatenating files only:
% xASL_io_SplitASL('/data/RAD/share/EPAD500/010EPAD00001/ASL_1/ASL4D.nii', []);
% EXAMPLE 3: for moving the first two volumes to M0.ii and removing the 3rd volume as dummy:
% xASL_io_SplitASL('/data/RAD/share/EPAD500/010EPAD00001/ASL_1/ASL4D.nii', [1 2],3);
% EXAMPLE 4: for moving the third volume to M0.ii and removing the first 2 volumes as dummy:
% xASL_io_SplitASL('/data/RAD/share/EPAD500/010EPAD00001/ASL_1/ASL4D.nii', 3,[1 2]);
% EXAMPLE 5: for removing the 1st volume as dummy
% xASL_io_SplitASL('/data/RAD/share/EPAD500/010EPAD00001/ASL_1/ASL4D.nii', [],1);
% __________________________________
% Copyright 2015-2023 ExploreASL

    %% -----------------------------------------------------------------------------------------------------------------------------------------------------
    %% 1. Input parameter admin
	% Can be char or number on input, output should be a horizontal vector

	if nargin < 2 || isempty(iM0)
		iM0 = [];
	else
		iM0 = xASL_str2num(iM0);
		if size(iM0,1)>1 && size(iM0,2)>1
			warning('M0PositionInASL4D should be provided as a vector and not as a matrix')
		end