-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_PSTH_with_selectivity.m
42 lines (34 loc) · 1.07 KB
/
plot_PSTH_with_selectivity.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
% This is a script to plot PSTH and selectivity of individual cell
%
% cellId: determines which cell to plot
%
% Plot
% blue: lick right
% red: lick left
%% load data
cellId = 1; % cell to plot
load('ephysDataset.mat') % load data
%% Calculate the mean spike rate & selectivity
meanR = mean(ephysDataset(cellId).sr_right,1); % mean PSTH of lick R trial
meanL = mean(ephysDataset(cellId).sr_left,1); % mean PSTH of lick L trial
selectivity = meanR - meanL; % contra selectivity: difference in spike rate between two trial types (R - L)
%% plot the PSTH
figure
hold on
plot(timeTag,meanR,'b')
plot(timeTag,meanL,'r')
gridxy([-2.6 -1.3 0],'Color','k','Linestyle','--') ; % plot timing of each epoch
xlim([-3 1.5]); % range of X axis
xlabel('Time (s)')
ylabel('Spikes per s')
hold off
print('images/plot_PSTH','-dpng')
%% plot the contra selectivity
figure
hold on
plot(timeTag,selectivity,'k')
gridxy([-2.6 -1.3 0],'Color','k','Linestyle','--') ; % plot timing of each epoch
xlim([-3 1.5]); % range of X axis
xlabel('Time (s)')
ylabel('Contra selectivity (Spikes per s)')
hold off