-
Notifications
You must be signed in to change notification settings - Fork 0
/
nifti_viewer.html
162 lines (144 loc) · 4.88 KB
/
nifti_viewer.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<title>Remy's NIfTI Viewer</title>
<link rel="stylesheet" type="text/css" href="papaya.css?build=1456">
<script type="text/javascript" src="papaya.js?build=1456"></script>
<style>
/* General Styles */
body, html {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
height: 100%;
overflow: auto;
display: flex;
flex-direction: column;
}
/* Layout Container */
.container {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-start; /* Align items to the top of the page */
height: 100vh; /* Full viewport height */
overflow: hidden;
}
/* Sidebar Styles */
.sidebar {
width: 25%;
max-width: 300px;
padding: 4rem 1rem 1rem; /* Add extra padding to avoid overlap with the home button */
background: #ffffff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow-y: auto;
}
/* Content Styles */
.content {
flex-grow: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start; /* Push the viewer closer to the top */
padding: 1rem;
}
#papayaContainer {
width: 75%;
height: 65%;
max-width: 1200px;
max-height: 850px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
position: relative;
}
.info {
width: 100%;
text-align: center;
background: #ffffff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 1rem;
}
/* Home Button */
.home-button {
position: fixed;
top: 10px;
left: 10px;
padding: 10px 20px;
background-color: #007BFF;
color: white;
border-radius: 5px;
text-decoration: none;
z-index: 10;
}
/* Responsive Design */
@media (max-width: 768px) {
.container {
flex-direction: column;
}
.sidebar {
display: none;
}
#papayaContainer {
width: 90%;
height: 50vh;
max-width: none;
max-height: none;
}
}
</style>
</head>
<body>
<a href="index.html" class="home-button">Home</a>
<div class="container">
<!-- Sidebar -->
<div class="sidebar">
<h3>Instructions</h3>
<p>This viewer is pre-loaded with the MNI 152 standard brain. Hover or click on the brain to see anatomical labels.</p>
<p>To load your own image:</p>
<ol>
<li>Click on <strong>File</strong></li>
<li>Click on <strong>Close ALL</strong></li>
</ol>
<p>Drag and drop your <code>.nii.gz</code> file or click on <strong>File</strong> → <strong>Add Image</strong>.</p>
</div>
<!-- Papaya Viewer -->
<div class="content">
<div id="papayaContainer"></div>
</div>
</div>
<script type="text/javascript">
var params = {
images: ["images/mni152.nii.gz"],
worldSpace: true,
showControls: true
};
function resizePapaya() {
const container = document.getElementById("papayaContainer");
// Dynamically calculate size
const containerWidth = Math.min(window.innerWidth * 0.75, 1200); // 75% width, max 1200px
const containerHeight = Math.min(window.innerHeight * 0.65, 850); // 65% height, max 850px
// Set container dimensions
container.style.width = containerWidth + "px";
container.style.height = containerHeight + "px";
// Resize Papaya
papaya.Container.resizeViewer(0);
// Ensure canvas fits container
const canvas = container.querySelector("canvas");
if (canvas) {
canvas.style.width = containerWidth + "px";
canvas.style.height = containerHeight + "px";
}
}
// Initialise Papaya Viewer
window.onload = function () {
papaya.Container.addViewer("papayaContainer", params);
// Resize on load
resizePapaya();
};
// Resize dynamically on window changes
window.addEventListener("resize", resizePapaya);
</script>
</body>
</html>