-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
307 lines (264 loc) · 12.8 KB
/
index.html
File metadata and controls
307 lines (264 loc) · 12.8 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CellProfiler WebAssembly Demo</title>
<link rel="stylesheet" href="https://pyscript.net/releases/2024.8.2/core.css">
<script type="module" src="https://pyscript.net/releases/2024.8.2/core.js"></script>
<style>
body {
font-family: system-ui, -apple-system, sans-serif;
padding: 20px;
max-width: 1000px;
margin: auto;
background-color: #f9f9f9;
padding-bottom: 350px;
/* Space for the floating terminal */
}
/* --- Full Screen Loading Overlay --- */
#loading-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.95);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 9999;
/* High Z-index, but lower than the dock */
transition: opacity 0.5s ease;
}
.spinner {
width: 50px;
height: 50px;
border: 5px solid #f3f3f3;
border-top: 5px solid #007bff;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 20px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* --- Floating Bottom Dock --- */
#dev-dock {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 350px;
background: #1e1e1e;
color: #fff;
box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.5);
/* CRITICAL FIX: Z-index 10000 puts it ABOVE the loading screen */
z-index: 10000;
transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
display: flex;
flex-direction: column;
}
#dev-dock.minimized {
transform: translateY(310px);
}
#dock-header {
background: #2d2d2d;
padding: 10px 20px;
cursor: pointer;
font-weight: bold;
display: flex;
justify-content: space-between;
user-select: none;
border-top: 3px solid #007bff;
}
#dock-header:hover {
background: #3d3d3d;
}
#dock-body {
display: flex;
flex: 1;
overflow: hidden;
}
.dock-panel {
flex: 1;
padding: 15px;
overflow-y: auto;
border-right: 1px solid #444;
}
.dock-panel h4 {
margin-top: 0;
color: #888;
text-transform: uppercase;
font-size: 12px;
margin-bottom: 10px;
}
/* Terminal Logs Formatting */
#boot-terminal {
font-family: 'Courier New', monospace;
font-size: 13px;
color: #00ff00;
}
.log-error {
color: #ff5555;
}
.log-warn {
color: #ffff55;
}
.log-info {
color: #55ffff;
}
/* Remove the old .py-repl-box override and use this instead */
.repl-wrapper {
background: #ffffff;
/* Force a white background for the editor */
color: #000000;
padding: 5px;
border-radius: 4px;
margin-top: 10px;
}
</style>
</head>
<body>
<div id="loading-overlay">
<div class="spinner"></div>
<h2>CellProfiler WebAssembly</h2>
<p id="loading-status">Downloading library and initializing engine...</p>
</div>
<div id="ui-container" style="display: none;">
<h2>CellProfiler WebAssembly Demo</h2>
<div
style="border: 1px solid #ccc; padding: 15px; margin-bottom: 10px; border-radius: 5px; background: white; box-shadow: 0 2px 5px rgba(0,0,0,0.05);">
<h3>1. Load Image Set</h3>
<div
style="margin-bottom: 20px; padding: 10px; background: #f8f9fa; border-radius: 4px; display: flex; gap: 20px;">
<label style="cursor: pointer;"><input type="radio" name="source-type" value="upload" checked
onclick="toggleSourceUI()"> 📂 Local File Upload</label>
<label style="cursor: pointer;"><input type="radio" name="source-type" value="url"
onclick="toggleSourceUI()"> 🌐 Remote Example URLs</label>
</div>
<div id="container-upload" style="display: block;">
<div style="margin-bottom: 10px;"><strong>OrigBlue (DAPI):</strong> <input type="file" id="upload-blue"
accept="image/*"></div>
<div style="margin-bottom: 10px;"><strong>OrigGreen (FITC):</strong> <input type="file"
id="upload-green" accept="image/*"></div>
<div style="margin-bottom: 10px;"><strong>OrigRed (Rhodamine):</strong> <input type="file"
id="upload-red" accept="image/*"></div>
</div>
<div id="container-url" style="display: none;">
<p style="font-size: 12px; color: #666; margin-bottom: 15px;">Pre-populated with <i>ExampleFly</i> data
from the CellProfiler repository.</p>
<div style="margin-bottom: 10px; display: flex; flex-direction: row;">
<strong>OrigBlue URL:</strong>
<input type="text" id="url-blue"
value="https://raw.githubusercontent.com/CellProfiler/CellProfiler/main/src/frontend/cellprofiler/data/examples/ExampleFly/images/01_POS002_D.TIF"
style="width: max-content; font-family: monospace; font-size: 11px; padding: 5px; margin-left: 10px; flex: 1">
</div>
<div style="margin-bottom: 10px; display: flex; flex-direction: row;">
<strong>OrigGreen URL:</strong>
<input type="text" id="url-green"
value="https://raw.githubusercontent.com/CellProfiler/CellProfiler/main/src/frontend/cellprofiler/data/examples/ExampleFly/images/01_POS002_F.TIF"
style="width: max-content; font-family: monospace; font-size: 11px; padding: 5px; margin-left: 10px; flex: 1">
</div>
<div style="margin-bottom: 10px; display: flex; flex-direction: row;">
<strong>OrigRed URL:</strong>
<input type="text" id="url-red"
value="https://raw.githubusercontent.com/CellProfiler/CellProfiler/main/src/frontend/cellprofiler/data/examples/ExampleFly/images/01_POS002_R.TIF"
style="width: max-content; font-family: monospace; font-size: 11px; padding: 5px; margin-left: 10px; flex: 1">
</div>
</div>
<button py-click="on_load_images"
style="margin-top: 15px; padding: 10px 20px; background: #28a745; color: white; border: none; cursor: pointer; border-radius: 4px; font-weight: bold; width: 100%;">LOAD
IMAGES</button>
<div id="out-uploads" style="margin-top: 10px; font-weight: bold; text-align: left;"></div>
</div>
<script>
function toggleSourceUI() {
const mode = document.querySelector('input[name="source-type"]:checked').value;
document.getElementById('container-upload').style.display = (mode === 'upload' ? 'block' : 'none');
document.getElementById('container-url').style.display = (mode === 'url' ? 'block' : 'none');
}
</script>
<div style="border: 1px solid #ccc; padding: 15px; margin-bottom: 10px; border-radius: 5px; background: white;">
<h3>2. Crop Blue (DAPI)</h3>
Left: <input type="number" id="crop-b-left" value="501" style="width: 70px;">
Right: <input type="number" id="crop-b-right" value="700" style="width: 70px;">
Top: <input type="number" id="crop-b-top" value="251" style="width: 70px;">
Bottom: <input type="number" id="crop-b-bottom" value="450" style="width: 70px;"><br><br>
<button py-click="on_crop_b"
style="padding: 10px 15px; background: #17a2b8; color: white; border: none; cursor: pointer; border-radius: 4px;">Run
Crop Blue</button>
<div id="out-crop-b-status" style="margin-top: 10px; font-weight: bold;"></div>
<details id="details-crop-b" style="margin-top: 10px; padding-top: 10px; border-top: 1px solid #eee;">
<summary style="cursor: pointer; color: #007bff; font-weight: bold;">👁️ View Output Image</summary>
<div id="out-crop-b-viz" style="margin-top: 10px; text-align: center;"></div>
</details>
</div>
<div style="border: 1px solid #ccc; padding: 15px; margin-bottom: 10px; border-radius: 5px; background: white;">
<h3>3. Identify Primary (Nuclei)</h3>
Min Diam: <input type="number" id="ip-min" value="10" style="width: 70px;">
Max Diam: <input type="number" id="ip-max" value="40" style="width: 70px;"><br><br>
<button py-click="on_ip"
style="padding: 10px 15px; background: #17a2b8; color: white; border: none; cursor: pointer; border-radius: 4px;">Identify
Nuclei</button>
<div id="out-ip-status" style="margin-top: 10px; font-weight: bold;"></div>
<details id="details-ip" style="margin-top: 10px; padding-top: 10px; border-top: 1px solid #eee;">
<summary style="cursor: pointer; color: #007bff; font-weight: bold;">👁️ View Segmentation</summary>
<div id="out-ip-viz" style="margin-top: 10px; text-align: center;"></div>
</details>
</div>
</div>
<div id="dev-dock" class="minimized">
<div id="dock-header" onclick="toggleDock()">
<span>🛠️ Developer Console</span>
<span id="dock-arrow">▲</span>
</div>
<div id="dock-body" style="flex-direction: column; padding: 15px; gap: 10px;">
<div id="boot-terminal"
style="flex: 1; overflow-y: auto; background: #000; padding: 10px; border-radius: 4px; border: 1px solid #444;">
</div>
<div style="display: flex; gap: 10px; height: 50px;">
<textarea id="repl-input" spellcheck="false"
onkeydown="if(event.key === 'Enter' && !event.shiftKey) { event.preventDefault(); document.getElementById('repl-btn').click(); }"
style="flex: 1; background: #222; color: #00ff00; font-family: 'Courier New', monospace; font-size: 13px; border: 1px solid #555; border-radius: 4px; padding: 10px; resize: none;"
placeholder=">>> Type an expression (e.g., state['OrigBlue'].shape) and press Enter..."></textarea>
<button id="repl-btn" py-click="on_repl_run"
style="padding: 0 20px; background: #28a745; color: white; border: none; cursor: pointer; border-radius: 4px; font-weight: bold; text-transform: uppercase;">▶
Run</button>
</div>
</div>
</div>
<script>
function toggleDock() {
const dock = document.getElementById('dev-dock');
const arrow = document.getElementById('dock-arrow');
dock.classList.toggle('minimized');
arrow.innerText = dock.classList.contains('minimized') ? '▲' : '▼';
}
const terminal = document.getElementById('boot-terminal');
function pipeToTerminal(oldFunc, cssClass, prefix) {
return function (...args) {
const msg = args.map(a => typeof a === 'object' ? JSON.stringify(a) : a).join(' ');
terminal.innerHTML += `<div class="${cssClass}">${prefix}${msg}</div>`;
terminal.parentNode.scrollTop = terminal.parentNode.scrollHeight;
oldFunc.apply(console, args);
};
}
console.log = pipeToTerminal(console.log, '', '');
console.info = pipeToTerminal(console.info, 'log-info', '[INFO] ');
console.warn = pipeToTerminal(console.warn, 'log-warn', '[WARN] ');
console.error = pipeToTerminal(console.error, 'log-error', '[ERROR] ');
</script>
<py-config>
interpreter = "https://cdn.jsdelivr.net/pyodide/v0.29.3/full/pyodide.mjs"
packages = ["matplotlib", "numpy", "pydantic"]
</py-config>
<py-script src="./main.py"></py-script>
</body>
</html>