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: ULM_tracking2D.m
    path of file: ./repos/PALA/PALA/PALA_addons/ULM_toolbox
    
    the code of the file until where you have to start completion: function varargout = ULM_tracking2D(MatTracking,ULM,varargin)
%% function varargout = ULM_tracking2D(MatTracking,ULM,varargin)
% Takes bubbles positions and returns a lists of tracks. The pairing of bubbles is based
% on partial assignment and minimization of the total distance with 'simpletracker' and
% munkres implementation (from Jean-Yves Tinevez https://github.com/tinevez/simpletracker).
% It takes a cellstruct containing the bubbles' positions of the current frame (cell(ii) = positions of bubbles at frame ii).
% Short tracks are remove because not consistent. Long tracks are then interpolated to
% later correctly fill the density MatOut.
% All parameters must have the same unit (bubbles position, max_linking_distance), it can be mm, wavelength, um...
%
% Different modes have been implemented:
%       - nointerp : raw tracks [z x iFrame]
%       - interp : interpolation of track [zi xi] using interp_factor (1/interp_factor more points)
%       - velocityinterp : interpolation of tracks and calculate lateral/axial velocities [z x vz vx timeline]
%       - pala : return raw tracks AND interpolated tracks
%
% INPUTS:
%       - MatTracking is a[4 Nparticles*Nframes] matrix sorting bubble's information [intensity, z position, x position, frame number]
%       - numberOfFrames
%       - ULM.max_linking_distance is the maximal distance between 2 bubbles that can be paired
%       - ULM.max_gap_closing is maximal gap of frame accepted to pair bubbles.
%       - ULM.min_length is the minimal length of tracks
%       - ULM.scale is the scale of data, [scale_z scale_x scale_t] (scale_z=scale_x=1, scale_t=1/FrameRate for velocity)
%       - mode is the method used to post process tracks (ie. interpolation, velocity measurement...)
% OUTPUTS:
%       - Tracks is a cellstruct containing the list of coordinates of each tracks.

    
function varargout = ULM_tracking2D(MatTracking,ULM,varargin)
%% function varargout = ULM_tracking2D(MatTracking,ULM,varargin)
% Takes bubbles positions and returns a lists of tracks. The pairing of bubbles is based
% on partial assignment and minimization of the total distance with 'simpletracker' and
% munkres implementation (from Jean-Yves Tinevez https://github.com/tinevez/simpletracker).
% It takes a cellstruct containing the bubbles' positions of the current frame (cell(ii) = positions of bubbles at frame ii).
% Short tracks are remove because not consistent. Long tracks are then interpolated to
% later correctly fill the density MatOut.
% All parameters must have the same unit (bubbles position, max_linking_distance), it can be mm, wavelength, um...
%
% Different modes have been implemented:
%       - nointerp : raw tracks [z x iFrame]
%       - interp : interpolation of track [zi xi] using interp_factor (1/interp_factor more points)
%       - velocityinterp : interpolation of tracks and calculate lateral/axial velocities [z x vz vx timeline]
%       - pala : return raw tracks AND interpolated tracks
%
% INPUTS:
%       - MatTracking is a[4 Nparticles*Nframes] matrix sorting bubble's information [intensity, z position, x position, frame number]
%       - numberOfFrames
%       - ULM.max_linking_distance is the maximal distance between 2 bubbles that can be paired
%       - ULM.max_gap_closing is maximal gap of frame accepted to pair bubbles.
%       - ULM.min_length is the minimal length of tracks
%       - ULM.scale is the scale of data, [scale_z scale_x scale_t] (scale_z=scale_x=1, scale_t=1/FrameRate for velocity)
%       - mode is the method used to post process tracks (ie. interpolation, velocity measurement...)
% OUTPUTS:
%       - Tracks is a cellstruct containing the list of coordinates of each tracks.
%
% This function was created by Baptiste Heiles 07/04/17, last modifications Arthur Chavignon, 18/11/19
%
% Requirements: this function requires a two additional functions from the MathWorks
% Community and should be downloaded and add to the path.
%       - 'simpletracker.m' : Jean-Yves Tinevez (2020). simpletracker (https://www.github.com/tinevez/simpletracker), GitHub. Retrieved April 22, 2020.
%           https://fr.mathworks.com/matlabcentral/fileexchange/34040-simpletracker)
%       - 'munkres.m': by Yi Cao at Cranfield University on 17th June 2008 (http://csclab.murraystate.edu/bob.pilgrim/445/munkres.html)
%           https://fr.mathworks.com/matlabcentral/fileexchange/20328-munkres-assignment-algorithm
%
% DATE 2020.07.22 - VERSION 1.1
% AUTHORS: Arthur Chavignon, Baptiste Heiles, Vincent Hingot. CNRS, Sorbonne Universite, INSERM.
% Laboratoire d'Imagerie Biomedicale, Team PPM. 15 rue de l'Ecole de Medecine, 75006, Paris
% Code Available under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (see https://creativecommons.org/licenses/by-nc-sa/4.0/)
% ACADEMIC REFERENCES TO BE CITED
% Details of the code in the article by Heiles, Chavignon, Hingot, Lopez, Teston and Couture.  
% Performance benchmarking of microbubble-localization algorithms for ultrasound localization microscopy, Nature Biomedical Engineering, 2021.
% General description of super-resolution in: Couture et al., Ultrasound localization microscopy and super-resolution: A state of the art, IEEE UFFC 2018

if nargin>2
    mode=lower(varargin{1});
else
    mode='velocityinterp'; % default mode
end