Skip to content

Commit 3719200

Browse files
authored
Rename Epochs.reset_drop_log_selection() to Epochs.reset_index() (#13675)
1 parent 557eca6 commit 3719200

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

doc/changes/dev/13675.other.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add :meth:`mne.Epochs.reset_index`, which replaces the legacy :meth:`mne.Epochs.reset_drop_log_selection` (the new name better reflects the method's purpose), by `Clemens Brunner`_.

mne/epochs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
check_fname,
9898
check_random_state,
9999
copy_function_doc_to_method_doc,
100+
legacy,
100101
logger,
101102
object_size,
102103
repr_html,
@@ -702,6 +703,7 @@ def _check_consistency(self):
702703
assert all(isinstance(log, tuple) for log in self.drop_log)
703704
assert all(isinstance(s, str) for log in self.drop_log for s in log)
704705

706+
@legacy(alt="mne.Epochs.reset_index()")
705707
def reset_drop_log_selection(self):
706708
"""Reset the drop_log and selection entries.
707709
@@ -711,6 +713,17 @@ def reset_drop_log_selection(self):
711713
many Epochs instances, as ``drop_log`` can accumulate many entries
712714
which can become problematic when saving.
713715
"""
716+
self.reset_index()
717+
718+
def reset_index(self):
719+
"""Reset the epochs index.
720+
721+
This resets the epochs indexing and drop log so that ``self.selection`` becomes
722+
a simple increasing sequence starting at zero and ``self.drop_log`` becomes a
723+
tuple of empty tuples of the same length. The operation is in-place and is
724+
useful when creating epochs from a subset of events (using ``event_id``) and the
725+
original event indexes are not relevant anymore.
726+
"""
714727
self.selection = np.arange(len(self.events))
715728
self.drop_log = (tuple(),) * len(self.events)
716729
self._check_consistency()

0 commit comments

Comments
 (0)