CalculatePSTH(Spike​Times,start,varargi​n)

版本 1.0.0.0 (8.9 KB) 作者: Jordan Sorokin
calculates peri-stimulus time histogram (PSTH) + variance of neural spike times
455.0 次下载
更新时间 2016/2/19

查看许可证

% ---------[psth] = CalculatePSTH(SpikeTimes,EventTimes,varargin)-------------
%
% Calculates peri-stimulus time histograms (PSTHs) from a matrix or cell
% array of spiketimes (in seconds), given a user-defined bin-width. Plots
% PSTHs and saves in current directory.
%
% >>> INPUTS >>>
% Required:
% SpikeTimes = matrix or cell of spiketimes in SECONDS
% If matrix, will assume columns are trials, rows are spiketimes.
% If cell, will assume each cell is a trial, and in each cell
% columns are channels, rows are spiketimes.
% start = n-element vector containing times of events (in seconds)...if
% spiketimes are relative (i.e. blocks of spikeitmes, each block relative
% to stim onset), then user should define "start" as the time of the
% onset of the stim relative to the start of the block. For instance, if
% stim is 6 seconds into the start of each block, then set "start" = 6.
% * if spikes NOT relative, start = nx1 array of starting times.
% Optional:
% pre_time = time (in SECONDS) to subtract from starting time...
% makes plots relative to stim onset (default = 1s);
% post_time = time (in SECONDS) to add to starting time...
% (default = 1s);
% bin_width = bin (ms) for PSTH calculation. Default = 10ms.
% name = name to save figure (default = "psth.pdf")
% saving = 0 or 1 (default 1). If 1, saves figures to current directory.
%
% <<< OUTPUTS <<<
% psth = bin-counts of spiketimes occuring within specified time range.
% If SpikeTimes is a cell array, psth is an nxtrialsxchan matrix.
% If SpikeTimes is a matrix, psth is an nxtrials matrix
% psthTrialAvg = average of psth across trials per channel
% varTrialAvg = average variance of psth across trials per channel
%
% Example:
% SpikeTimes{1} = sort(rand(100)); % fake spiketimes for ch1
% SpikeTimes{2} = sort(rand(100)); % fake spiketimes for ch2
% [psth,trialAvg,varAvg] = CalculatePSTH(SpikeTimes,.5,.2,.5,10,'control',1)
% % plots histogram and variances for each channel, from -0.2s : 0.5s
% % around the starting point, (here 0.5s into the SpikeTimes). Save
% % the figures and appends "control" to the figure name
%
% By JMS, 11/13/2015
%-------------------------------------------------------

引用格式

Jordan Sorokin (2024). CalculatePSTH(SpikeTimes,start,varargin) (https://www.mathworks.com/matlabcentral/fileexchange/55460-calculatepsth-spiketimes-start-varargin), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2013a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Electrophysiology 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0

commented on the requirement of this function on "EdgeCalculator", another function I've created for segmenting spike times based on bin widths