-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickViewPatterns.m
More file actions
executable file
·123 lines (106 loc) · 3.95 KB
/
Copy pathquickViewPatterns.m
File metadata and controls
executable file
·123 lines (106 loc) · 3.95 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
% Script to quickly visualize the results of the MAIN function
loadNew = 1;
phaseCmap = pmkmp_new(256, 'ostwald_o');
skipLength = 5;
startIndex = 3800;
spikeSmoothSpan = 21;
vScale = 200;
% Load files
if loadNew
% Load spikes
load(outputFile1Name, 'spikeMatrix', 'Fs')
% Make sure that spikes are represented by ones
spikeMatrix = spikeMatrix ~= 0;
% Smooth spikes with a moving average filter to obtain spike rate
spikeRate = zeros(size(spikeMatrix));
for ii = 1:size(spikeMatrix, 1)
spikeRate(ii,:) = smooth(spikeMatrix(ii,:), spikeSmoothSpan);
end
% Convert to grid and SI units
spikeRate = vector2grid(spikeRate) * Fs;
% Load phase maps, velocity fields and pattern information
load(outputFile2Name, 'phase', 'experiment', 'file', 'discardTimeSteps')
phase = vector2grid(phase);
load(outputFile3Name, 'velocityX', 'velocityY', 'badChannelsGrid', ...
'pwActive', 'syActive', 'patternCentreStruct')
% Convert critical point structure to more usable form
centres = combinePatternCentres(patternCentreStruct);
centres = sortStruct(centres, 'time');
% Trim spikes to correct time values to match other data
spikeRate = spikeRate(:,:,discardTimeSteps:(size(spikeMatrix,2) - ...
discardTimeSteps));
% % Calculate binary array of spike wave activity
% [phi, v0, v_direction] = orderParameter(spikevx, spikevy);
% [~, spwActive] = addToPatternsStructure(...
% 'planeWave', phi>=planeWaveThreshold, [], params);
% spwActive = spwActive(discardTimeSteps:(end - discardTimeSteps));
end
for index = startIndex:skipLength:size(phase, 3)
% View phase
subplot(2,2,1)
displayGrid(phase(:,:,index), phaseCmap, [-pi pi], 0, 1);
title(sprintf('%s-%d phase: %0.3f s, step %d', ...
experiment, file, index/Fs, index))
axis square
% View velocity field with pattern types
subplot(2,2,3)
quiver(0.5:9.5, 0.5:9.5, vScale*flipud(velocityX(:,:,index)), ...
vScale*flipud(-velocityY(:,:,index)), 0)
set(gca, 'XTick', 0:2.5:10, 'YTick', 0:2.5:10)%, ...
% 'XTickLabel', [], 'YTickLabel', []);
axis([0 10 0 10])
axis square
title('Phase velocity field')
% Show criticial point centres
hold on
critIndex = find(centres.time == index);
for ii = 1:length(critIndex)
icrit = critIndex(ii);
% Choose marker colour/type based on pattern
switch char(centres.name(icrit))
case 'saddle'
mcol = 'k';
mtype = 'x';
case 'sink'
mcol = 'r';
mtype = 'filled';
case 'source'
mcol = 'r';
mtype = 'o';
case 'spiralIn'
mcol = 'b';
mtype = 'filled';
case 'spiralOut'
mcol = 'b';
mtype = 'o';
end
% Coordinates are in row, column form so convert to cartesian
% coordinates for plotting
scatter(centres.coords(icrit,2)-0.5, 10.5-centres.coords(icrit,1), 80, ...
mcol, mtype, 'LineWidth', 2)
end
hold off
% View multi-unit firing rate at each channel
subplot(2,2,2)
displayGrid(spikeRate(:,:,index), jet, [0, Fs], 0, 1);
title(sprintf('Multi-unit firing rate, %d ms window', spikeSmoothSpan));
% Add indicator for synchronized activity
subplot(6,4,19)
imagesc([0 1], [0 1], syActive(index), [0 1])
colormap gray
set(gca, 'XTick', [], 'YTick', [])
title('Synchrony')
% Add indicator for plane wave
subplot(6,4,20)
imagesc([0 1], [0 1], pwActive(index), [0 1])
colormap gray
set(gca, 'XTick', [], 'YTick', [])
title('Plane wave')
% % TEMP: Add indicator for spike wave
% subplot(4,4,15)
% imagesc([0 1], [0 1], spwActive(index), [0 1])
% colormap gray
% title('Spike plane wave')
drawnow
w = waitforbuttonpress;
end