mne-tools / mne-bids-pipeline

Automatically process entire electrophysiological datasets using MNE-Python.
https://mne.tools/mne-bids-pipeline/
BSD 3-Clause "New" or "Revised" License
137 stars 65 forks source link

_5_make_epochs fails with critical error #785

Open hyruuk opened 1 year ago

hyruuk commented 1 year ago

Description of the problem

mne_bids_pipeline fails to segment my data based on event markers.

Steps to reproduce

Run mne_bids_pipeline on the following BIDS data sample (the configuration file have been saved in the report)

Link to data

https://u.pcloud.link/publink/show?code=XZJyGaVZGY8wcRMFIR7tXQ4KjkRzkBlH053X

Expected results

The pipeline should produce an epoched file.

Actual results

The pipeline crashes when asserting that some time window is not void of events (it apparently is).

[17:33:54] │ ⏳️ preprocessing/_05_make_epochs sub-05 run-02 Creating task-related epochs …
Used Annotations descriptions: ['Freq', 'Rare', 'Resp']
[17:33:54] │ 🐛 preprocessing/_05_make_epochs sub-05 A critical error occurred. The error message was:

Starting post-mortem debugger.
<traceback object at 0x7fd05634ae80>
> /home/hyruuk/mambaforge/envs/saflow/lib/python3.11/site-packages/mne/epochs.py(2882)make_metadata()
-> assert not events_in_window.empty

The _5_make_epochs script never completes. Investigating more, I find that the metadata dataframe generated in the MNE call is suspicious (contains all NaNs and values of ~0.5 or ~1 when I would expect timing onsets in seconds - if I understand correctly), although events_df looks fine and contains correct events and sample indexes.

Additional information

Platform Linux-5.15.0-79-generic-x86_64-with-glibc2.35 Python 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0] Executable /home/hyruuk/mambaforge/envs/saflow/bin/python3.11 CPU x86_64 (8 cores) Memory 31.1 GB

Core ├☑ mne 1.5.0 ├☑ numpy 1.24.4 (OpenBLAS 0.3.23 with 8 threads) ├☑ scipy 1.11.2 ├☑ matplotlib 3.7.2 (backend=agg) ├☑ pooch 1.7.0 └☑ jinja2 3.1.2

Numerical (optional) ├☑ sklearn 1.3.0 ├☑ numba 0.57.1 ├☑ nibabel 5.1.0 ├☑ nilearn 0.10.1 ├☑ dipy 1.7.0 ├☑ openmeeg 2.5.6 ├☑ pandas 2.0.3 └☐ unavailable cupy

Visualization (optional) ├☑ pyvista 0.41.1 (OpenGL 4.6 (Core Profile) Mesa 23.0.4-0ubuntu1~22.04.1 via Mesa Intel(R) Iris(R) Plus Graphics (ICL GT2)) ├☑ pyvistaqt 0.0.0 ├☑ ipyvtklink 0.2.2 ├☑ vtk 9.2.6 ├☑ qtpy 2.3.1 (PyQt5=5.15.8) ├☑ pyqtgraph 0.13.3 ├☑ mne-qt-browser 0.5.2 └☐ unavailable ipympl

Ecosystem (optional) ├☑ mne-bids 0.13 ├☑ mne-bids-pipeline 1.4.0 └☐ unavailable mne-nirs, mne-features, mne-connectivity, mne-icalabel

welcome[bot] commented 1 year ago

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

hoechenberger commented 1 year ago

Hello @hyruuk, could you set on_error = "abort" in your configuration file, re-run, and paste the full traceback here? Thanks!

hyruuk commented 1 year ago

Hi !

Oops yeah I had interactive mode active that's why I couldn't see the full traceback, thanks.

­­­

(saflow) hyruuk@hyruuk-laplin:~/GitHub/cocolab/cc_saflow$ mne_bids_pipeline --config saflow/bids-pipeline/config.py
[09:21:51] ╶╴👋 Welcome aboard the MNE BIDS Pipeline!
[09:21:51] ╶╴🧾 Using configuration: saflow/bids-pipeline/config.py
──────────────────────────────────────────────────────────────────────────────────────────────
[09:21:51] ┌╴🚀 init/_01_init_derivatives_dir Now running  👇
[09:21:51] └╴🎉 init/_01_init_derivatives_dir Done running  👆 [1s]
──────────────────────────────────────────────────────────────────────────────────────────────
[09:21:51] ┌╴🚀 init/_02_find_empty_room Now running  👇
The MEG sidecar file does not contain an "AssociatedEmptyRoom" entry. Aborting search for an empty-room recording, as you passed use_sidecar_only=True
[09:21:51] │ ✅ init/_02_find_empty_room sub-05 run-02 Computation unnecessary (cached) …
[09:21:51] └╴🎉 init/_02_find_empty_room Done running  👆 [1s]
──────────────────────────────────────────────────────────────────────────────────────────────
[09:21:51] ┌╴🚀 preprocessing/_01_data_quality Now running  👇
[09:21:52] │ ✅ preprocessing/_01_data_quality sub-05 run-02 Computation unnecessary (cached) …
[09:21:52] └╴🎉 preprocessing/_01_data_quality Done running  👆 [2s]
──────────────────────────────────────────────────────────────────────────────────────────────
[09:21:52] ┌╴🚀 preprocessing/_02_head_pos Now running  👇
[09:21:52] │ ⏩ preprocessing/_02_head_pos Skipping …
[09:21:52] └╴🎉 preprocessing/_02_head_pos Done running  👆 [1s]
──────────────────────────────────────────────────────────────────────────────────────────────
[09:21:52] ┌╴🚀 preprocessing/_03_maxfilter Now running  👇
[09:21:52] │ ⏩ preprocessing/_03_maxfilter Skipping …
[09:21:52] └╴🎉 preprocessing/_03_maxfilter Done running  👆 [1s]
──────────────────────────────────────────────────────────────────────────────────────────────
[09:21:52] ┌╴🚀 preprocessing/_04_frequency_filter Now running  👇
[09:21:54] │ ✅ preprocessing/_04_frequency_filter sub-05 run-02 Computation unnecessary (cached) …
[09:21:54] └╴🎉 preprocessing/_04_frequency_filter Done running  👆 [2s]
──────────────────────────────────────────────────────────────────────────────────────────────
[09:21:54] ┌╴🚀 preprocessing/_05_make_epochs Now running  👇
Opening raw data file /media/hyruuk/CoCoLabYANN/coco_data/saflow/bids_sample/derivatives/mne-bids-pipeline/sub-05/meg/sub-05_task-gradCPT_run-02_proc-filt_raw.fif...
    Read 5 compensation matrices
    Range : 0 ... 29999 =      0.000 ...    49.998 secs
Ready.
Current compensation grade : 3
Used Annotations descriptions: ['Freq', 'Rare', 'Resp']
[09:21:54] │ ⏳️ preprocessing/_05_make_epochs sub-05 run-02 Loading filtered raw data from sub-05_task-gradCPT_run-02_proc-filt_raw.fif
Opening raw data file /media/hyruuk/CoCoLabYANN/coco_data/saflow/bids_sample/derivatives/mne-bids-pipeline/sub-05/meg/sub-05_task-gradCPT_run-02_proc-filt_raw.fif...
    Read 5 compensation matrices
    Range : 0 ... 29999 =      0.000 ...    49.998 secs
Ready.
Current compensation grade : 3
Reading 0 ... 29999  =      0.000 ...    49.998 secs...
[09:21:54] │ ⏳️ preprocessing/_05_make_epochs sub-05 run-02 Creating task-related epochs …
Used Annotations descriptions: ['Freq', 'Rare', 'Resp']
[09:21:54] │ ❌ preprocessing/_05_make_epochs sub-05 A critical error occurred. The error message was:

Aborting pipeline run. The traceback is:

  File "/home/hyruuk/mambaforge/envs/saflow/lib/python3.11/site-packages/mne_bids_pipeline/_run.py", line 55, in __mne_bids_pipeline_failsafe_wrapper__
    out = memory.cache(func)(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyruuk/mambaforge/envs/saflow/lib/python3.11/site-packages/mne_bids_pipeline/_run.py", line 268, in wrapper
    out_files = memorized_func(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyruuk/mambaforge/envs/saflow/lib/python3.11/site-packages/joblib/memory.py", line 655, in __call__
    return self._cached_call(args, kwargs)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyruuk/mambaforge/envs/saflow/lib/python3.11/site-packages/joblib/memory.py", line 598, in _cached_call
    out, metadata = self.call(*args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyruuk/mambaforge/envs/saflow/lib/python3.11/site-packages/joblib/memory.py", line 856, in call
    output = self.func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyruuk/mambaforge/envs/saflow/lib/python3.11/site-packages/mne_bids_pipeline/steps/preprocessing/_05_make_epochs.py", line 117, in run_epochs
    epochs = make_epochs(
             ^^^^^^^^^^^^
  File "/home/hyruuk/mambaforge/envs/saflow/lib/python3.11/site-packages/mne_bids_pipeline/_import_data.py", line 97, in make_epochs
    metadata, events, event_id = mne.epochs.make_metadata(
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyruuk/mambaforge/envs/saflow/lib/python3.11/site-packages/mne/epochs.py", line 2882, in make_metadata
    assert not events_in_window.empty
­­­­