-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvcan_corr_errts_container.html
143 lines (136 loc) · 4.75 KB
/
nvcan_corr_errts_container.html
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
<html>
<head>
<link rel="stylesheet" type="text/css" href="extra_info/styles.css" />
<script src="./assets/niivue_afni.umd.js"> </script>
<script type="text/javascript">
/* show/hide olay in NV (for align checks)
obj : NV object ID
bid : button ID in that object's NV canvas
*/
function niivue_ShowHideOlay(obj, bid) {
let element = document.getElementById(bid);
if (obj.volumes[1].opacity) {
obj.setOpacity(1, 0);
element.innerText = "View Olay";
} else {
obj.setOpacity(1, 1);
element.innerText = "Hide Olay";
}
}
// used for string formatting numbers (C Rorden), below
function flt2str0(flt, ndec = 0) {
//retain trailing zero
return flt.toFixed(ndec); //return string
}
/* more string formatting numbers, below ... WITH directionality here,
assuming the coords are what AFNI calls LPI (and what some other
software call RAS); basically, L/P/I are neg coords, and R/A/S are
positive.
*/
function flt2str0_dir(flt, ndec = 0, dir = '') {
//retain trailing zero
if (dir == '') {
return flt.toFixed(ndec); //return string
} else if (dir == 'RL') {
let aflt = Math.abs(flt);
let lab = (flt < 0) ? 'L' : 'R';
return aflt.toFixed(ndec) + lab;
} else if (dir == 'AP') {
let aflt = Math.abs(flt);
let lab = (flt < 0) ? 'P' : 'A';
return aflt.toFixed(ndec) + lab;
} else if (dir == 'IS') {
let aflt = Math.abs(flt);
let lab = (flt < 0) ? 'I' : 'S';
return aflt.toFixed(ndec) + lab;
} else {
return '';
}
}
</script>
</head>
<body>
<!-- start NiiVue canvas for: nvcan_corr_errts -->
<div class="class_niivue" id="nvcan_corr_errts_container">
<canvas id="nvcan_corr_errts">
</canvas>
<footer id="nvcan_corr_errts_xyz" style="color:#fff; ">
</footer>
<script>
function reportCoorAndValues(data) {
// coord str
let x = flt2str0_dir(data.mm[0], 3, 'RL')
let y = flt2str0_dir(data.mm[1], 3, 'AP')
let z = flt2str0_dir(data.mm[2], 3, 'IS')
let str_c = ' xyz:[' +
x.padStart(8).replace(/ /g, ' ') + ' ' +
y.padStart(8).replace(/ /g, ' ') + ' ' +
z.padStart(8).replace(/ /g, ' ') + '], '
// value str (accommodate Olay/Thr being present or not)
let u = flt2str0(data.values[0].value, 6) // always have ulay
let o = 'NA';
let t = 'NA';
if (data.values.length > 1) { // do we have olay?
o = flt2str0(data.values[1].value, 6);
}
if (data.values.length > 2) { // do we have thr?
t = flt2str0(data.values[2].value, 6);
}
let str_v = 'UOT:[' +
u.padStart(12).replace(/ /g, ' ') + ' ' +
o.padStart(12).replace(/ /g, ' ') + ' ' +
t.padStart(12).replace(/ /g, ' ') + ']'
document.getElementById('nvcan_corr_errts_xyz').innerHTML = str_c + str_v;
}
const nvobj_corr_errts = new niivue.Niivue(
{ logging: true,
show3Dcrosshair: true,
onLocationChange: reportCoorAndValues,
}
)
nvobj_corr_errts.opts.isColorbar = false; // just use from HTML
nvobj_corr_errts.opts.sagittalNoseLeft = true;
nvobj_corr_errts.opts.isRadiologicalConvention = false;
nvobj_corr_errts.opts.isCornerOrientationText = true;
nvobj_corr_errts.attachTo('nvcan_corr_errts');
nvobj_corr_errts.loadVolumes([
{ // ulay
url:"./MNI152_2009_template_SSW.nii.gz",
cal_max: 1296.72432,
}, { // olay
url:"./corr_brain+tlrc.HEAD",
frame4D: 0, // idx of vol
colormap: "afni_reds_inv",
colormapNegative: "afni_blues_inv",
cal_min: 0,
cal_max: 0.6,
opacity: 1.0,
}, { // thr
url:"./corr_brain+tlrc.HEAD", // same dset as olay
frame4D: 0, // idx of vol
colormap: "blue",
colormapNegative: "blue",
cal_min: 0,
cal_max: 0.3,
opacity: 0,
}
]).then(()=>{ // more actions
if ( nvobj_corr_errts.volumes.length > 1 ) {
nvobj_corr_errts.volumes[1].alphaThreshold = true; // alpha for olay
}
nvobj_corr_errts.overlayOutlineWidth = 1;
nvobj_corr_errts.opts.multiplanarForceRender = true;
nvobj_corr_errts.backgroundMasksOverlays = true;
nvobj_corr_errts.setModulationImage(
nvobj_corr_errts.volumes[1].id,
nvobj_corr_errts.volumes[2].id,
modulateAlpha = 2.0
); // activate+specify mapping
nvobj_corr_errts.scene.crosshairPos = nvobj_corr_errts.mm2frac([-1, -17, 5.0]); // jump to XYZ
nvobj_corr_errts.updateGLVolume();
})
</script>
</div>
</body>
</html>