| Description of slverifyroc_blks |
slverifyroc_blks
PURPOSE 
SLVERIFYROC_BLKS Computes the verification ROC for blockwise score matrix
SYNOPSIS 
function [thrs, fars, frrs] = slverifyroc_blks(scores, blocks, labels1, labels2, op, npts)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
- slreadarray SLREADARRAY Reads an array from an array file
- slhistroc SLHISTROC Computes the ROC curve from value histogram
- raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
This function is called by:
SUBFUNCTIONS 
SOURCE CODE 
0001 function [thrs, fars, frrs] = slverifyroc_blks(scores, blocks, labels1, labels2, op, npts)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 if nargin < 5
0031 raise_lackinput('slverifyroc_blks', 5);
0032 end
0033 if isempty(labels2)
0034 labels2 = labels1;
0035 end
0036 if ~iscell(scores)
0037 error('sltoolbox:invalidargs', ...
0038 'The scores should be a cell array of filenames');
0039 end
0040 if nargin < 6 || isempty(npts)
0041 npts = 500;
0042 end
0043 nblks = numel(scores);
0044 if ~isequal(size(scores), size(blocks))
0045 error('The sizes of scores and blocks are inconsistent');
0046 end
0047
0048
0049
0050
0051
0052 maxv = -inf;
0053 minv = inf;
0054 for k = 1 : nblks
0055 [curmaxv, curminv] = collect_maxmin(slreadarray(scores{k}));
0056 if curmaxv > maxv
0057 maxv = curmaxv;
0058 end
0059 if curminv < minv
0060 minv = curminv;
0061 end
0062 end
0063
0064 if minv >= maxv
0065 error('sltoolbox:valuerror', ...
0066 'The minv should be less than maxv');
0067 end
0068
0069
0070 thrs = linspace(minv, maxv, npts)';
0071
0072
0073
0074 H = zeros(npts, 2);
0075 for k = 1 : nblks
0076 cb = blocks{k};
0077 l1 = labels1(cb(1,1):cb(2,1));
0078 l2 = labels2(cb(1,2):cb(2,2));
0079 curscores = slreadarray(scores{k});
0080 curH = collect_scorehist(curscores, l1, l2, thrs);
0081
0082 H = H + curH;
0083 end
0084
0085
0086
0087
0088 hist_a = H(:, 1);
0089 hist_r = H(:, 2);
0090
0091 [thrs, fars, frrs] = slhistroc(hist_a, hist_r, thrs, op);
0092
0093
0094
0095
0096 function [maxv, minv] = collect_maxmin(S)
0097
0098 S = S(:);
0099 maxv = max(S);
0100 minv = min(S);
0101
0102
0103 function H = collect_scorehist(S, l1, l2, thrs)
0104
0105
0106 m = length(l1);
0107 n = length(l2);
0108 if ~isequal(size(S), [m, n])
0109 error('sltoolbox:sizmismatch', ...
0110 'The sizes of labels and score matrix are mismatch');
0111 end
0112
0113 l1 = l1(:);
0114 l2 = l2(:)';
0115 L1 = l1(:, ones(1, n));
0116 L2 = l2(ones(m, 1), :);
0117 signals = (L1 == L2);
0118 clear L1 L2;
0119
0120 scores_a = S(signals);
0121 scores_r = S(~signals);
0122
0123 if ~isempty(scores_a)
0124 hist_a = histc(scores_a, thrs);
0125 else
0126 hist_a = zeros(length(thrs), 1);
0127 end
0128
0129 if ~isempty(scores_r)
0130 hist_r = histc(scores_r, thrs);
0131 else
0132 hist_r = zeros(length(thrs), 1);
0133 end
0134
0135 H = [hist_a, hist_r];
0136
0137
Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003
|
|