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_stat_GetAcquisitionTime.m
    path of file: ./repos/ExploreASL/Modules/SubModule_Population
    
    the code of the file until where you have to start completion: function x = xASL_stat_GetAcquisitionTime(x)
%xASL_stat_GetAcquisitionTime Summarize the acquisition time of scans
%
% FORMAT: [x] = xASL_stat_GetAcquisitionTime(x)
% 
% INPUT:
%   x   - struct containing pipeline environment parameters (REQUIRED)
%
% INPUTFILES: can be any combination of *parms.mat (legacy) and *.json
%
% OUTPUT: /MyStudy/Population/Stats/AcquisitionTime.jpg - AcquisitionTime
%                                                         histogram for total study population
% 
%                         
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: This functions collects the DICOM field AcquisitionTime from
% each json sidecar (& parms.mat for backward compatibility) and saves them
% in the participants.tsv. Additionally, it creates a AcquisitionTime histogram of the
% full study, which can be useful to check time of scanning -> can
% influence physiological CBF variability.
%
% 1. Collect times
% 2. Save times
% 3. Create time histogram
% 
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% EXAMPLE: x = xASL_stat_GetAcquisitionTime(x);
% __________________________________
% Copyright 2016-2021 ExploreASL



    %% -----------------------------------------------------------------------------------------------
    %% 1) Collect times
    fprintf('%s\n','Loading AcquisitionTimes:  ');
    for iSubject=1:x.dataset.nSubjects
        for iSession=1:x.dataset.nSessions
            
            % Track progress
            iSubjSess = ((iSubject-1)*x.dataset.nSessions)+iSession;
            xASL_TrackProgress(iSubjSess,x.dataset.nSubjectsSessions);

            % Initialize defaults
            AcquisitionTime{iSubjSess,1} = x.SUBJECTS{iSubject};
            AcquisitionTime{iSubjSess,2} = x.SESSIONS{iSession};
            AcquisitionTime{iSubjSess,3} = NaN;
            MissingData(iSubjSess,1) = 1;

            % Define paths
            PathMAT = fullfile(x.D.ROOT, x.SUBJECTS{iSubject}, x.SESSIONS{iSession}, 'ASL4D_parms.mat'); % legacy
            Parms = xASL_adm_LoadParms(PathMAT,[],0);
			
			%PathJSON = fullfile(x.D.ROOT, x.SUBJECTS{iSubject}, x.SESSIONS{iSession}, 'ASL4D.json');
			%Parms = xASL_io_ReadJson(PathJSON);
		           

    
function x = xASL_stat_GetAcquisitionTime(x)
%xASL_stat_GetAcquisitionTime Summarize the acquisition time of scans
%
% FORMAT: [x] = xASL_stat_GetAcquisitionTime(x)
% 
% INPUT:
%   x   - struct containing pipeline environment parameters (REQUIRED)
%
% INPUTFILES: can be any combination of *parms.mat (legacy) and *.json
%
% OUTPUT: /MyStudy/Population/Stats/AcquisitionTime.jpg - AcquisitionTime
%                                                         histogram for total study population
% 
%                         
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: This functions collects the DICOM field AcquisitionTime from
% each json sidecar (& parms.mat for backward compatibility) and saves them
% in the participants.tsv. Additionally, it creates a AcquisitionTime histogram of the
% full study, which can be useful to check time of scanning -> can
% influence physiological CBF variability.
%
% 1. Collect times
% 2. Save times
% 3. Create time histogram
% 
% -----------------------------------------------------------------------------------------------------------------------------------------------------
% EXAMPLE: x = xASL_stat_GetAcquisitionTime(x);
% __________________________________
% Copyright 2016-2021 ExploreASL



    %% -----------------------------------------------------------------------------------------------
    %% 1) Collect times
    fprintf('%s\n','Loading AcquisitionTimes:  ');
    for iSubject=1:x.dataset.nSubjects
        for iSession=1:x.dataset.nSessions
            
            % Track progress
            iSubjSess = ((iSubject-1)*x.dataset.nSessions)+iSession;
            xASL_TrackProgress(iSubjSess,x.dataset.nSubjectsSessions);

            % Initialize defaults
            AcquisitionTime{iSubjSess,1} = x.SUBJECTS{iSubject};
            AcquisitionTime{iSubjSess,2} = x.SESSIONS{iSession};
            AcquisitionTime{iSubjSess,3} = NaN;
            MissingData(iSubjSess,1) = 1;

            % Define paths
            PathMAT = fullfile(x.D.ROOT, x.SUBJECTS{iSubject}, x.SESSIONS{iSession}, 'ASL4D_parms.mat'); % legacy
            Parms = xASL_adm_LoadParms(PathMAT,[],0);
			
			%PathJSON = fullfile(x.D.ROOT, x.SUBJECTS{iSubject}, x.SESSIONS{iSession}, 'ASL4D.json');
			%Parms = xASL_io_ReadJson(PathJSON);
		           
            if isfield(Parms,'AcquisitionTime')
                AcquisitionTime{iSubjSess,3} = min(Parms.AcquisitionTime);
                AcquisitionTimeN(iSubjSess,1) = min(Parms.AcquisitionTime); % for histogram below
                MissingData(iSubjSess,1) = 0;
            end