-
Notifications
You must be signed in to change notification settings - Fork 2
/
plot_CD.m
74 lines (59 loc) · 2.03 KB
/
plot_CD.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
% plot coding direction
%
% This code will go through coding direction plot for a selected single
% session for two behavioral conditions.
%
%
%
% Ziqiang Wei
load('ephysDataset.mat')
sessionId = 1;
sessionData = ephysDataset([ephysDataset.sessionIndex] == sessionId & [ephysDataset.cell_type]==1);
numUnit = length(sessionData);
numTime = length(timeTag);
%% coding direction
% coding direction is defined as a vector spanned by neurons;
% each element is the difference of the mean activity of neurons in two
% trial type conditions.
cdMat = zeros(numUnit, numTime);
meanMatR = zeros(numUnit, numTime);
meanMatL = zeros(numUnit, numTime);
for cellId = 1:numUnit
meanR = mean(ephysDataset(cellId).sr_right,1);
meanL = mean(ephysDataset(cellId).sr_left,1);
cdMat(cellId, :) = meanR - meanL;
meanMatR(cellId, :) = meanR;
meanMatL(cellId, :) = meanL;
end
% We now explore the similarity of coding direction across time using corr
% function in matlab.
figure;
title(['Coding direction correlation across time for Session #' num2str(sessionId)])
hold on
imagesc(timeTag, timeTag, corr(cdMat));
gridxy([-2.6 -1.3 0],[-2.6 -1.3 0],'Color','k','Linestyle','--') ;
xlim([-3.0 1.5]);
ylim([-3.0 1.5]);
xlabel('Time from movement (sec)')
ylabel('Time from movement (sec)')
hold off
%% projection of data to delay-epoch coding direction
% delay-epoch coding direction is defined as an average of coding direction
% over whole delay period -1.3 to 0 sec in time tag.
cdDelay = mean(cdMat(:, timeTag > -1.3 & timeTag < 0), 2);
cdDelay = cdDelay/norm(cdDelay);
popR = meanMatR' * cdDelay;
popL = meanMatL' * cdDelay;
% We now project the neuronal activity in different trial type conditions
% to the coding direction.
figure;
title(['Coding direction projection for Session #' num2str(sessionId)])
hold on
plot(timeTag, popR, '-b')
plot(timeTag, popL, '-r')
gridxy([-2.6 -1.3 0],'Color','k','Linestyle','--') ;
xlim([-3.0 1.5]);
xlabel('Time from movement (sec)')
ylabel('Activity projected coding direction')
hold off