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: rejectvisual_summary.m
    path of file: ./repos/fieldtrip/private
    
    the code of the file until where you have to start completion: function [chansel, trlsel, cfg] = rejectvisual_summary(cfg, data)

% SUBFUNCTION for ft_rejectvisual

% Copyright (C) 2005-2006, Markus Bauer, Robert Oostenveld
% Copyright (C) 2006-2022, Robert Oostenveld, Jan-Mathijs Schoffelen
%
% 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,
    
function toggle_channels(h, eventdata)
info = guidata(h);

% process input from the "toggle channels" textbox
text = get(h, 'string');
set(h, 'string', '');
chans = handle_edit_input(text);                      % this can be 'all' or 'megref'
chans = ft_channelselection(chans, info.data.label);  % this is a cell-array of strings
chans = match_str(info.data.label, chans);            % this is a list of numbers

if isempty(chans)
  update_log(info.output_box, sprintf('Please enter one or more channels'));
  uiresume
  return
elseif any(chans<1)
  update_log(info.output_box, sprintf('ERROR: Channel value too small!'));
  uiresume
  return
elseif any(chans>length(info.data.label))
  update_log(info.output_box, sprintf('ERROR: Channel value too large!'));
  uiresume
  return
else
  info.chansel(chans) = ~info.chansel(chans);
  % recalculate the metric
  compute_metric(h)
  guidata(h, info);
end