-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatCompute.m
More file actions
59 lines (53 loc) · 1.77 KB
/
catCompute.m
File metadata and controls
59 lines (53 loc) · 1.77 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
function catCompute(sets,filename)
%catCompute Computes various statistics for cat data
% catCompute(sets,filename)
if(ischar(sets))
sets = str2num(sets);
end
% load refractory data
mat = load('refractory.mat');
rf = struct(mat.rf);
% get frame boundaries
rtlength = length(rf.data.rtEdges{1});
% take out last value in rtEdges so there will be an even number of points
rt1 = reshape(rf.data.rtEdges{1}(1:(rtlength-1)),rf.data.qtframebins,[]);
% grab the first row which should be the frame limits and add the last
% point in rtEdges
fbins = [rt1(1,:)'; rf.data.rtEdges{1}(rtlength)];
% number of frames should be number of columns in rt1
numframes = size(rt1,2);
% get number of repetitions
reps = rf.data.repetitions;
% allocate memory
sptrain = cell(1,sets);
sg.scmean = zeros(numframes,sets);
sg.scstd = zeros(numframes,sets);
% generate surrogates
for i = 1:sets
fprintf('Set %d\n',i);
% generate surrogate spike trains, each repetition is in a column
sptrain{i} = getSurrogateSpikes(rf.data,1);
% get spike counts for each frame of sptrain, one column for each rep
sc = histcie(cell2array(sptrain{i}),fbins,'DropLast');
% reshape into repetitions and then transpose so we can take the mean
% and std easily
sc1 = reshape(sc,numframes,[])';
% store mean and std in columns
sg.scmean(:,i) = mean(sc1)';
sg.scstd(:,i) = std(sc1)';
end
% save surrogates and statistics for surrogates
fid = fopen([filename '.bin'],'w','ieee-le');
fwrite(fid,[sets reps],'int32');
for i = 1:sets
for j = 1:reps
st = sptrain{i}{j};
% write number of spikes for set i, repetition j
fwrite(fid,size(st,1),'int32');
% write spike times for set i, repetition j
% multiply by 10 so we can convert tenth of a ms to integer
fwrite(fid,st*10,'int32');
end
end
fclose(fid);
save([filename 'FF'],'sg');