-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_spiking_positions.m
93 lines (76 loc) · 3.02 KB
/
plot_spiking_positions.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plot_spiking_positions(xN,yN,XLocAtSpikes,YLocAtSpikes)
% Outputs: none, displays n figures
% Inputs:
% xN - normalized positions x (of any # of neurons)
% yN - normalized positions y (of any # of neurons)
% XLocAtSpikes - positions xN at spikes (of any # of neurons)
% YLocAtSpikes - positions yN at spikes (of any # of neurons)
%
% This function plots the spikes and the path taken as a function of
% normalized position for all neurons given. It loops through each neuron
% and calls the function psp(i,xN,yN,xspikes_i,yspikes_i) to plot
% corresponding figures.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function plot_spiking_positions(xN,yN,XLocAtSpikes,YLocAtSpikes,varargin)
p = inputParser;
defaultType = 'subplot';
validType = {'subplot','separate'};
checkType = @(x) any(validatestring(x,validType));
addRequired(p,'xN');
addRequired(p,'yN');
addRequired(p,'XLocAtSpikes');
addRequired(p,'YLocAtSpikes');
addOptional(p,'type',defaultType,checkType);
parse(p,xN,yN,XLocAtSpikes,YLocAtSpikes,varargin{:})
n = numel(XLocAtSpikes);
if strcmp(p.Results.type,'separate')
for i=1:n
psp(i,xN,yN,XLocAtSpikes{i},YLocAtSpikes{i});
end
elseif strcmp(p.Results.type,'subplot')
figure('Name','Raw Data - Spikes and Path vs Position',...
'units','normalized','outerposition',[0 0.035 1 0.92]); hold on;
for i=1:n
subplot(n/5, 5, i); hold on;
plot(xN,yN,XLocAtSpikes{i},YLocAtSpikes{i},'r.');
% make pretty
title(['Neuron ' num2str(i)])
if i==ceil(3*n/4)
xlabel('Normalized x position');
end
if mod(i,n/2)==1
ylabel('Normalized y position');
end
pbaspect([1 1 1]);
set(gca,'fontsize',20)
end
% suptitle('Spiking activity as a function of position')
set(gca,'fontsize',20)
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% psp(i,xN,yN,xspikes_i,yspikes_i)
% Outputs: none, displays figure
% Inputs:
% i - neuron ID #
% xN - normalized positions x
% yN - normalized positions y
% xspikes_i - positions xN at spikes (XLocAtSpikes{i})
% yspikes_i - positions yN at spikes (YLocAtSpikes{i})
%
% This function plots the spikes against the path taken as a function of
% normalized position. The figure is labeled according to neuron ID #. This
% function is called by
% plot_spiking_positions(xN,yN,XLocAtSpikes,YLocAtSpikes) for n number of
% neurons in the data.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function psp(i,xN,yN,xspikes_i,yspikes_i)
figure('Name','Raw Data - Spikes and Path vs Position');
plot(xN,yN,xspikes_i,yspikes_i,'r.');
% making it look pretty and readable
title(['Neuron: ' num2str(i) ': Spiking Activity as a Function of Position'])
xlabel('Normalized x position'); ylabel('Normalized y position');
% legend('Path taken','Position at spike','location','best')
set(gca,'fontsize',14)
end