Skip to content

Commit 3a7b863

Browse files
committed
Re-initialization
0 parents  commit 3a7b863

File tree

756 files changed

+142551
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

756 files changed

+142551
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.npy filter=lfs diff=lfs merge=lfs -text

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.asv
2+
*.mexa64
3+
*.nfs*

Classes/MEArecording.m

Lines changed: 1978 additions & 0 deletions
Large diffs are not rendered by default.

Classes/RecordingGroup.m

Lines changed: 2262 additions & 0 deletions
Large diffs are not rendered by default.

Classes/Unit.m

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
classdef Unit < handle
2+
properties
3+
MEArecording
4+
ReferenceWaveform
5+
ReferenceElectrode
6+
TemplateID %Added
7+
SpikeTimes
8+
WaveformFeatures
9+
ActivityFeatures
10+
RegularityFeatures
11+
GraphFeatures
12+
Catch22
13+
end
14+
15+
properties(SetObservable = true)
16+
ClusterID
17+
end
18+
19+
properties(Dependent)
20+
unitID
21+
ACG
22+
FullACG
23+
end
24+
25+
methods (Static)
26+
27+
function feature_names = returnFeatureNames(feature_group)
28+
switch feature_group
29+
case "act"
30+
feature_names = ["FiringRate","MeanInterSpikeInterval","VarianceInterSpikeInterval","CVInterSpikeInterval","PartialAutocorrelation"];
31+
case "reg"
32+
feature_names = ["RegularityFrequency","RegularityMagnitude","RegularityFit"];
33+
case "c22"
34+
feature_names = string(GetAllFeatureNames());
35+
end
36+
end
37+
38+
end
39+
40+
41+
methods
42+
43+
function unit = Unit(mearec, waveform, reference_electrode, spike_times, waveform_features)
44+
if nargin > 0
45+
unit.MEArecording = mearec;
46+
unit.ReferenceWaveform = waveform;
47+
unit.ReferenceElectrode = reference_electrode;
48+
unit.SpikeTimes = spike_times;
49+
unit.WaveformFeatures = struct2table(waveform_features);
50+
unit.inferActivityFeatures();
51+
end
52+
end
53+
54+
function unit_id = get.unitID(unit)
55+
unit_id = find(unit.MEArecording.Units == unit);
56+
end
57+
58+
function acg = get.ACG(unit)
59+
acg = unit.MEArecording.Connectivity.CCG.CCGs(:,unit.unitID,unit.unitID);
60+
end
61+
62+
function acg = get.FullACG(unit)
63+
acg = unit.MEArecording.Connectivity.FullCCG.CCGs(:,unit.unitID,unit.unitID);
64+
end
65+
66+
function [eCCG,iCCG] = getCCGconnections(unit)
67+
% unit.MEArecording.Connectivity.C
68+
% e_idx =
69+
end
70+
71+
function inferActivityFeatures(unit)
72+
if length(unit.SpikeTimes) > 2
73+
isi = diff(unit.SpikeTimes);
74+
act_feat.FiringRate = length(unit.SpikeTimes)/unit.MEArecording.RecordingInfo.Duration;
75+
act_feat.MeanInterSpikeInterval = mean(isi);
76+
act_feat.VarianceInterSpikeInterval = var(isi);
77+
act_feat.CVInterSpikeInterval = std(isi)/mean(isi);
78+
pacf = parcorr(isi,1);
79+
act_feat.PartialAutocorrelation = pacf(2);
80+
unit.ActivityFeatures = struct2table(act_feat);
81+
if unit.MEArecording.Parameters.Analyses.Regularity
82+
unit.RegularityFeatures = unit.getRegularity();
83+
end
84+
if unit.MEArecording.Parameters.Analyses.Catch22
85+
catch_22_table = unit.MEArecording.run_catch_22(unit.SpikeTimes);
86+
catch_22_table.Properties.VariableNames = "SC_" + string(catch_22_table.Properties.VariableNames);
87+
unit.Catch22 = catch_22_table;
88+
89+
end
90+
end
91+
end
92+
93+
function regularity_table = getRegularity(unit)
94+
binned_activity = histcounts(unit.SpikeTimes,'BinLimits',[0 unit.MEArecording.RecordingInfo.Duration],'BinWidth',unit.MEArecording.Parameters.Regularity.Binning);
95+
norm_activity = binned_activity/max(binned_activity);
96+
NFFT = length(norm_activity);
97+
F = (0 : 1/NFFT : 1/2-1/NFFT)*(1/unit.MEArecording.Parameters.Regularity.Binning);
98+
TEMP = fft(norm_activity,NFFT);
99+
TEMP(1) = 0;
100+
freq_domain = abs(TEMP(1:NFFT/2));
101+
[mag,freq_idx] = max(freq_domain);
102+
reg_feat.RegularityFrequency = F(freq_idx);
103+
reg_feat.RegularityMagnitude = mag;
104+
105+
norm_freq_domain = freq_domain/max(freq_domain);
106+
l = [];
107+
p = [];
108+
for i = 1:unit.MEArecording.Parameters.Regularity.N_peaks
109+
[pks,locs,~,~] = findpeaks(norm_freq_domain,'NPeaks',1,'SortStr','descend');
110+
norm_freq_domain = norm_freq_domain(locs:end);
111+
l = [l; locs]; %#ok<AGROW>
112+
p = [p; pks]; %#ok<AGROW>
113+
if isempty(pks) || length(norm_freq_domain) < 10
114+
break
115+
end
116+
end
117+
log_p = log10(p)-min(log10(p)); % Make data positive to be able to fit
118+
try
119+
f = fit(cumsum(l),log_p,'exp1');
120+
reg_feat.RegularityFit = f.b;
121+
catch
122+
reg_feat.RegularityFit = NaN;
123+
end
124+
regularity_table = struct2table(reg_feat);
125+
end
126+
127+
end
128+
end
1.65 KB
Binary file not shown.

Data/Figure3/base_age_prediction.mat

129 KB
Binary file not shown.

Data/Figure3/comb_clustering.mat

1.17 KB
Binary file not shown.
1.57 KB
Binary file not shown.

Data/Figure3/network_clustering.mat

1.16 KB
Binary file not shown.

Data/Figure3/network_features.mat

3.6 KB
Binary file not shown.

Data/Figure3/network_heatmap.mat

3.55 KB
Binary file not shown.

Data/Figure3/network_p_vals.mat

11.9 KB
Binary file not shown.

Data/Figure3/network_values.mat

44.7 KB
Binary file not shown.
1.39 KB
Binary file not shown.

Data/Figure3/single_cell_features.mat

3.49 KB
Binary file not shown.

Data/Figure3/single_cell_heatmap.mat

3.33 KB
Binary file not shown.

Data/Figure3/single_cell_p_vals.mat

11.1 KB
Binary file not shown.

Data/Figure3/single_cell_values.mat

47.1 KB
Binary file not shown.

Data/Figure3/wt_age.mat

60.5 KB
Binary file not shown.

Data/Figure4/FRET_results.mat

1.2 KB
Binary file not shown.

Data/Figure4/coactivity_plot.mat

9.49 KB
Binary file not shown.

Data/Figure4/full_lna_batches.mat

1.41 KB
Binary file not shown.

Data/Figure4/lna_accuracy.mat

1.2 KB
Binary file not shown.

Data/Figure4/lna_age_prediction.mat

2.29 KB
Binary file not shown.

Data/Figure4/lna_comb_umap.mat

926 Bytes
Binary file not shown.

Data/Figure4/lna_comparisons.mat

7.83 KB
Binary file not shown.

Data/Figure4/lna_nw_umap.mat

926 Bytes
Binary file not shown.

Data/Figure4/lna_sc_umap.mat

927 Bytes
Binary file not shown.

Data/Figure4/test.tif

1.61 MB
Binary file not shown.

Data/Figure4/top_features.mat

1.2 KB
Binary file not shown.

Data/Figure5/activity_prediction.mat

105 KB
Binary file not shown.

Data/Figure5/cluster_proportions.mat

2.28 KB
Binary file not shown.
218 Bytes
Binary file not shown.

Data/Figure5/cluster_scatter.mat

1.12 MB
Binary file not shown.

Data/Figure5/combined_prediction.mat

744 KB
Binary file not shown.
Binary file not shown.
99.5 KB
Binary file not shown.
290 KB
Binary file not shown.
304 KB
Binary file not shown.

Data/Figure5/scatter_comb.mat

1.12 MB
Binary file not shown.
2.02 KB
Binary file not shown.

Data/Figure5/waveform_prediction.mat

737 KB
Binary file not shown.

Data/Figure5/wf_prediction.mat

346 KB
Binary file not shown.

Data/Figure6/qp_results.mat

161 KB
Binary file not shown.
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:76a47cffdac296e3d4fd0a287a71fd13a975e37a5332b8abc7d4d562e8243436
3+
size 4556112
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:408e6bf9cb58cfc34c7d1b9f837ec3b69aef367ed7bb814ec24e660220294684
3+
size 9112144
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:ec07ee8ccc8aba16eb04a767ee2c3244ef5b3c2f2a6fd3d3eabadf2af7bd0a16
3+
size 536968880
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:cb98c3ebc7ec0c5e4bbcb946cc9d2f34f8619ef0197fc9ab8c3976192281a430
3+
size 7517860
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:d0c7f5c4c1fa30090692a3cb7aee7ee7f7347eabd9388a803b113766ab3fed17
3+
size 15035640
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:c9bcda01ab7c92d089a1a6049011dbfccc32c640279614b654abc1d6f0543c80
3+
size 717631280

Data/Supplement/figure_S3.mat

1.92 KB
Binary file not shown.

Data/cellline_lookup.xlsx

11.2 KB
Binary file not shown.

Functions/CCG.m

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
%CCG - Compute multiple cross- and auto-correlograms
2+
%
3+
% USAGE
4+
%
5+
% ccg_params.duration = 0.05,<options>)
6+
%
7+
% times times of all events
8+
% NOTE: spiketimes in SECONDS.
9+
% groups group IDs for each event in time list (should be
10+
% integers 1:nGroups)
11+
%
12+
% alternate buzcode usage:
13+
% times {Ncells} array of [Nspikes] spiketimes for each cell.
14+
% groups []
15+
%
16+
% spikes = bz_GetSpikes
17+
% [ccg,t] = CCG(spikes.times,[])
18+
%
19+
% <options> optional list of property-value pairs (see table below)
20+
%
21+
% =========================================================================
22+
% Properties Values
23+
% -------------------------------------------------------------------------
24+
% 'binSize' bin size in s (default = 0.01)
25+
% 'duration' duration in s of each xcorrelogram (default = 2)
26+
% 'norm' normalization of the CCG, 'counts' or 'rate' (DL added 8/1/17)
27+
% 'counts' gives raw event/spike count,
28+
% 'rate' returns CCG in units of spks/second (default: counts)
29+
% =========================================================================
30+
%
31+
%
32+
% OUTPUT
33+
% ccg [t x ngroups x ngroups] matrix where ccg(t,i,j) is the
34+
% number (or rate) of events of group j at time lag t with
35+
% respect to reference events from group i
36+
% t time lag vector (units: seonds)
37+
%
38+
% SEE
39+
%
40+
% See also ShortTimeCCG.
41+
42+
% Copyright (C) 2012 by Michaël Zugaro
43+
%
44+
% This program is free software; you can redistribute it and/or modify
45+
% it under the terms of the GNU General Public License as published by
46+
% the Free Software Foundation; either version 3 of the License, or
47+
% (at your option) any later version.
48+
49+
function [ccg,t] = CCG(times,groups,varargin)
50+
51+
% Default values
52+
duration = 2;
53+
binSize = 0.01;
54+
Fs = 1/20000;
55+
normtype = 'counts';
56+
57+
% Option for spike times to be in {Ncells} array of spiketimes DL2017
58+
if iscell(times) && isempty(groups)
59+
numcells = length(times);
60+
for cc = 1:numcells
61+
groups{cc}=cc.*ones(size(times{cc}));
62+
end
63+
times = cat(1,times{:}); groups = cat(1,groups{:});
64+
end
65+
66+
%Sort
67+
[times,sortidx] = sort(times);
68+
groups = groups(sortidx);
69+
70+
% Check parameters
71+
if nargin < 2,
72+
error('Incorrect number of parameters (type ''help <a href="matlab:help CCG">CCG</a>'' for details).');
73+
end
74+
%if ~isdvector(times),
75+
% error('Parameter ''times'' is not a real-valued vector (type ''help <a href="matlab:help CCG">CCG</a>'' for details).');
76+
%end
77+
if ~isdscalar(groups) && ~isdvector(groups),
78+
error('Parameter ''groups'' is not a real-valued scalar or vector (type ''help <a href="matlab:help CCG">CCG</a>'' for details).');
79+
end
80+
if ~isdscalar(groups) && length(times) ~= length(groups),
81+
error('Parameters ''times'' and ''groups'' have different lengths (type ''help <a href="matlab:help CCG">CCG</a>'' for details).');
82+
end
83+
groups = groups(:);
84+
times = times(:);
85+
86+
% Parse parameter list
87+
for i = 1:2:length(varargin),
88+
if ~ischar(varargin{i}),
89+
error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help CCG">CCG</a>'' for details).']);
90+
end
91+
switch(lower(varargin{i})),
92+
case 'binsize',
93+
binSize = varargin{i+1};
94+
%if ~isdscalar(binSize,'>0'),
95+
% error('Incorrect value for property ''binSize'' (type ''help <a href="matlab:help CCG">CCG</a>'' for details).');
96+
% end
97+
case 'duration',
98+
duration = varargin{i+1};
99+
if ~isdscalar(duration,'>0'),
100+
error('Incorrect value for property ''duration'' (type ''help <a href="matlab:help CCG">CCG</a>'' for details).');
101+
end
102+
103+
case 'Fs',
104+
Fs = varargin{i+1};
105+
if ~isdscalar(Fs,'>0'),
106+
error('Incorrect value for property ''Fs'' (type ''help <a href="matlab:help CCG">CCG</a>'' for details).');
107+
end
108+
case 'norm'
109+
normtype = varargin{i+1};
110+
111+
end
112+
end
113+
114+
115+
116+
% Number of groups, number of bins, etc.
117+
if length(groups) == 1,
118+
groups = ones(length(times),1);
119+
nGroups = 1;
120+
else
121+
nGroups = max(unique(groups));
122+
end
123+
124+
125+
halfBins = round(duration/binSize/2);
126+
nBins = 2*halfBins+1;
127+
t = (-halfBins:halfBins)'*binSize;
128+
times = round(times/Fs);
129+
binSize_Fs = round(binSize/Fs);
130+
if length(times) <= 1,
131+
% ---- MODIFIED BY EWS, 1/2/2014 ----
132+
% *** Use unsigned integer format to save memory ***
133+
ccg = uint16(zeros(nBins,nGroups,nGroups));
134+
% -----------------------------------
135+
return
136+
end
137+
138+
% Compute CCGs
139+
nEvents = length(times);
140+
%
141+
142+
counts = double(CCGHeart(times,uint32(groups),binSize_Fs,uint32(halfBins)));
143+
% -----------------------------------
144+
%
145+
% Reshape the results
146+
n = max(groups);
147+
counts = reshape(counts,[nBins n n]);
148+
149+
150+
if n < nGroups,
151+
counts(nBins,nGroups,nGroups) = 0;
152+
end
153+
154+
%Rate normalization: counts/numREFspikes/dt to put in units of spikes/s. DL
155+
switch normtype
156+
case 'rate'
157+
for gg = 1:nGroups
158+
numREFspikes = sum(groups==gg);%number of reference events for group
159+
counts(:,gg,:) = counts(:,gg,:)./numREFspikes./binSize;
160+
end
161+
end
162+
163+
164+
ccg = flipud(counts);

0 commit comments

Comments
 (0)