Skip to content

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

Merged
larsoner merged 18 commits intomne-tools:mainfrom
Famous077:doc/crop-first-samp-behavior
Mar 13, 2026
Merged

DOC: document first_samp behavior after crop and RawArray workaround#13685
larsoner merged 18 commits intomne-tools:mainfrom
Famous077:doc/crop-first-samp-behavior

Conversation

@Famous077
Copy link
Contributor

@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.

@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
Contributor 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
Contributor 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
Contributor 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?

@Famous077
Copy link
Contributor Author

Hi @larsoner, Thank you for asking. I used an AI tools mostly for Understanding the codebase, Docstring formatting, Test structure. But, All core decisions like what to implement, what the correct behavior should be, and whether the fix makes sense and requesting for feedback to update according to the suggestion that i get were all made by me. If any of my changes introduce unintended side effects, violate codebase conventions, or create a negative impact in any way, please do not hesitate to point them out directly or close the PR. I will completely understand and take it as a valuable learning experience. I apologize in advance if anything I have done has caused any inconvenience.

@larsoner
Copy link
Member

larsoner commented Mar 5, 2026

An updated example or tutorial showing the behavior

Looks like this one hasn't been done yet ☝️

@Famous077
Copy link
Contributor Author

An updated example or tutorial showing the behavior

Looks like this one hasn't been done yet ☝️

Hi @larsoner , Sorry for the delay due to exams. I have implemented updated example as per your suggestion. Can you check and let me know changes are working correctly or not. Waiting for your feedback and learn more.

@larsoner larsoner merged commit c3db378 into mne-tools:main Mar 13, 2026
31 checks passed
@larsoner
Copy link
Member

Thanks @Famous077 !

@Famous077
Copy link
Contributor Author

Love to learn more from you @larsoner.

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