-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdealRespByCue.m
52 lines (43 loc) · 1.36 KB
/
dealRespByCue.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
function [respByCue, thisAxis] = dealRespByCue(respByCue, centering, showDistance, prefDir, cardinalDir)
%INPUT:
%respByCue: direction x time x wo/w cue
%
%OUTPUT:
%respByCue:
%thisAxis: direction or distance from prefDir
%created from showGainInfo_pop.m
% gainInfo = gainInfo_pop(idata);
% avgTonsetByCue = squeeze(gainInfo.avgTonsetByCue(:,1,:,:));
% if sum(sum(avgTonsetByCue(:,:,2))) ~= 0
% okgain = [okgain idata];
% end
if centering
centralBin = round(0.5*length(cardinalDir));
centralDir = cardinalDir(centralBin);
centeredDir = 180/pi*circ_dist(pi/180*cardinalDir, pi/180*centralDir );
dirAxis = centeredDir;
distAxis = unique(abs(round(dirAxis)));
else
dirAxis = cardinalDir;
centeredDir = 180/pi*circ_dist(pi/180*cardinalDir,0);
distAxis = unique(abs(round(centeredDir)));
end
if centering %alignMtxDir
[~,prefBin] = min(abs(prefDir - cardinalDir));
centralBin = round(0.5*length(cardinalDir));
respByCue = circshift(respByCue, centralBin - prefBin, 1);
end
respByCue(respByCue==0) = nan;
if showDistance
avgTonsetByCue_c = [];
for idist =1:numel(distAxis)
theseDirs = find(abs(round(dirAxis)) == distAxis(idist));
avgTonsetByCue_c(idist,:,:) = mean(respByCue(theseDirs,:,:),1);
end
respByCue = avgTonsetByCue_c;
end
if showDistance
thisAxis = distAxis;
else
thisAxis = dirAxis;
end