diff --git a/doc/changes/devel/12986.bugfix.rst b/doc/changes/devel/12986.bugfix.rst new file mode 100644 index 00000000000..5bacb548fdd --- /dev/null +++ b/doc/changes/devel/12986.bugfix.rst @@ -0,0 +1 @@ +Fix IndexError when loading CNT file does not have annotations, by :newcontrib:`Ziyi ZENG`. \ No newline at end of file diff --git a/doc/changes/names.inc b/doc/changes/names.inc index 79fbe9b1236..3dfc742b3b3 100644 --- a/doc/changes/names.inc +++ b/doc/changes/names.inc @@ -318,4 +318,5 @@ .. _Yousra Bekhti: https://www.linkedin.com/pub/yousra-bekhti/56/886/421 .. _Yu-Han Luo: https://github.com/yh-luo .. _Zhi Zhang: https://github.com/tczhangzhi/ +.. _Ziyi ZENG: https://github.com/ZiyiTsang .. _Zvi Baratz: https://github.com/ZviBaratz diff --git a/mne/io/cnt/cnt.py b/mne/io/cnt/cnt.py index bd5fb4c2f29..16c074269bf 100644 --- a/mne/io/cnt/cnt.py +++ b/mne/io/cnt/cnt.py @@ -337,7 +337,8 @@ def _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format, he n_samples = data_size // (n_bytes * n_channels) # See: PR #12393 annotations = _read_annotations_cnt(input_fname, data_format="int16") - if annotations.onset[-1] * sfreq > n_samples: + # See: PR #12986 + if len(annotations) and annotations.onset[-1] * sfreq > n_samples: n_bytes = 4 n_samples = n_samples_header warn(