-
Notifications
You must be signed in to change notification settings - Fork 1
/
getCMAinfo.m
83 lines (60 loc) · 2.8 KB
/
getCMAinfo.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% getCMAinfo.m: Caculates the parameters for CMA burst detection
% authors: Inkeri A. Välkki, Kerstin Lenk, Jarno E. Mikkonen, Fikret E. Kapucu, Jari A. K. Hyttinen
% date: 2016 - 2019
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [CMAinfo, ISIinfo] = getCMAinfo(CMAType, SpikeTimes, IDs)
% [CMAinfo] = getCMAinfo(CMAType, ISIinfo)
% in:
% CMAtype: 'original', 'net' or 'net_alpha'
% SpikeTimes: SpikeTimes in ms in a cell
% IDs: IDs for the spike sequences
% out:
% CMAinfo: CMA parameters
% ISIinfo: ISI statistics
CMAinfo.type = CMAType;
CMAinfo.ID = IDs;
% Emre's original CMA
if strcmp(CMAType, 'original')
% Calculate ISIs & ISIinfo for all the SpikeTimes
ISIs = cellfun(@diff, SpikeTimes, 'UniformOutput', false);
ISIinfo = getISIinfo(ISIs, IDs);
% Calculate the alphas
[CMAinfo.BurstAlpha, CMAinfo.TailAlpha] = skw2alpha(ISIinfo.skewISI);
CMAinfo.BurstThreshold = nan(size(SpikeTimes));
CMAinfo.TailThreshold = nan(size(SpikeTimes));
% Calculate CMA thresholds
for n = 1:length(SpikeTimes)
[CMAinfo.BurstThreshold(n), CMAinfo.TailThreshold(n)] = alphas2ths(ISIinfo.CMAcurve{n}, CMAinfo.BurstAlpha(n), CMAinfo.TailAlpha(n));
end
% Common alpha value for all the neurons !! Is not such a good idea to use
elseif strcmp(CMAType, 'net_alpha')
% Calculate ISIs and ISIinfo
ISIs = cellfun(@diff, SpikeTimes, 'UniformOutput', false);
ISIinfo = getISIinfo(ISIs, IDs);
% Combined ISI histogram
ISIdataAll = horzcat(ISIs{:});
ISIinfoAll = getISIinfo({ISIdataAll}, {'all'});
ISIinfo = [ISIinfo;ISIinfoAll];
% Calculate the alphas
[CMAinfo.BurstAlpha, CMAinfo.TailAlpha] = skw2alpha(ISIinfoAll.skewISI);
CMAinfo.BurstThreshold = nan(size(SpikeTimes));
CMAinfo.TailThreshold = nan(size(SpikeTimes));
% Calculate CMA thresholds
for n = 1:length(SpikeTimes)
[CMAinfo.BurstThreshold(n), CMAinfo.TailThreshold(n)] = alphas2ths(ISIinfo.CMAcurve{n}, CMAinfo.BurstAlpha, CMAinfo.TailAlpha);
end
% Common thresholds for burst detection
elseif strcmp(CMAType, 'net')
% Calculate ISIs and ISIinfo
ISIs = cellfun(@diff, SpikeTimes, 'UniformOutput', false);
% Combined ISI histogram
ISIdataAll = horzcat(ISIs{:});
ISIinfoAll = getISIinfo({ISIdataAll}, {'all'});
ISIinfo = ISIinfoAll;
% Calculate the burst alphas
[CMAinfo.BurstAlpha, CMAinfo.TailAlpha] = skw2alpha(ISIinfoAll.skewISI);
% Calculate CMA thresholds
[CMAinfo.BurstThreshold, CMAinfo.TailThreshold] = alphas2ths(ISIinfoAll.CMAcurve{1}, CMAinfo.BurstAlpha, CMAinfo.TailAlpha);
end
end