-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_lfp_data.m
74 lines (62 loc) · 2.27 KB
/
plot_lfp_data.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
function plot_lfp_data(info)
if ~exist('info','var')
load('dataE_LFP.mat','info')
end
trial_id = 1;
trialLFP = info.LM{trial_id};
trialTime = info.LMe{trial_id}(:,1);
trialEvents = info.LMe{trial_id}(:,2);
trial_v = info.TM(trial_id,:);
ecodeRTshape;
%% Plot trial events and spike rasters
figure(1);clf;
subplot(3,1,1);hold on;
for i = 1:length(trialEvents)
if ~any(trialEvents(i)==[E_SPIKE,E_FP_OFF,E_FP2_ON,E_STIM_OFF,E_CLEAR_SCREEN,...
E_SHAPE_TASK,E_PARAM,E_FEEDBACK_ON,E_TRIAL_INFO,E_TARGET1_ACQUIRED,E_TARGET2_ACQUIRED])
en = event_name(event_code==trialEvents(i),:);
en = strrep(en,'E_','');
en = strrep(en,'E-','');
en = strrep(en,'STIM','SHAPE');
text(trialTime(i),2,en,'Rotation', 90);
end
end
spikeTime = trialTime(trialEvents==E_SPIKE);
tickRaster(spikeTime,1,'k')
xlim([trialTime(1),trialTime(end)])
ylim([0,3])
xlabel('Elapsed trial time (ms)')
set(gca,'YTick',1:2,'YTickLabel',{'Spikes','Event Name'})
%% Plot cumulative evidence in a trial
t_stim_on = trialTime(trialEvents==E_STIM_ON);
n_shape_on = length(t_stim_on);
t_stim_on = [0;t_stim_on;trialTime(trialEvents==E_SACCADE)];
woe = [inf, -inf, 0.9, -0.9, 0.7, -0.7, 0.5, -0.5, 0.3, -0.3, 0.1, -0.1]; % weigt of evidence (logLR)
n_shape_used = sum(isfinite(trial_v(11:30)));
w = [0,woe(int8(trial_v(11:11+n_shape_used-1)))];
cum_w = cumsum(w);
subplot(3,1,2);hold on;
for si = 1:n_shape_used+1
plot(t_stim_on(si:si+1),cum_w(si)*[1,1],'k-');
end
xlim([trialTime(1),trialTime(end)])
ylim([-2 2])
xlabel('Elapsed trial time (ms)')
ylabel('Cumulative evidence (logLR)')
%% Plot LFP
subplot(3,1,3);hold on;
plot(trialLFP);
xlim([trialTime(1),trialTime(end)])
xlabel('Elapsed trial time (ms)')
ylabel('LFP (a.u.)')
end
function tickRaster(spikeTime,trialNum,color)
if size(spikeTime,1)~=1
spikeTime = spikeTime';
end
s = [repmat(spikeTime,2,1);nan(1,length(spikeTime))];
t = [zeros(1,length(spikeTime))+trialNum-0.3;...
zeros(1,length(spikeTime))+trialNum+0.3;...
nan(1,length(spikeTime))];
plot(s,t,'-','color',color);
end