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: create_ppg_beat_detection_fig.m
    path of file: ./repos/ppg-beats/source/figures
    
    the code of the file until where you have to start completion: function create_ppg_beat_detection_fig(data)

close all

% load data
filepath = '/Users/petercharlton/Documents/Data/mimiciii_ppg_neonate_adult_beat_detection/mimic_train_a_data.mat';
if nargin==0
    load(filepath);
end

% create assessment framework plot
create_assessment_framework_plot(data);


    
function create_ppg_beat_detection_fig(data)

close all

% load data
filepath = '/Users/petercharlton/Documents/Data/mimiciii_ppg_neonate_adult_beat_detection/mimic_train_a_data.mat';
if nargin==0
    load(filepath);
end

% create assessment framework plot
create_assessment_framework_plot(data);

% select signal of interest
subj_no = 3;
durn = 10;
buffer = 5;
S_orig = data(subj_no).ppg;
rel_els = 1:(1+durn*S_orig.fs+2*buffer*S_orig.fs);
rel_els2 = rel_els + 1000;
rel_els1 = rel_els + 49800;

% make figure
figure('Position', [20,20,500,400])

% cycle through each sample
for sample_no = 1 :2
    
    eval(['curr_rel_els = rel_els' num2str(sample_no) ';']);
    S.v = S_orig.v(curr_rel_els);
    S.fs = S_orig.fs;
    
    %% - filter signal
    
    % - Fiducial Points: eliminating high freqs
    uParams.analysis.filtering.elim_high_freqs.Fpass = 10;   % in HZ
    uParams.analysis.filtering.elim_high_freqs.Fstop = 6.93;   % in HZ   % 6.93 - 10 gives -3dB cutoff of 8.00 Hz
    uParams.analysis.filtering.elim_high_freqs.Dpass = 0.05;
    uParams.analysis.filtering.elim_high_freqs.Dstop = 0.01;
    
    % - Fiducial Points: eliminating low freqs
    uParams.analysis.filtering.elim_low_freqs.Fpass = 1.02;  % in Hz
    uParams.analysis.filtering.elim_low_freqs.Fstop = 0.6;  % in Hz      % 0.6 - 1.02 gives -3dB cutoff of 40 bpm (i.e. 0.67 Hz)
    uParams.analysis.filtering.elim_low_freqs.Dpass = 0.05;
    uParams.analysis.filtering.elim_low_freqs.Dstop = 0.01;
    
    % - setup PulseAnalyse options for filtering
    options.elim_high_freqs = uParams.analysis.filtering.elim_high_freqs;
    options.elim_low_freqs = uParams.analysis.filtering.elim_low_freqs;
    options.calc_pw_inds = 0;
    options.do_plot = 0;
    options.do_beats = 0;
    options.do_quality = 0;
    options.close_figures = 0;
    
    % Downsample and filter PPG signal
    [~, ~, ~, sigs] = PulseAnalyse(S, options);
    S.v = sigs.filt;
    S.fs = sigs.fs;
    clear options
    
    % specify beat detectors
    beat_detectors = {'MSPTD', 'Pulses'};
    
    % detect beats
    for beat_detector_no = 1 : length(beat_detectors)
        curr_detector = beat_detectors{beat_detector_no};
        
        %% - beat detection
        
        % - setup PulseAnalyse options for beat detection
        options.calc_pw_inds = 0;
        options.do_plot = 0;
        options.do_beat_filter = 0;
        options.do_filter = 0;
        options.do_quality = 0;
        options.close_figures = 0;
        options.beat_detector = curr_detector;
        
        % - detect beats in this subject's PPG signals using this peak detector
        [~, ~, pulses, ~] = PulseAnalyse(S, options);
        peaks{beat_detector_no,1} = pulses.peaks;
        clear options pulses
        
    end