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

% MEM 6gb
% WALLTIME 00:10:00
% DEPENDENCY
% DATA public

% Reading in spike data
% 
% Make sure you run ft_defaults after having added the main FieldTrip path (e.g. addpath('path_to_fieldtrip')), ensuring that the required functions are in your MATLAB path. For spike analysis there is spike toolbox that is located in fieldtrip/contrib/spike.
% 
% Spike data can be read out using the function ft_read_spike. At the time of writing this tutorial the supported formats are neurosim, mclust t files, neuralynx (nse, nst, ntt, nts) and plexon (nex and plx) files.. The original data can be obtained from ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/spike/p029_sort_final_01.nex. After reading out the spike data, we select the spike channels of interest.

cd (dccnpath('/home/common/matlab/fieldtrip/data/ftp/tutorial/spike'));

spike = ft_read_spike('p029_sort_final_01.nex'); 
 
cfg              = [];
cfg.spikechannel = {'sig002a_wf', 'sig003a_wf'}; % select only the two single units
spike = ft_spike_select(cfg, spike);

% one obtains a so called spike structure (see ft_datatype_spike). In this spike structure we simply gather the raw spike data (timestamps of spikes and waveforms) for multiple cells, which are identified through their labels:
% 
% spike = 
%  
%         label: {'sig002a_wf'  'sig003a_wf'}
%     timestamp: {[1x164456 int32]  [1x134803 int32]}
%      waveform: {[1x32x164456 double]  [1x32x134803 double]}
%          unit: {[1x164456 double]  [1x134803 double]}
%           hdr: [1x1 struct]
%        dimord: '{chan
    
function ft_spike_psth.
% 
% Running
 
cfg             = []; 
cfg.binsize     =  0.1; % if cfgPsth.binsize = 'scott' or 'sqrt', we estimate the optimal bin size from the data itself
cfg.outputunit  = 'rate'; % give as an output the firing rate
cfg.latency     = [-1 3]; % between -1 and 3 sec.
cfg.vartriallen = 'yes'; % variable trial lengths are accepted
cfg.keeptrials  = 'yes'; % keep the psth per trial in the output
psth = ft_spike_psth(cfg,spikeTrials);
% gives us the output

% psth = 
%  
%            avg: [2x40 double]
%            var: [2x40 double]
%            dof: [2x40 double]
%        fsample: 10
%           time: [1x40 double]
%          label: {'sig002a_wf'  'sig003a_wf'}
%          trial: [600x2x40 double]
%         dimord: 'rpt_chan_time'
%     sampleinfo: [600x2 double]
%            cfg: [1x1 struct]
% The PSTH structure is a so called 'timelock' data structure (ft_datatype_timelock, and can as such be used in all functions taking timelock structures as an input. The field psth.avg contains the average firing rates per bin per unit, and psth.trial contains the average firing rate per trial per unit per time-bin. It is also possible (but less computationally efficient) to enter the binary spike trains that are stored in a continuous raw format. The data is then automatically converted to a spike structure within ft_spike_psth.
% 
% A raster plot with psth is obtained by running
% 
cfg         = [];
cfg.binsize =  [0.05];
cfg.latency = [-1 3];
psth = ft_spike_psth(cfg,spikeTrials);
 
cfg              = [];
cfg.topplotfunc  = 'line'; % plot as a line
cfg.spikechannel = spikeTrials.label([1 2]);
cfg.latency      = [-1 3];
cfg.errorbars    = 'std'; % plot with the standard deviation
cfg.interactive  = 'no'; % toggle off interactive mode
figure, ft_spike_plot_raster(cfg,spikeTrials, psth) 

% 
% The yellow lines in the raster plot indicate the trial borders. Configuration options are available to control spike length and width, and size of the raster relative to the summarizing PSTH / spike density data. Also, multiple neurons are plotted with different colors. This can also be used to plot multiple conditions at the same time.
% 
% We then run spike-density functions on the spike trains, to obtain spike density with rasters. The advantage of the spike-density function is that an estimate of the instantaneous firing rate or expected spike count can be obtained for every time-point, instead of larger bins (as with the PSTH).

cfg         = [];
cfg.latency = [-1 3]; 
cfg.timwin  = [-0.025 0.025];
cfg.fsample = 1000; % sample at 1000 hz
sdf = ft_spikedensity(cfg,spikeTrials);
cfg              = [];
cfg.topplotfunc  = 'line'; % plot as a line plot
cfg.spikechannel = spikeTrials.label([1 2]); % can also select one unit here
cfg.latency      = [-1 3];
cfg.errorbars    = 'std'; % plot with standard deviation
cfg.interactive  = 'no'; % toggle off interactive mode
figure, ft_spike_plot_raster(cfg,spikeTrials, sdf) 

% 
% The output from ft_spikedensity is again a timelock structure. A second output can be obtained from ft_spikedensity, containing the estimated spike densities per trial in a continuous raw data structure. To this end