|
93 | 93 | "outputs": [], |
94 | 94 | "source": [ |
95 | 95 | "files_watch_summary = data_access.summarise_files_in_directory(cfg)\n", |
96 | | - "files_watch_summary\n", |
97 | | - "\n", |
98 | | - "# TODO: fix this warning []" |
| 96 | + "files_watch_summary" |
99 | 97 | ] |
100 | 98 | }, |
101 | 99 | { |
|
183 | 181 | "raw_data_full.head()" |
184 | 182 | ] |
185 | 183 | }, |
186 | | - { |
187 | | - "cell_type": "markdown", |
188 | | - "id": "627b216b-03c1-4e05-a2d9-619710b35445", |
189 | | - "metadata": {}, |
190 | | - "source": [ |
191 | | - "Note: The first value in the `timeDifference` column is `NaN` because [TODO:]" |
192 | | - ] |
193 | | - }, |
194 | 184 | { |
195 | 185 | "cell_type": "markdown", |
196 | 186 | "id": "312181a7-80e7-4e04-a617-cae3f6d803c7", |
|
233 | 223 | "## Visualization" |
234 | 224 | ] |
235 | 225 | }, |
236 | | - { |
237 | | - "cell_type": "markdown", |
238 | | - "id": "d41ffd18-652e-4e98-921c-5753aca89ce3", |
239 | | - "metadata": {}, |
240 | | - "source": [ |
241 | | - "Coarse overview of time-series\n", |
242 | | - "TODO" |
243 | | - ] |
244 | | - }, |
245 | 226 | { |
246 | 227 | "cell_type": "code", |
247 | 228 | "execution_count": null, |
248 | 229 | "id": "cc0e2a43-2484-4c57-9dc7-87f3102d1ea7", |
249 | 230 | "metadata": {}, |
250 | 231 | "outputs": [], |
251 | 232 | "source": [ |
252 | | - "reporting.plotly_data(raw_data_trimmed, cfg)\n", |
253 | | - "\n", |
254 | | - "#TODO 4 second bins (efficiency)" |
255 | | - ] |
256 | | - }, |
257 | | - { |
258 | | - "cell_type": "code", |
259 | | - "execution_count": null, |
260 | | - "id": "4d13fd7b-a6c0-4009-a0d2-0cd497b4be5e", |
261 | | - "metadata": {}, |
262 | | - "outputs": [], |
263 | | - "source": [ |
264 | | - "# Datashader\n", |
265 | | - "import xarray as xr\n", |
266 | | - "import datashader as ds\n", |
267 | | - "import datashader.transfer_functions as tf\n", |
268 | | - "\n", |
269 | | - "\n", |
270 | | - "def get_ds_aggs(df, name_y, h=1500, w=4000):\n", |
271 | | - " # datashader does not have native date support -- convert time to int\n", |
272 | | - " d = df.copy()\n", |
273 | | - " d.loc[:, \"ITime\"] = d[\"time\"].astype(\"int64\")\n", |
274 | | - " d.sort_values(\"ITime\", inplace=True)\n", |
275 | | - " dx_min = d[\"ITime\"].min() # For manual scaling of img\n", |
276 | | - " dx_max = d[\"ITime\"].max()\n", |
277 | | - " dy_min = d[name_y].min() - 2\n", |
278 | | - " dy_max = d[name_y].max() + 2\n", |
279 | | - "\n", |
280 | | - " # For multiple plots (each HR timeseries), cvs must be same size\n", |
281 | | - " cvs = ds.Canvas(\n", |
282 | | - " x_range=(dx_min, dx_max), y_range=(dy_min, dy_max), plot_height=h, plot_width=w\n", |
283 | | - " )\n", |
284 | | - " aggs = {}\n", |
285 | | - " for c in d[\"watchId\"].unique():\n", |
286 | | - " aggs[c] = cvs.line(d[d[\"watchId\"] == c], \"ITime\", name_y)\n", |
287 | | - " return aggs\n", |
288 | | - "\n", |
289 | | - "\n", |
290 | | - "def plot_raw_individual_watches(df, config_dat, value=\"heartRate\"):\n", |
291 | | - " dir_fig_out = config_dat[\"directories\"][\"figures\"]\n", |
292 | | - " df_agg = get_ds_aggs(df, value)\n", |
293 | | - " for w in df_agg.keys():\n", |
294 | | - " img = tf.shade(df_agg[w])\n", |
295 | | - " ds.utils.export_image(img, dir_fig_out + f\"fig_raw_{value}_{w}\")\n", |
296 | | - "\n", |
297 | | - "plot_raw_individual_watches(raw_data_trimmed, cfg, value=\"ppgRaw\")" |
| 233 | + "reporting.plotly_data(raw_data_trimmed, cfg)" |
298 | 234 | ] |
299 | 235 | }, |
300 | 236 | { |
|
353 | 289 | "metadata": {}, |
354 | 290 | "outputs": [], |
355 | 291 | "source": [ |
356 | | - "resampled_data_HR_1000ms.reset_index('time', inplace=True)\n", |
357 | | - "# TODO: fix plotting for resampled df\n" |
| 292 | + "resampled_data_HR_1000ms.reset_index('time', inplace=True)" |
358 | 293 | ] |
359 | 294 | }, |
360 | 295 | { |
|
366 | 301 | "source": [ |
367 | 302 | "reporting.plotly_data(resampled_data_HR_1000ms, cfg)" |
368 | 303 | ] |
369 | | - }, |
370 | | - { |
371 | | - "cell_type": "markdown", |
372 | | - "id": "641e0d26-9d39-4193-b171-c02594c5b1e4", |
373 | | - "metadata": {}, |
374 | | - "source": [ |
375 | | - "## PPG processing" |
376 | | - ] |
377 | | - }, |
378 | | - { |
379 | | - "cell_type": "markdown", |
380 | | - "id": "a1499ff5-7484-420d-a066-df4f5f4ce386", |
381 | | - "metadata": {}, |
382 | | - "source": [] |
383 | | - }, |
384 | | - { |
385 | | - "cell_type": "code", |
386 | | - "execution_count": null, |
387 | | - "id": "2f8516d3-16a6-4709-8f45-259e92292814", |
388 | | - "metadata": {}, |
389 | | - "outputs": [], |
390 | | - "source": [ |
391 | | - "raw_data_trimmed.reset_index(inplace=True) # TODO: Fix in resample_PPG()\n", |
392 | | - "\n", |
393 | | - "resampled_data_PPG_25ms = pipelines.resample_PPG(\n", |
394 | | - " raw_data_trimmed, cfg, save_data=True\n", |
395 | | - ")\n", |
396 | | - "# TODO: Fix warning" |
397 | | - ] |
398 | | - }, |
399 | | - { |
400 | | - "cell_type": "code", |
401 | | - "execution_count": null, |
402 | | - "id": "9438a7c7-d6b4-4edf-b043-9e85152496f1", |
403 | | - "metadata": {}, |
404 | | - "outputs": [], |
405 | | - "source": [ |
406 | | - "resampled_data_PPG_25ms\n", |
407 | | - "\n", |
408 | | - "# Plot output -- compare to original signal" |
409 | | - ] |
410 | | - }, |
411 | | - { |
412 | | - "cell_type": "markdown", |
413 | | - "id": "5b2d351a-eddd-4b9b-99dd-fe42f06cedbb", |
414 | | - "metadata": {}, |
415 | | - "source": [ |
416 | | - "## Peak finding" |
417 | | - ] |
418 | | - }, |
419 | | - { |
420 | | - "cell_type": "code", |
421 | | - "execution_count": null, |
422 | | - "id": "443249d5-bb91-4a29-af75-ecbf77d1fe2e", |
423 | | - "metadata": {}, |
424 | | - "outputs": [], |
425 | | - "source": [ |
426 | | - "PPG_peaks = pipelines.PPG_find_peaks(resampled_data_PPG_25ms, cfg)\n", |
427 | | - "PPG_peaks" |
428 | | - ] |
429 | | - }, |
430 | | - { |
431 | | - "cell_type": "code", |
432 | | - "execution_count": null, |
433 | | - "id": "7c5b1cd2-fd19-4486-ace3-e693362c101d", |
434 | | - "metadata": {}, |
435 | | - "outputs": [], |
436 | | - "source": [] |
437 | | - }, |
438 | | - { |
439 | | - "cell_type": "code", |
440 | | - "execution_count": null, |
441 | | - "id": "dc5c7797-36fd-44b6-ac4d-c785281ac712", |
442 | | - "metadata": {}, |
443 | | - "outputs": [], |
444 | | - "source": [ |
445 | | - "PPG_peaks['PPG_PeaksAlt'] = PPG_peaks['PPG_Peaks'] * PPG_peaks['PPG_Clean'].std() * 3\n", |
446 | | - "PPG_peaks.loc[PPG_peaks['watchId'] == 'W020', ['PPG_Clean', 'PPG_PeaksAlt']].plot(figsize=(1000,5))" |
447 | | - ] |
448 | | - }, |
449 | | - { |
450 | | - "cell_type": "markdown", |
451 | | - "id": "a6d60aac-c751-41bf-99ee-d83a1ba65afd", |
452 | | - "metadata": {}, |
453 | | - "source": [ |
454 | | - "TODO:\n", |
455 | | - "\n", |
456 | | - "Plot comparison of PPG HR and heartRate (from bangle)\n", |
457 | | - "\n", |
458 | | - "more meaningful function names\n", |
459 | | - "\n", |
460 | | - "consistent index axis names\n", |
461 | | - "\n", |
462 | | - "rename plot_raw_data? generalize to any data? also handle resampling.\n", |
463 | | - "\n", |
464 | | - "final data frame PPG-based HRV" |
465 | | - ] |
466 | | - }, |
467 | | - { |
468 | | - "cell_type": "markdown", |
469 | | - "id": "f7c75b73-6ae5-4b59-af15-8a2b92406121", |
470 | | - "metadata": {}, |
471 | | - "source": [ |
472 | | - "# More" |
473 | | - ] |
474 | | - }, |
475 | | - { |
476 | | - "cell_type": "markdown", |
477 | | - "id": "608562f5-85c4-461a-bf70-b0c8172276a4", |
478 | | - "metadata": {}, |
479 | | - "source": [ |
480 | | - "## Read processed data" |
481 | | - ] |
482 | | - }, |
483 | | - { |
484 | | - "cell_type": "code", |
485 | | - "execution_count": null, |
486 | | - "id": "560ed64e-8bd7-4b40-bdce-6690ecdb8b1f", |
487 | | - "metadata": {}, |
488 | | - "outputs": [], |
489 | | - "source": [] |
490 | 304 | } |
491 | 305 | ], |
492 | 306 | "metadata": { |
|
0 commit comments