forked from pillowlab/neuroGLM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd_simulated_spikes_to_Cells.m
30 lines (26 loc) · 1.3 KB
/
add_simulated_spikes_to_Cells.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
function Cells = add_simulated_spikes_to_Cells(Cells,params,spikes)
% spikes is the output of fit_glm_to_Cells
Cells.Trials = remove_trials(Cells.Trials,params.exclude_trials);
nTrials = numel(Cells.Trials.pokedR);
Cells.spike_time_s = remove_trials_from_spikes(Cells.spike_time_s,params.exclude_trials);
expt=params.dm.dspec.expt;
time_s = (expt.binSize:expt.binSize:expt.trial(1).duration_s) - expt.binSize/2 - expt.trial(1).(params.ref_event);
for i=1:numel(spikes)
cellno = spikes(i).cellno;
if params.distribution=="poisson"
spikes(i).samples = poissrnd(spikes(i).Yhat);
else
error('not implemented yet');
end
Cells.spike_time_s.(params.ref_event){cellno} = cell(nTrials,1);
for t=1:nTrials
ndx = buildGLM.getSpikeIndicesforTrial(expt,t);
these_spikes = spikes(i).samples(ndx);
lim = max(these_spikes);
for k=1:lim
Cells.spike_time_s.(params.ref_event){cellno}{t} = [Cells.spike_time_s.(params.ref_event){cellno}{t} time_s(these_spikes>=k)];
end
Cells.spike_time_s.(params.ref_event){cellno}{t} = sort(Cells.spike_time_s.(params.ref_event){cellno}{t}');
end
end
end