calculates peri-stimulus time histogram (PSTH) + variance of neural spike times

ダウンロード: 430

更新 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 (2023). CalculatePSTH(SpikeTimes,start,varargin) (, MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2013a
Windows macOS Linux
Help Center および MATLAB AnswersElectrophysiology についてさらに検索
タグ タグを追加

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート

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