mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Making possible to edit first_samp after using crop

Open lilly-sanchezz opened this issue 1 year ago • 2 comments

Describe the new feature or enhancement

Hi!

I want to suggest the possibility to change the first_samp attribute when using crop on a raw object. I understand that the reason why this attribute does not start at 0 is to mantain a record of the time frame of the original signal where the segment was extracted, but there are cases where you owuld like to treat the cropped segments as independient signals. It has been suggested to usea RawArrays as an alternative to reset first_samp values, but in my point of view, implementing the option on the crop function makes it easier and faster.

Describe your proposed implementation

Just that, the ability to reset the value of the attribute to treat cropped signals independient raw objects.

Describe possible alternatives

Another alternative is to include information on the documentation about the way crop treats the first _samp on the segments and alternatives to reset it, because this is not noted, and by looking at different entries both on the forum and github we can tell is not that obvious.

Additional context

No response

lilly-sanchezz avatar Jun 05 '25 20:06 lilly-sanchezz

I guess we could add a reset_first_samp=False default where if you set it to True would have the desired behavior. I could live with it as long as we document that it could mess things up (e.g., if you extract events then crop with reset_first_samp=True and try to use those original events, things will be broken).

larsoner avatar Jun 10 '25 14:06 larsoner

HI @lilly-sanchezz @larsoner , I'd be happy to start with the documentation improvement while the feature design is being discussed. I can add a note to the crop() docstring explaining how first_samp behaves after cropping and mention RawArray as the current workaround.

Famous077 avatar Feb 25 '26 06:02 Famous077