# Discrepancy with epochs numbering with plotting epochs with ICA sources

**URL:** <https://mne.discourse.group/t/discrepancy-with-epochs-numbering-with-plotting-epochs-with-ica-sources/8992>\
**Category:** Support & Discussions\
**Tags:** visualization, epochs\
**Created:** [June 25, 2024, 2:48am UTC](https://mne.discourse.group/t/discrepancy-with-epochs-numbering-with-plotting-epochs-with-ica-sources/8992 "2024-06-25T02:48:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![danieltomasz](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/danieltomasz/32/101_2.png) [@danieltomasz](https://mne.discourse.group/u/danieltomasz)\
**Post date:** [June 25, 2024, 2:48am UTC](https://mne.discourse.group/t/discrepancy-with-epochs-numbering-with-plotting-epochs-with-ica-sources/8992/1 "2024-06-25T02:48:02Z")

</div>

MNE 1.7.1

When I plot error with epochs.plot() epochs are numbered starting from 1, when plot ICA sources with ica.plot\_sources(epochs) epochs numbering starts from 0.

This might be error prone, I spent last hour trying to debug some unexpected results because of this.

---

<div class="post-metadata">

**Author:** ![danieltomasz](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/danieltomasz/32/101_2.png) [@danieltomasz](https://mne.discourse.group/u/danieltomasz)\
**Post date:** [June 25, 2024, 2:56am UTC](https://mne.discourse.group/t/discrepancy-with-epochs-numbering-with-plotting-epochs-with-ica-sources/8992/2 "2024-06-25T02:56:34Z")

</div>

Also autoreject library is indexing epochs from 0 which add to the confusion

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [June 25, 2024, 7:46am UTC](https://mne.discourse.group/t/discrepancy-with-epochs-numbering-with-plotting-epochs-with-ica-sources/8992/3 "2024-06-25T07:46:12Z")

</div>

@danieltomasz Are you sure the first epoch wasn’t dropped when you plotted your epochs? We generally start indexing everything at zero, including epochs.

---

<div class="post-metadata">

**Author:** ![danieltomasz](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/danieltomasz/32/101_2.png) [@danieltomasz](https://mne.discourse.group/u/danieltomasz)\
**Post date:** [June 25, 2024, 12:11pm UTC](https://mne.discourse.group/t/discrepancy-with-epochs-numbering-with-plotting-epochs-with-ica-sources/8992/4 "2024-06-25T12:11:31Z")

</div>

@richard thanks for a quickly reply, you are right that the first epoch was dropped.

I had set reject by annotation to `reject_by_annotation=True` when creating epochs and this was proabably reason of removing epoch nr 0.  
is there a way to reset numbering of epochs after creating them?  
This is confusing, like my orginal case with ICA or with autoreject as well.  
as a step, I am running autoreject to find bad epochs

```python
auto_reject_pre_ica = autoreject.AutoReject(**auto_reject_params).fit(epochs[:20])
epochs_ar, reject_log = auto_reject_pre_ica.transform(epochs, return_log=True)
reject_plot = reject_log.plot("vertical")

```

And it gives me among other things this line

```python
Dropped 11 epochs: 6, 18, 29, 36, 37, 50, 51, 60, 64, 65, 66

```

but when I plot them

```python
scalings = dict(eeg=40e-6)
epochs[reject_log.bad_epochs].plot

```

in plot bad epochs are starting from 7, 19 …. (because now the 0 indexed epoch in Epochs has number 1)

I my pipeline I manually check the bad epochs from autoreject and sometimes remove more bad epochs before ica, having this double numbering may lead me into confusion/errors (however I can understand why this is happening)

---

<div class="post-metadata">

**Author:** ![danieltomasz](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/danieltomasz/32/101_2.png) [@danieltomasz](https://mne.discourse.group/u/danieltomasz)\
**Post date:** [June 25, 2024, 4:51pm UTC](https://mne.discourse.group/t/discrepancy-with-epochs-numbering-with-plotting-epochs-with-ica-sources/8992/5 "2024-06-25T16:51:58Z")

</div>

I was creating epochs from resting state via

```python
events = mne.make_fixed_length_events(
    raw=raw,
    start=0,
    stop=None,
    duration=5,
    overlap=1.5,
    first_samp=True,
)

```

The culprit was first\_samp=`False’ causing first epoch to be dropped.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [July 2, 2024, 4:52pm UTC](https://mne.discourse.group/t/discrepancy-with-epochs-numbering-with-plotting-epochs-with-ica-sources/8992/6 "2024-07-02T16:52:08Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
