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: ft_filter_event.m
    path of file: ./repos/bspm/thirdparty/spm12/external/fieldtrip/fileio
    
    the code of the file until where you have to start completion: function event = ft_filter_event(event, varargin)

% FT_FILTER_EVENT does what its name implies
%
% Use as
%   event = ft_filter_event(event, ...)
%
% The optional arguments should come in key-value pairs and determine the
% filter characteristics:

    
function event = ft_filter_event(event, varargin)

% FT_FILTER_EVENT does what its name implies
%
% Use as
%   event = ft_filter_event(event, ...)
%
% The optional arguments should come in key-value pairs and determine the
% filter characteristics:
%   type         = cell-array with strings
%   value        = numeric array
%   sample       = numeric array
%   timestamp    = numeric array
%   offset       = numeric array
%   duration     = numeric array
%   minsample    = value
%   maxsample    = value
%   minduration  = value
%   maxduration  = value
%   mintimestamp = value
%   maxtimestamp = value
%   minnumber    = value, applies only if event.number is present
%   maxnmumber   = value, applies only if event.number is present
%
% See also FT_READ_EVENT, FT_WRITE_EVENT

% Copyright (C) 2007-2010 Robert Oostenveld
%
% This file is part of FieldTrip, see http://www.fieldtriptoolbox.org
% for the documentation and details.
%
%    FieldTrip is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    FieldTrip is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with FieldTrip. If not, see <http://www.gnu.org/licenses/>.
%
% $Id$

% get the optional input arguments
type         = ft_getopt(varargin, 'type');
value        = ft_getopt(varargin, 'value');
sample       = ft_getopt(varargin, 'sample');
timestamp    = ft_getopt(varargin, 'timestamp');
offset       = ft_getopt(varargin, 'offset');
duration     = ft_getopt(varargin, 'duration');

% the numeric fields can also be filtered on a range
minsample    = ft_getopt(varargin, 'minsample');
maxsample    = ft_getopt(varargin, 'maxsample');
minduration  = ft_getopt(varargin, 'minduration');
maxduration  = ft_getopt(varargin, 'maxduration');
mintimestamp = ft_getopt(varargin, 'mintimestamp');
maxtimestamp = ft_getopt(varargin, 'maxtimestamp');
minnumber    = ft_getopt(varargin, 'minnumber');
maxnumber    = ft_getopt(varargin, 'maxnumber');

if ~isempty(type) && ~iscell(type)
  % this can be specified as string or as cell-array, convert to cell-array
  type = {type};
end