Repository: mne-tools/mne-python

Issue:
Exporting epochs is not working if epochs have been concatenated
### Description of the problem

Hi all,
I ma facing this error for which exporting epochs using mne.export_epochs() will fail if epochs were concatenated using mne.concatenate_epochs.

I understand from previous issues (e.g. #11131) that this is because mne.concatenate_epochs has no support for annotations, however either the concatenate function should generate empty annotations, or the export function should handle missing annotations. 

I tried to solve it myself using the second approach as I needed it rapidly, by editing the file mne-python/mne/export/_eeglab.py. See https://github.com/Gabrock94/mne-python

The workaround I used is to edit Line 45 from:
`if len(epochs.annotations) > 0:`

to:

```
if (type(epochs.annotations)!=None.__class__):
        if (len(epochs.annotations) > 0):
```

however probably fixing the concatenation function would be a better approach. 


### Steps to reproduce

```Python
import mne
mne.datasets.sample.data_path(verbose=True)

raw = mne.io.read_raw_fif('~/mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif', verbose=False).load_data()
events = mne.find_events(raw, shortest_event=1)

epochs = mne.Epochs(raw, events, tmin=-1, tmax = 1, detrend = 0, event_id={'LA':1, 'RA':2})
epochsCombined =  mne.concatenate_epochs([epochs['LA'], epochs['RA']])
mne.export.export_epochs('~/mne_data/MNE-sample-data/MEG/sample/test.set', epochsCombined, fmt='auto')
```


### Link to data

_No response_

### Expected results

Epochs should be exported with no annotations. 

### Actual results

Traceback (most recent call last):

  File "/usr/local/lib/python3.8/dist-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "/home/giulio/Repositories/spinrec_giulio/Scripts/untitled4.py", line 16, in <module>
    mne.export.export_epochs('~/mne_data/MNE-sample-data/MEG/sample/test.set', epochsCombined, fmt='auto')

  File "<decorator-gen-601>", line 12, in export_epochs

  File "/usr/local/lib/python3.8/dist-packages/mne/export/_export.py", line 105, in export_epochs
    _export_epochs(fname, epochs)

  File "/usr/local/lib/python3.8/dist-packages/mne/export/_eeglab.py", line 45, in _export_epochs
    if len(epochs.annotations) > 0:

TypeError: object of type 'NoneType' has no len()

### Additional information

mne.sys_info()
Platform:         Linux-5.15.0-58-generic-x86_64-with-glibc2.29
Python:           3.8.10 (default, Nov 14 2022, 12:59:47)  [GCC 9.4.0]
Executable:       /usr/bin/python3
CPU:              x86_64: 20 cores
Memory:           31.1 GB

mne:              1.3.0
numpy:            1.22.3 {OpenBLAS 0.3.18 with 20 threads}
scipy:            1.8.0
matplotlib:       3.5.1 {backend=Qt5Agg}

sklearn:          1.0.2
numba:            Not found
nibabel:          Not found
nilearn:          Not found
dipy:             Not found
openmeeg:         Not found
cupy:             10.3.0
pandas:           1.4.2
pyvista:          Not found
pyvistaqt:        Not found
ipyvtklink:       Not found
vtk:              Not found
qtpy:             2.0.1 {PyQt5=5.15.2}
ipympl:           Not found
pyqtgraph:        Not found
pooch:            v1.6.0

mne_bids:         Not found
mne_nirs:         Not found
mne_features:     Not found
mne_qt_browser:   Not found
mne_connectivity: Not found
mne_icalabel:     Not found


Discussion:

Resolving patch:
diff --git a/mne/datasets/config.py b/mne/datasets/config.py
--- a/mne/datasets/config.py
+++ b/mne/datasets/config.py
@@ -87,7 +87,7 @@
 # respective repos, and make a new release of the dataset on GitHub. Then
 # update the checksum in the MNE_DATASETS dict below, and change version
 # here:                  ↓↓↓↓↓         ↓↓↓
-RELEASES = dict(testing='0.141', misc='0.24')
+RELEASES = dict(testing='0.142', misc='0.24')
 TESTING_VERSIONED = f'mne-testing-data-{RELEASES["testing"]}'
 MISC_VERSIONED = f'mne-misc-data-{RELEASES["misc"]}'
 
@@ -111,7 +111,7 @@
 # Testing and misc are at the top as they're updated most often
 MNE_DATASETS['testing'] = dict(
     archive_name=f'{TESTING_VERSIONED}.tar.gz',
-    hash='md5:08b1e81e944de9616a408eb70d73775b',
+    hash='md5:44b857ddb34aefd752e4f5b19d625dee',
     url=('https://codeload.github.com/mne-tools/mne-testing-data/'
          f'tar.gz/{RELEASES["testing"]}'),
     # In case we ever have to resort to osf.io again...
diff --git a/mne/export/_eeglab.py b/mne/export/_eeglab.py
--- a/mne/export/_eeglab.py
+++ b/mne/export/_eeglab.py
@@ -42,7 +42,7 @@ def _export_epochs(fname, epochs):
     ch_names = [ch for ch in epochs.ch_names if ch not in drop_chs]
     cart_coords = _get_als_coords_from_chs(epochs.info['chs'], drop_chs)
 
-    if len(epochs.annotations) > 0:
+    if epochs.annotations:
         annot = [epochs.annotations.description, epochs.annotations.onset,
                  epochs.annotations.duration]
     else:


Test patch: