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: clusterstat.m
    path of file: ./repos/malini/Codes/deconvolution - model/spm8/external/fieldtrip/private
    
    the code of the file until where you have to start completion: function [stat, cfg] = clusterstat(cfg, statrnd, statobs, varargin)

% SUBFUNCTION for computing cluster statistic for N-D volumetric source data
% or for channel-freq-time data
%
% This function uses
%   cfg.dim
%   cfg.inside (only for source data)
%   cfg.tail = -1, 0, 1
    
function channeighbstructmat = makechanneighbstructmat(cfg);

% MAKECHANNEIGHBSTRUCTMAT makes the makes the matrix containing the channel
% neighbourhood structure.

% because clusterstat has no access to the actual data (containing data.label), this workaround is required
% cfg.neighbours is cleared here because it is not done where avgoverchan is effectuated (it should actually be changed there)
if strcmp(cfg.avgoverchan, 'no')
  nchan=length(cfg.channel);
elseif strcmp(cfg.avgoverchan, 'yes')
  nchan = 1;
  cfg.neighbours = [];
end