Skip to content

DOC: document first_samp behavior after crop and RawArray workaround#13685

Open
Famous077 wants to merge 7 commits intomne-tools:mainfrom
Famous077:doc/crop-first-samp-behavior
Open

DOC: document first_samp behavior after crop and RawArray workaround#13685
Famous077 wants to merge 7 commits intomne-tools:mainfrom
Famous077:doc/crop-first-samp-behavior

Conversation

@Famous077
Copy link

@Famous077 Famous077 commented Feb 25, 2026

Reference issue (if any)

Fixed #13278

-->

What does this implement/fix?

Adds a reset_first_samp=False parameter to Raw.crop() that allows
users to treat cropped segments as independent recordings. When set
to True, first_samp is reset to 0 after cropping.

Also adds a Notes section to the docstring explaining the default
first_samp behavior after cropping and documents the RawArray
workaround for users who prefer that approach.

Additional information

As noted in the docstring, setting reset_first_samp=True can break
things if events were extracted before cropping and used afterward.
This is clearly documented in the parameter description to warn users.

The default is False to maintain backward compatibility with existing
code.

note :
This PR was developed with the assistance of an AI coding assistant for guidance on code structure, docstring formatting, and implementation approach.

@welcome
Copy link

welcome bot commented Feb 25, 2026

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

@Famous077
Copy link
Author

Hi @larsoner , Added reset_first_samp=False parameter to Raw.crop() as suggested.
When set to True, it resets first_samp to 0 after cropping, treating
the segment as an independent recording. Also added a warning in the
docs that this can break event indices extracted before cropping.
Happy to update based on feedback.

@Famous077
Copy link
Author

Famous077 commented Feb 25, 2026

Hi @mscheltienne , Could you please take a look when you have time? I’d really value your perspective and any suggestions for improvement.

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An updated example or tutorial showing the behavior desired in #13278 would be good. Also we need updated tests to ensure this works as intended. The doc/ file is incorrectly named. Lastly, please disclose AI usage for this PR

If True, reset :term:`first_samp` to 0 after cropping, treating
the cropped segment as an independent recording. Note that this
can break things if you extracted events before cropping and try
to use them afterward. Default is False.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs versionadded directive

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @larsoner, thank you for the review. I have addressed all the feedbacks:

  • Renamed changelog to 13685.other.rst
  • Added .. versionadded:: 1.12 to reset_first_samp docstring
  • Added regression test test_crop_reset_first_samp
  • Updated changelog to use :newcontrib: format
  • Disclosed AI usage in the PR description

@Famous077 Famous077 requested a review from larsoner March 2, 2026 19:17
@larsoner
Copy link
Member

larsoner commented Mar 4, 2026

@Famous077 if you used AI tools during the development of these changes, could you let us know how you used them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Making possible to edit first_samp after using crop

2 participants