mse.timescales = 1000 ./ mse.fsample; % by convention
mse.time = toi;
mse.dimord = 'chan_timescales_time';
mse.sampen = sampen;
mse.r = squeeze(nanmean(r_estimate,4)); % average across starting points
if isfield(data, 'trialinfo')
mse.trialinfo = data.trialinfo;
end
mse.config = cfg;
% do the general cleanup and bookkeeping at the end of the function
ft_postamble debug % this clears the onCleanup function used for debugging in case of an error
ft_postamble trackconfig % this converts the config object back into a struct and can report on the unused fields
ft_postamble previous data % this copies the data.cfg structure into the cfg.previous field. You can also use it for multiple inputs, or for "varargin"
ft_postamble provenance mse % this records the time and memory at the end of the function, prints them on screen and adds this information together with the function name and MATLAB version etc. to the output cfg
ft_postamble history mse % this adds the local cfg structure to the output data structure, i.e. dataout.cfg = cfg
ft_postamble savevar mse % this saves the output data structure to disk in case the user specified the cfg.outputfile option