-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwaveform.asv
More file actions
executable file
·55 lines (47 loc) · 2.05 KB
/
waveform.asv
File metadata and controls
executable file
·55 lines (47 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% WAVEFORM() function
%
% Given a signal trace F and vector of indices i that indicate
% spike locations in F, construct a 2-D array where each row
% contains a window around each spike in F. The window is
% defined using the prespike and postspike arguments.
%_______________________________________________________________
% Arguments:
% F = vector of voltages in the signal.
% i = vector of spike locations in F; can be obtained
% using i = find(D~=0) at command line.
% prespike = time interval in milliseconds between the
% start of waveform window and the spike peak.
% postspike = time interval in milliseconds between the
% spike peak and the end of waveform window.
%_______________________________________________________________
% Returns:
% W = 2-D array where each row contains a window around
% each spike in F.
%_______________________________________________________________
% (c) 2003 Witold J. Lipski. Please feel free to copy
% and/or modify this code. Questions/Comments: wjl3@pitt.edu
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [W, Wm, Ws] = waveform(F, i, sf, prespike, postspike, filename)
unit = 1000; %display millisecs
prespike = prespike*sf/unit; %convert to samples
postspike = postspike*sf/unit; %convert to samples
timescale = unit*((1:(prespike+postspike+1))-prespike-1)/sf;
for(j = 1:length(i))
if((i(j)-prespike)>0 & (i(j)+postspike)<=length(F))
W(:,j)=F(i(j)-prespike:i(j)+postspike);
end
end
Wm = mean(W, 2);
Ws = std(W, 0, 2);
figure;
plot(timescale, Wm, 'LineWidth', 2);
hold on
%plot(timescale, Wm-Ws, '--')
%plot(timescale, Wm+Ws, '--')
plot(timescale, Wm-Ws, '--')
plot([0 0], ylim, ':', 'color', 'red')
xlim(unit*[-prespike postspike]/sf);
ylabel('mV');
xlabel('ms');
title([filename, ' waveform mean +/- std']);