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_imp_Initialize.m
    path of file: ./repos/ExploreASL/Functions/Import
    
    the code of the file until where you have to start completion: function imPar = xASL_imp_Initialize(studyPath, imParPath)
%xASL_imp_Initialize Initialize the import.
%
% FORMAT: imPar = xASL_imp_Initialize(studyPath, imParPath)
% 
% INPUT:
%   studyPath  - Path to the study directory containing the 'sourcedata' directory with the DICOM files (REQUIRED, CHAR ARRAY)
%   imParPath  - Path to the JSON file with structure with import parameters (REQUIRED, CHAR ARRAY)
%
% OUTPUT:
%   imPar      - JSON file with structure with import parameters (REQUIRED, STRUCT)
%                         
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: Initialize DCM2NII.
%
% 1. Read study file
% 2. Specify paths
% 3. Finalize the directories
% 4. Specify the tokens
% 5. Specify the additional details of the conversion
%
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% EXAMPLE:     imPar = xASL_imp_Initialize(studyPath, imParPath);
% __________________________________
% Copyright 2015-2023 ExploreASL

    %% 1. Read study file


    
function imPar = xASL_imp_Initialize(studyPath, imParPath)
%xASL_imp_Initialize Initialize the import.
%
% FORMAT: imPar = xASL_imp_Initialize(studyPath, imParPath)
% 
% INPUT:
%   studyPath  - Path to the study directory containing the 'sourcedata' directory with the DICOM files (REQUIRED, CHAR ARRAY)
%   imParPath  - Path to the JSON file with structure with import parameters (REQUIRED, CHAR ARRAY)
%
% OUTPUT:
%   imPar      - JSON file with structure with import parameters (REQUIRED, STRUCT)
%                         
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: Initialize DCM2NII.
%
% 1. Read study file
% 2. Specify paths
% 3. Finalize the directories
% 4. Specify the tokens
% 5. Specify the additional details of the conversion
%
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% EXAMPLE:     imPar = xASL_imp_Initialize(studyPath, imParPath);
% __________________________________
% Copyright 2015-2023 ExploreASL

    %% 1. Read study file

    % Initialize the imPar field
    [fpath, fname, fext] = fileparts(studyPath);

    % Load the imPar from the file
    if ~isempty(imParPath) && xASL_exist(imParPath,'file')==2
        % DCM2NII
        imPar = xASL_io_ReadJson(imParPath);
    else
        % NII2BIDS, DEFACE & BIDS2LEGACY
        imPar = struct;
    end