Hello, programmers! I am trying to read the annotation file in python, which contains information about the time (in samples) of the occurrence of V-or N-complexes on the electrocardiogram. The syntax of the function call module wfdb took c github:

import wfdb ann1 = wfdb.Annotation (recordname = 'ann1', annotator = 'atr', sample = [10,20,400], symbol = ['N', 'N', '['], aux_note = [None, None , 'Serious Vfib'])

Here is a description of some parameters in the function:

The record name of the record file is attached to.

extension is stored in.

sample:

symbol: The annotation type according to the standard WFDB codes.

subtype: The marked class / category of each annotation.

chan: The signal channel associated with each annotations.

Here is my code: ann1 = wfdb.Annotation ('C: / Users / 1 / Desktop / 9 sem / 1 zadanie / 14134', extension = 'atr', sample = [10,20,400], symbol = ['V'] )

print (ann1 [1 ::, 1])

those. if I want to count the counts from the second column, an error appears: TypeError: 'Annotation' object is not subscriptable

If I introduce torture just to remove a separate element, it appears

TypeError: 'Annotation' object does not support indexing

What could be the reason? Thank!

ps Here is a sample annotation file. enter image description here

    1 answer 1

    TypeError: 'Annotation' object is not subscriptable

    This error is called if the object is not an array of data, that is, most likely the variable referenced by the error contains a non-enumerated data type (int, char, etc.)

    TypeError: 'Annotation' object does not support indexing

    It means that the object to which you are trying to access does not have the __getitem__ method, and therefore cannot return anything by index.

    Most likely the problem is in attempting to access ann1.

    • Thanks for the clarification, the fact is that if, for example, you simply output an annotation file, for example, print (ann1), then a strange message appears: <wfdb.readwrite.annotations.Annotation object at 0x000001F5B0247940> - rabbit
    • @rabbit, Well, I would not say that it is strange, you get exactly what you ask. The object and its position in memory. I would venture to suggest that you are just not right trying to get an annotation. Read the library documentation carefully. Look for something like Reading or reading reading annotation. - Vasiliy Rusin