This repository was archived by the owner on Feb 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.js
More file actions
134 lines (101 loc) · 2.95 KB
/
testing.js
File metadata and controls
134 lines (101 loc) · 2.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
124
125
126
127
128
129
130
131
132
133
134
var version = '1.1';
// globals
var gx = 480; // canvas width
var gy = 480; // canvas height
var gt = gx * gy;
var gColPN = "#1b4f72";
var gColPP = "#216a8c";
var gColNP = "#216a8c";
var gColNN = "#1b4f72";
var gPercentPos = 0.0;
var gPercentNeg = 0.0;
var gSpec = 0.0;
var gSens = 0.0;
var gPosTestPos = 0;
var gPosTestNeg = 0;
var gNegTestPos = 0;
var gNegTestNeg = 0;
function redraw() {
gPercentPos = parseInt($('#posslider').val()) / 100.0;
gPercentNeg = 1.0 - gPercentPos;
gSens = parseInt($('#sensslider').val()) / 1000.0;
gSpec = parseInt($('#specslider').val()) / 1000.0;
var x = 0;
var y = 0;
var w = 0;
var h = 0;
gPosTestPos = gt * gPercentPos * gSens;
gPosTestNeg = gt * gPercentPos * (1 - gSens);
gNegTestNeg = gt * gPercentNeg * gSpec;
gNegTestPos = gt * gPercentNeg * (1 - gSpec);
x = 0;
y = 0;
w = gx * gPercentPos;
h = gy * gPosTestPos / (gPosTestPos + gPosTestNeg);
ctx.fillStyle = gColPP;
ctx.fillRect(x,y,w,h);
ctx.fillStyle = '#eeeeee';
ctx.font = "10px Serif";
ctx.fillText('TP', x+w/2-5, y+h/2)
x = x;
y = h;
w = w;
h = gy * gPosTestNeg / (gPosTestPos + gPosTestNeg);
ctx.fillStyle = gColPN;
ctx.fillRect(x,y,w,h);
if (gSens < 0.999) {
ctx.fillStyle = '#eeeeee';
ctx.font = "10px Serif";
ctx.fillText('FN', x+w/2-5, y+h/2)
}
x = gx * gPercentPos;
y = 0;
w = gx * gPercentNeg;
h = gy * gNegTestNeg / (gNegTestPos + gNegTestNeg);
ctx.fillStyle = gColNN;
ctx.fillRect(x,y,w,h);
ctx.fillStyle = '#eeeeee';
ctx.font = "10px Serif";
ctx.fillText('TN', x+w/2-5, y+h/2)
x = x;
y = h;
w = w;
h = gy * gNegTestPos / (gNegTestPos + gNegTestNeg);
ctx.fillStyle = gColNP;
ctx.fillRect(x,y,w,h);
if (gSpec < 0.999) {
ctx.fillStyle = '#eeeeee';
ctx.font = "10px Serif";
ctx.fillText('FP', x+w/2-5, y+h/2)
}
x = x-1;
y = 0;
w = 3;
h = gy;
ctx.fillStyle = '#eeeeee';
ctx.fillRect(x,y,w,h);
$('#postext').html(gPercentPos*100 + '% background rate');
$('#senstext').html(Math.round(gSens*1000.0)/10.0 + '% sensitivity');
$('#spectext').html(Math.round(gSpec*1000.0)/10.0 + '% specificity');
var probpos = Math.round(gPosTestPos / (gPosTestPos + gNegTestPos)*100);
var probneg = Math.round(gNegTestNeg / (gNegTestNeg + gPosTestNeg)*100);
$('#head2').html('Positive result: '+probpos+'%');
$('#head3').html('Negative result: '+probneg+'%');
}
var canvas = 0;
var ctx = 0;
$(function() {
$('#ver').html(version);
canvas = document.getElementById("graphs");
ctx = canvas.getContext("2d");
$('#posslider').on('input', function (e) {
redraw();
});
$('#sensslider').on('input', function (e) {
redraw();
});
$('#specslider').on('input', function (e) {
redraw();
});
redraw();
});