-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_ts.m
67 lines (58 loc) · 1.61 KB
/
get_ts.m
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
56
57
58
59
60
61
62
63
64
65
66
67
% GET_TS get spike timestamps
%
% $Id: get_ts.m 779 2010-03-10 00:18:25Z joey $
%
% input:
%
% fname - string identifying a mat file to load (from plx2mat)
% usortflag - flag indicates inclusion of unsorted units (defaults to false)
%
% output:
%
% spikes - matrix of spikes [total number of spikes x 2] first col is time, second col is neuron identity
% names - cell array of spike channel names (maps with identity)
function [spikes,names] = get_ts(fname,varargin)
global DATADIR
global mk
error(nargchk(1,2,nargin,'struct'));
usortflag = 0;
for i=2:nargin
if (i==2)
usortflag = varargin{i-1};
end
end
try
if(strmatch(mk,'mango'))
ismango = true;
else
ismango = false;
end
catch
i
end
% ismango = false;
% put timestamp data in a sensible format
if(ismango)
rgxp = '^(LHA|LHL|RHA|RHL|sig)\d?_?\d{3}[abcd]$';
load(fname{1},'-regexp',rgxp);
sigs = who('-regexp',rgxp);
else
% rgxp = '^(L|R|sig)\d\(A|B|C)?_?d{3}';
rgxp = '^(L|R|sig)\d\(A|B|C)?';
% rgxp = '^(L|R)?';
load(fname{1},'-regexp',rgxp);
% clear *_wf *_fit *_thr *_tem *_wf_ts
sigs = who('-regexp',rgxp);
if length(sigs)< 2
rgxp = '^(sig)\d?_?\d{3}[abcd]$';
load(fname{1},'-regexp',rgxp);
sigs = who('-regexp',rgxp);
end
end
ts = []; ident = [];
for i=1:size(sigs,1);
ts = [ ts ; eval(sigs{i}) ];
ident = [ ident ; i*ones(size(eval(sigs{i}))) ];
end
spikes = [ ts ident ];
names = sigs;