-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshowFilmstripPlot.m
83 lines (77 loc) · 2.88 KB
/
showFilmstripPlot.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
function [minRate, maxRate] = showFilmstripPlot(rateStruct)
addpath kdtree
addpath geo
cnames = fieldnames(rateStruct);
nCells = min(20,length(cnames));
minRate = nan(nCells,1);
maxRate = nan(nCells,1);
for fig=1:ceil(length(cnames)/20)
figure(fig);
colormap([jet; 1 1 1]);
for iic=1:min(20,length(cnames)-(fig-1)*20)
% fig = 1;
% for iic=1:nCells
rate = rateStruct.(cnames{(fig-1)*20+iic});
minRate(iic) = min(rate(:));
maxRate(iic) = max(rate(:));
rate = rate - min(rate(:));
rate = rate./max(rate(:));
rate = rate.*(length(colormap)-1);
targets = target26(1);
profile = var(rate,0,2);
% profile = mean(rate,2);
pd = regress(profile,[targets; targets])';
[az,el] = cart2sph(targets(:,1),targets(:,2),targets(:,3));
[az0,el0] = cart2sph(pd(1), pd(2), pd(3));
[el,az] = rotatem(el,az,[el0 az0],'forward','radians');
sliceLoc = 1:size(rate,2);%[5 10 15 18];
outward = cell(length(sliceLoc)*2,1);
inward = cell(size(outward));
xrange = -pi:pi/25:pi;
yrange = -pi/2:pi/25:pi/2;
[xi, yi] = meshgrid(xrange,yrange);
spacer = length(colormap)*ones(ceil(length(yrange)/10),length(xrange));
% spacer = nan(ceil(length(yrange)/10),length(xrange));
for iis=1:length(sliceLoc)
slice = sliceLoc(iis);
outward{iis*2-1} = nearest(az,el,rate(1:26,slice),xi,yi);
outward{iis*2} = spacer;
% subplot(length(sliceLoc),2*nCells,(iis-1)*2*nCells+2*iic-1);
% image(xrange,yrange,zi);
% axis image, box off, axis off
inward{iis*2-1} = nearest(az,el,rate(27:end,slice),xi,yi);
inward{iis*2} = spacer;
% subplot(length(sliceLoc),2*nCells,(iis-1)*2*nCells+2*iic);
% image(xrange,yrange,zi);
% axis image, box off, axis off
end
outward = cell2mat(outward(1:end-1));
inward = cell2mat(inward(1:end-1));
img = [outward length(colormap)*ones(size(outward,1), size(spacer,1)) inward];
% subplot(3,ceil(nCells/3),iic);
subplot(2,10,iic);
image(img);
axis image, box off, axis off
end
print('-dpsc',sprintf('filmstrip%0.2d.ps',fig));
end
end
function zi = nearest(x,y,z,xi,yi)
reference = [reshape(x,numel(x),1) reshape(y,numel(y),1)];
model = [reshape(xi,numel(xi),1) reshape(yi,numel(yi),1)];
idx = kdtreeidx(reference,model);
zi = reshape(z(idx),size(xi));
% zi = nan(size(xi));
%
% x = reshape(x,numel(x),1);
% y = reshape(y,numel(y),1);
% z = reshape(z,numel(z),1);
% xi = reshape(xi,numel(xi),1);
% yi = reshape(yi,numel(yi),1);
%
% dists = sqrt(bsxfun(@minus,x,xi').^2+bsxfun(@minus,y,yi').^2);
% dists = bsxfun(@eq,dists,min(dists));
%
% [row,col] = find(dists);
% zi(col) = z(row);
end