Commit 2176a3c
Gereon Elvers
Armeni / Schoffelen: chunked preprocessing for Colab-class memory budgets
The previous _preprocess_raw_to_h5 called raw.load_data() on the full
recording before running notch + bp + ds. For Armeni sessions (~8 GB
CTF, ~9 GB float64 preloaded) that OOM-killed free Colab runtimes
before any pipeline step ran.
Now we:
- open the recording lazily, drop reference / EEG / EOG / STIM
channels (mne pick("meg")) before any data lands in RAM;
- iterate the recording in chunk_seconds (default 120 s) windows;
- preload + run the full pipeline (notch + bp + ds) inside each chunk
so each filter pass sees a chunk-sized signal;
- after the chunk passes through ds, downcast to float32 — filters
are done and the H5 serializer writes float32 anyway, so the cast
is lossless relative to the on-disk format and halves the
accumulated chunk memory;
- merge tiny last-chunk remainders into the previous chunk so mne is
never asked to filter a sub-second tail (was triggering
filter_length > signal warnings on 305 s recordings).
Verified end-to-end on the VM:
- Armeni sub-001/ses-001/task-compr (8 GB CTF):
fresh build 430 s, peak RSS 4.81 GB (was 10.08 GB before chunking,
OOM in free Colab). 29 460 phoneme samples, 298 MEG channels.
- Schoffelen sub-A2002/task-rest (530 MB CTF):
fresh build 86 s, peak RSS 2.28 GB. 31 trial samples, 301 channels.
Both fit comfortably under 12 GB now.1 parent 0941304 commit 2176a3c
2 files changed
Lines changed: 173 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
390 | 408 | | |
391 | 409 | | |
392 | 410 | | |
393 | 411 | | |
394 | 412 | | |
395 | 413 | | |
396 | 414 | | |
| 415 | + | |
397 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
398 | 422 | | |
399 | 423 | | |
400 | 424 | | |
401 | 425 | | |
402 | 426 | | |
403 | 427 | | |
404 | 428 | | |
405 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
406 | 447 | | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
414 | 463 | | |
415 | | - | |
416 | | - | |
417 | | - | |
| 464 | + | |
| 465 | + | |
418 | 466 | | |
419 | 467 | | |
420 | 468 | | |
421 | 469 | | |
422 | 470 | | |
423 | 471 | | |
424 | 472 | | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
433 | 496 | | |
434 | 497 | | |
435 | 498 | | |
| |||
491 | 554 | | |
492 | 555 | | |
493 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
494 | 579 | | |
495 | 580 | | |
496 | 581 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
356 | 371 | | |
357 | 372 | | |
358 | 373 | | |
359 | 374 | | |
360 | 375 | | |
361 | 376 | | |
362 | 377 | | |
| 378 | + | |
363 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
364 | 385 | | |
365 | 386 | | |
366 | 387 | | |
367 | 388 | | |
368 | 389 | | |
369 | 390 | | |
370 | 391 | | |
371 | | - | |
| 392 | + | |
372 | 393 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
380 | 421 | | |
381 | | - | |
382 | | - | |
383 | | - | |
| 422 | + | |
| 423 | + | |
384 | 424 | | |
385 | 425 | | |
386 | 426 | | |
387 | 427 | | |
388 | 428 | | |
389 | 429 | | |
390 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
391 | 435 | | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
399 | 450 | | |
400 | 451 | | |
401 | 452 | | |
| |||
0 commit comments