-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbullseye_pDet.m
executable file
·145 lines (128 loc) · 4.69 KB
/
bullseye_pDet.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
% BULLSEYE plots patch data in polar coordinates. The DATA matrix is
% mapped to a bullseye plot as follows. The matrix rows are mapped to
% the circumference and matrix columns are mapped to radial direction. For
% example, the top-left (first row, first column) data point in the matrix is
% mapped to the inner-most radial patch and starts from 0 degrees (far
% right of bullseye, not top) and extends counter-clockwise.
%
% If you use the hard coded cardiac anatomic lables then this first
% row is within the INFEROTLATERAL segment. The last row is within the
% INFERIOR segment.
%
% SYNTAX: h=bullseye(DATA,varargin)
%
% color - matrix of data (ROWSxCOLUMNS==CIRCUMFERENCExRADIUS)
% param.N - number of points used to define each patch
% param.rho - 2x1 or 1x2 vector of inner and outer radius
% param.tht - 2x1 or 1x2 vector of beginning and ending circumference in DEGREES
% param.tht0 - 1x1 value in degrees indicating the circumferential location of the first segment (>0 is CCW)
% param.labels- 0 or 1, flag that turns on anatomic labeling
% param.lines - 1x2 or 2x1, determines number of RADIAL x CIRCUMFERENTIAL lines to use for anatomic sector emphasis
%
% h - handle for the patch object
%
% Example: bullseye; % Try running it with no input arguments.
% bullseye(rand(3,5),'N',100,'tht',[0 360]);
%
% Feedback: Rate this file @ <a href="matlab:web('http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectType=author&objectId=1093772','-browser')">MATLAB Central File Exchange</a>
%
% DBE 2004/07/21
% DBE 2005/10/24 Minor bug fixes
% http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectType=author&objectId=1093772&objectType=author
function [h,t]=bullseye_pDet(data,varargin);
if nargin==0
data=rand(12,9);
data(1,:)=1;
data(2,:)=2;
data(:,1)=0;
data(1,1)=3;
data
end
ax_hand =axes;
% data=flipud(data); % The matrices are defined from left to right...graph is CCW
param.N =[];
param.rho =[];
param.tht =[];
param.tht0 =[];
param.label=[];
param.lines=[];
i = 1;
while i <= length(varargin)
switch lower(varargin{i})
case 'n'
param.N =varargin{i+1}; i=i+2;
case 'rho'
param.rho =varargin{i+1}; i=i+2;
case 'tht'
param.tht =varargin{i+1}; i=i+2;
case 'tht0'
param.tht0 =varargin{i+1}; i=i+2;
case {'label','labels'}
param.label=varargin{i+1}; i=i+2;
case 'lines'
param.lines=varargin{i+1}; i=i+2;
otherwise
error(['Input argument ',varargin{i},' not valid.']);
end
end
if isempty(param.N ), param.N =5 ; end
if isempty(param.rho ), param.rho =[1 6] ; end
if isempty(param.tht ), param.tht =[0 360] ; end
if isempty(param.tht0), param.tht0 =0 ; end
if isempty(param.label), param.label =0 ; end
if isempty(param.lines), param.lines =[] ; end
[X,Y]=gen_xy(data,param);
h=patch(X,Y,lin(data')');
set(h, 'edgecolor', 'none')
if ~isempty(param.lines)
[X,Y]=gen_xy(zeros(param.lines),param);
h=patch(X,Y,lin(zeros(param.lines)')');
set(h,'linewidth',3,'facecolor','none');
end
[cmap, lims, ticks, bfncol, ctable] = cptcmap('GMT_gray.cpt', gca, 'mapping', 'scaled', 'ncol', 256);
cmap(1,:) = [0,0,0];
colormap(cmap);
axis equal off;
set(gcf,'color',[1 1 1]);
title('N','FontSize', 12,'FontWeight','demi')
% if param.label, t=bull_labels(param); end
c=colorbar('FontSize', 12);
hy = ylabel(c, 'Probability of detection','FontSize', 14);
set(hy,'rotation',-90)
hy_pos = get(hy,'Position');
hy_pos(1) = hy_pos(1) +2;
set(hy,'Position',hy_pos)
return
function [X,Y]=gen_xy(data,param);
ind=1;
for j=1:size(data,1)
for k=1:size(data,2)
dtht=-diff(param.tht)/size(data,1);
tht1=dtht*(j-1)+param.tht(1)-param.tht0-90;
tht2=dtht* j +param.tht(1)-param.tht0-90;
dr=diff(param.rho)/size(data,2);
rho1=dr*(k-1)+param.rho(1);
rho2=dr* k +param.rho(1);
ang = linspace(tht1/180*pi,tht2/180*pi,param.N);
[arc1.x,arc1.y]=pol2cart(ang,rho1);
[arc2.x,arc2.y]=pol2cart(ang,rho2);
X(:,ind)=[arc1.x arc2.x(end:-1:1)];
Y(:,ind)=[arc1.y arc2.y(end:-1:1)];
ind=ind+1;
end
end
return
% This function linearizes a matrix (m) of any dimension (eg M=m(:)).
% If an index vector (ind) is given then the the ind entries of m(:) are
% returned.
%
% SYNTAX: m=lin(m);
% m=lin(m,ind);
%
% DBE 12/22/03
function m=lin(m,ind);
m=m(:);
if nargin==2
m=m(ind);
end
return