-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_bursts.m
144 lines (93 loc) · 2.88 KB
/
get_bursts.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
function [ filedata ] = get_bursts( filename, progressflag )
% takes bursts from file produced by spike 2 scripts, computes things about them
% outputs data in a struct
if nargin<2
progressflag=false;
end
filedata=struct();
fid=fopen(filename,'r');
text_array=textscan(fid,'%s','delimiter',',');
text_array=text_array{1};
burst_count=(length(text_array)/12);
bursts=zeros(burst_count,8);
howmany=length(text_array);
if (howmany<10000)
progressflag=false;
end
if progressflag
ProgressBar('Importing...',howmany);
end
for i=1:length(text_array)
if progressflag
ProgressBar('Importing...');
end
burst_num=floor(i/12)+1;
data_field=rem(i,12);
switch data_field;
case 1
file_string=text_array{i};
numb='blank';
this='blank';
lastthis='blank';
while(strcmp(numb,'blank'))
[this, file_string]=strtok(file_string,'_');
if (strcmp(this,''))
numb=lastthis;
end
lastthis=this;
end
bursts(burst_num,1)=str2double(numb);
case 2
bursts(burst_num,2)=str2double(text_array{i});
case 3
bursts(burst_num,3)=str2double(text_array{i});
case 4
bursts(burst_num,4)=str2double(text_array{i});
case 5
bursts(burst_num,5)=str2double(text_array{i});
case 9
bursts(burst_num,6)=str2double(text_array{i});
% case 10
%
% bursts(burst_num,7)=str2double(text_array{i});
%
% case 11
%
% bursts(burst_num,8)=str2double(text_array{i});
%
% case 0
%
% bursts(burst_num-1,9)=str2double(text_array{i});
%
end
end
bursts=flipud(bursts);
starts=bursts(:,4);
ends=bursts(:,5);
if (length(starts) < 3)
hz=nan;
duty=nan;
duration=nan;
anic=nan;
end
hz=zeros(length(starts)-1,1);
duty=zeros(length(starts)-1,1);
duration=zeros(length(starts),1);
anic=zeros(length(starts)-2,1);
for i=1:(length(starts)-1)
hz(i)=1/(starts(i+1)-starts(i));
duty(i)=(ends(i)-starts(i))/(starts(i+1)-starts(i));
duration(i)=ends(i)-starts(i);
end
for i=1:(length(hz)-1)
anic(i)= abs(hz(i+1)-hz(i)) / hz(i);
end
filedata.tstart=bursts(:,4);
filedata.tend=bursts(:,5);
filedata.hz=hz;
filedata.dutycycle=duty;
filedata.burstlength=duration;
filedata.anic=anic;
filedata.filenums=bursts(:,1);
filedata.spikecount=bursts(:,6);
end