mne-bids-pipeline - critical error epoch

Hi !
I am trying to use the mne-bids-pipeline to preprocess my MEG data, but I got an error at the 3rd step (preprocessing/_03_make_epochs) :

[2022-11-13 12:15:15] │ ⏳️ preprocessing/_03_make_epochs sub-02 ses-recording A critical error occurred. The error message was: need at least one array to stack

Starting post-mortem debugger.
Traceback (most recent call last):
  File "/home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/mne_bids_pipeline/_run.py", line 62, in wrapper
    out = memory.cache(func)(*args, **kwargs)
  File "/home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/mne_bids_pipeline/_run.py", line 233, in wrapper
    out_files = memorized_func(*args, **kwargs)
  File "/home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/joblib/memory.py", line 594, in __call__
    return self._cached_call(args, kwargs)[0]
  File "/home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/joblib/memory.py", line 537, in _cached_call
    out, metadata = self.call(*args, **kwargs)
  File "/home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/joblib/memory.py", line 779, in call
    output = self.func(*args, **kwargs)
  File "/home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/mne_bids_pipeline/scripts/preprocessing/_03_make_epochs.py", line 220, in run_epochs
    epochs.plot_image(combine='gfp', sigma=2., cmap='YlGnBu_r')
  File "/home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/mne/epochs.py", line 1256, in plot_image
    return plot_epochs_image(self, picks=picks, sigma=sigma, vmin=vmin,
  File "/home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/mne/viz/epochs.py", line 304, in plot_epochs_image
    image_stack = np.stack(image_list)
  File "<__array_function__ internals>", line 5, in stack
  File "/home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/numpy/core/shape_base.py", line 422, in stack
    raise ValueError('need at least one array to stack')
ValueError: need at least one array to stack
> /home/claraek/miniconda3/envs/Solaugh/lib/python3.10/site-packages/numpy/core/shape_base.py(422)stack()
-> raise ValueError('need at least one array to stack')

I checked which arrays were causing this error by printing them, and this is what I found:

{'ref_meg': {'images': [], 'norm': []}, 'mag': {'images': [array([[147.4465529 , 149.07722538, 134.02208994, ...,  82.84461758,
         92.95923273,  97.75516449],
       [132.51142031, 134.04288592, 124.26501118, ...,  92.06381409,
        100.0684364 , 102.66235884],
       [122.4106138 , 123.32139956, 117.57524368, ...,  98.23945679,
        103.72982839, 105.0058862 ],
       ...,
       [101.70598124,  94.95574152,  84.47773358, ..., 110.17200352,
        110.89617498, 109.86245805],
       [105.32179819,  94.88206344,  82.96342712, ..., 111.60671339,
        108.79773498, 106.51722381],
       [107.53198413,  92.91396   ,  79.28677796, ..., 112.30146907,
        105.76324653, 103.28925194]])], 'norm': [True]}}

It looks like my ref_meg is empty, but it’s not supposed to be. With the first plot provided by the pipeline, I can easily visualize that I have data in ref_meg.
I tried different settings in the config file (like setting ch_type = ‘meg’ or ‘mag’, or changing the duration of my epochs, or even setting one or more conditions to define my epoch), but I couldn’t solve this issue.

Another thing, all my events appear in the first plot (the one that shows the data after filtering with all the events), but one of them is not detected when I place it as a condition for my epoch :

preprocessing/_03_make_epochs sub-02 ses-recording A critical error occurred. The error message was: 'Event name "Bad" could not be found. The following events are present in the data: Good, LaughPosed, LaughReal, OffSet, Start'

I don’t know if these problems I related…

(Really nice pipeline by the way!)
Thank you for your help :slight_smile:

System details :

mne                       1.1.1                    pypi_0    pypi
mne-bids                  0.11.1                   pypi_0    pypi
mne-bids-pipeline         0.1.dev635+gc5c1781          pypi_0    pypi

Operating system :

NAME="Manjaro Linux"
ID=manjaro
ID_LIKE=arch
Kernel: Linux 5.15.60-1-MANJARO

Hello @claraElk and thanks for reporting the issue! Would it be possible for you to share the data you’re using, so we can try to reproduce the problem?

@larsoner Would you have time to look into this?

Best wishes,
Richard

This is almost certainly a picking problem where we should be selecting ref meg but are not. @claraElk is this on some standard dataset, or can you share it as requested by @richard ?