diff --git a/pointprocesses/code/binnedRate.m b/pointprocesses/code/binnedRate.m index e34366c..cf9ad65 100644 --- a/pointprocesses/code/binnedRate.m +++ b/pointprocesses/code/binnedRate.m @@ -18,7 +18,7 @@ function [time, rate] = binned_rate(spikes, bin_width, dt, t_max) rate = zeros(size(time)); h = hist(spikes, bins) ./ bin_width; for i = 2:length(bins) - rate(round(bins(i - 1) / dt) + 1:round(bins(i) / dt)) = h(i); + rate(round(bins(i-1)/dt) + 1:round(bins(i)/dt)) = h(i); end end diff --git a/pointprocesses/code/convolutionRate.m b/pointprocesses/code/convolutionRate.m index a2b1344..4fe5bb8 100644 --- a/pointprocesses/code/convolutionRate.m +++ b/pointprocesses/code/convolutionRate.m @@ -10,19 +10,18 @@ function [time, rate] = convolution_rate(spikes, sigma, dt, t_max) % t_max : the trial duration in seconds. % % Returns: - two vectors containing the time and the rate. +% two vectors containing the time and the rate. -time = 0:dt:t_max - dt; -rate = zeros(size(time)); -spike_indices = round(spikes / dt); -rate(spike_indices) = 1; -kernel = gaussKernel(sigma, dt); - -rate = conv(rate, kernel, 'same'); + time = 0:dt:t_max - dt; + rate = zeros(size(time)); + spike_indices = round(spikes / dt); + rate(spike_indices) = 1; + kernel = gaussKernel(sigma, dt); + rate = conv(rate, kernel, 'same'); end function y = gaussKernel(s, step) x = -4 * s:step:4 * s; - y = exp(-0.5 .* (x ./ s) .^ 2) ./ sqrt(2 * pi) / s; + y = exp(-0.5 .* (x ./ s).^ 2) ./ sqrt(2 * pi) / s; end diff --git a/pointprocesses/code/counthist.m b/pointprocesses/code/counthist.m index 6885b1a..67b4cae 100644 --- a/pointprocesses/code/counthist.m +++ b/pointprocesses/code/counthist.m @@ -37,8 +37,8 @@ function [counts, bins] = counthist(spikes, w) % plot: if nargout == 0 - bar( bins, counts ); - xlabel( 'counts k' ); - ylabel( 'P(k)' ); + bar(bins, counts); + xlabel('counts k'); + ylabel('P(k)'); end end diff --git a/pointprocesses/code/instantaneousRate.m b/pointprocesses/code/instantaneousRate.m index 8928c31..da8ee29 100644 --- a/pointprocesses/code/instantaneousRate.m +++ b/pointprocesses/code/instantaneousRate.m @@ -19,6 +19,6 @@ function [time, rate] = instantaneous_rate(spikes, dt, t_max) spike_indices = [1 round(spikes ./ dt)]; for i = 2:length(spike_indices) - rate(spike_indices(i - 1):spike_indices(i)) = inst_rate(i - 1); + rate(spike_indices(i-1):spike_indices(i)) = inst_rate(i-1); end end diff --git a/pointprocesses/code/isihist.m b/pointprocesses/code/isihist.m index 33ad4f5..00b02c3 100644 --- a/pointprocesses/code/isihist.m +++ b/pointprocesses/code/isihist.m @@ -13,7 +13,7 @@ function [pdf, centers] = isihist(isis, binwidth) if nargin < 2 % compute good binwidth: - nperbin = 200; % average number of data points per bin + nperbin = 200; % average number of data points per bin bins = length(isis)/nperbin; % number of bins binwidth = max(isis)/bins; if binwidth < 5e-4 % half a millisecond diff --git a/pointprocesses/code/rasterplot.m b/pointprocesses/code/rasterplot.m index 0bcdb8d..7b28820 100644 --- a/pointprocesses/code/rasterplot.m +++ b/pointprocesses/code/rasterplot.m @@ -5,25 +5,25 @@ function rasterplot(spikes, tmax) % spikes: a cell array of vectors of spike times in seconds % tmax: plot spike raster upto tmax seconds -ntrials = length(spikes); -for k = 1:ntrials - times = spikes{k}; - times = times(times