-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyseFiringRateOverTime.m
More file actions
64 lines (49 loc) · 1.78 KB
/
Copy pathanalyseFiringRateOverTime.m
File metadata and controls
64 lines (49 loc) · 1.78 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
56
57
58
59
60
61
62
63
64
function analyseFiringRateOverTime(recordings,channels,varargin)
nRecordings = numel(recordings);
nChannels = numel(channels);
nSpikes = zeros(nChannels,nRecordings);
function fn(spikeTimes,channelIndex,varargin)
nSpikes(channelIndex,ii) = numel(spikeTimes);
end
for ii = 1:nRecordings
recording = recordings{ii};
forEachChannel(recording,channels,true,@fn,false)
end
function missingAllSpikesFilesFn(spikeTimes,channelIndex,~,cluster,varargin)
if cluster == 0
return;
end
if size(nSpikes,1) < channelIndex
nSpikes(channelIndex,ii) = numel(spikeTimes);
else
nSpikes(channelIndex,ii) = nSpikes(channelIndex,ii) + numel(spikeTimes);
end
end
if isempty(nSpikes) || sum(sum(abs(nSpikes))) == 0
for ii = 1:nRecordings
recording = recordings{ii};
forEachChannel(recording,channels,true,@missingAllSpikesFilesFn,true)
end
end
currentDir = pwd;
slashes = strfind(currentDir,'\');
if ~isempty(slashes)
currentDir = currentDir(slashes(end)+1:end);
end
figure;
boxplot(nSpikes,recordings(:));
xlabel('Recording');
ylabel('# Spikes');
title(currentDir);
options = getopt('suffix=NaN',varargin{:});
suffix = '';
if ischar(options.suffix)
suffix = ['_' options.suffix];
end
figFile = sprintf('%s%s_firing_rates',currentDir,suffix);
saveas(gcf,figFile,'fig');
saveas(gcf,figFile,'png');
spreadsheet = [figFile '.xlsx'];
xlswrite(spreadsheet,recordings,sprintf('A1:%s1','A'+numel(recordings)-1));
xlswrite(spreadsheet,nSpikes,sprintf('A2:%s%d','A'+numel(recordings)-1,size(nSpikes,1)+1));
end