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: test_ft_badchannel.m
    path of file: ./repos/fieldtrip/test
    
    the code of the file until where you have to start completion: function test_ft_badchannel

% WALLTIME 00:10:00
% DATA public
% MEM 1gb

dataset = dccnpath('/home/common/matlab/fieldtrip/data/ftp/test/ctf/Subject01.ds');

ft_debug off
interactive = false;

%%

cfg = [];
cfg.dataset = dataset;
cfg.channel = 'MEG';
cfg.trl = [1 7*3*300 0]; % first 7 trials, each of 3 seconds
cfg.continuous = 'yes';
cfg.demean = 'yes';
datacnt = ft_preprocessing(cfg);

cfg = [];
cfg.length = 1;
datatrl = ft_redefinetrial(cfg, datacnt);

%%

    
function test_ft_badchannel

% WALLTIME 00:10:00
% DATA public
% MEM 1gb

dataset = dccnpath('/home/common/matlab/fieldtrip/data/ftp/test/ctf/Subject01.ds');

ft_debug off
interactive = false;

%%

cfg = [];
cfg.dataset = dataset;
cfg.channel = 'MEG';
cfg.trl = [1 7*3*300 0]; % first 7 trials, each of 3 seconds
cfg.continuous = 'yes';
cfg.demean = 'yes';
datacnt = ft_preprocessing(cfg);

cfg = [];
cfg.length = 1;
datatrl = ft_redefinetrial(cfg, datacnt);

%%

cfg = [];
cfg.method = 'template';
neighbours = ft_prepare_neighbours(cfg, datatrl);

%%

if interactive
  % this can be used to determine the thresholds
  cfg = [];
  cfg.method = 'summary';
  cfg.neighbours = neighbours;
  cfg.metric = 'var';
  data_rejected = ft_rejectvisual(cfg, datatrl);
end