How to delete annotations

In MNE:raws[0] is modified in-place to achieve the concatenation. Boundaries of the raw files are annotated bad. If you wish to use the data as continuous recording, you can remove the boundary annotations after concatenation (see[mne.Annotations.delete()]

I learned about the delete function, but when I run it, it will tell me that I am missing a parameter ‘self’. What does this mean? How to apply this function?Thank you.

Hi @camellia - mne Raw objects have an annotations attribute, i.e. raw.annotations. This is where you will want to call the delete method. So in your case, raws[0].annotations.delete() should work.

Scott

Thank you for your answer, but after I made the corrections, the following issues arose:AttributeError: ‘tuple’ object has no attribute ‘Annotations’
May I ask what the reason is?

I see, I was guessing that your raw object is in your raws list, but it’s hard to tell without seeing your code. The error you are seeing is suggesting that raws[0] is a tuple object. You’ll need to identify the variable that you are storing your Raw object in, and then call the .annotations attribute of it.

Yes, because I used a function: mne.io.concatenate_ Raws(). I want to connect multiple pieces of my data together. When I learned this function, I saw this sentence: If you wish to use the data as continuous recording, you can remove the boundary annotations after concatenation (see[mne.Annotations.delete()].So I don’t know how to use this deletion function.

mne.Annotations.delete() is a method of the Annotations class, meaning it operates specifically on an existing Annotations object. It’s not a standalone function you call directly with mne.Annotations.delete(...). That’s whay you got the error you described.

Right, so what is the first raw object that you passed to this function? You need to access the annotations attribute of that raw object. For example:

raws_list = [raw1, raw2, raw3]
mne.io.concatenate_raws(raws_list)
indices_to_remove = [1 , 5]
raw1.annotations.delete(indices_to_remove)

I want to ask what the parameters here mean?

This would select the 2nd and 6th annotation for removal.

1 Like