Working with the MIT arrhythmia database annotations: how can I convert the characters into numbers?

7 vues (au cours des 30 derniers jours)
I work with MIT arrhythmia database and I want to group the annotations given for each beat in 5 classes, such as:
N={'N','L','R','e','j'}; %non_ectopic_beat
S={'A','a','J','S'}; %supra_ventricular_ectopic_beat
V={'V','E'}; %ventricular_ectopic_beats
F={'F'}; %Fusion_beat
non_beats={'+','/','f','Q'};
How can I search into the annotation files of each ECG signal and replace the letter from those 5 groups with numbers from 1 to 5?
For example, when I have any of the non-ectopic beats ('N', 'L','R','e', or 'j' ) I want to have the label 1. For the secong class ('A','a','J','S') I want to have label 2 and so on.
I am also opened to other suggestion, as my goal is to append these annotatios to the feature set that I extracted from these signals.
The annotations files are in 'atr' format and I read them using the WFDB toolbox:
[ann,anntype]=rdann('100','atr');
%ann has the location of the R peak and anntype has the annotation of each heartbeat
anntype =
2274×1 char array
'+'
'N'
'N'
'N'
'N'
'N'
'N'
'N'
'A'
'N'
'N'
'N'
...
  4 commentaires
dpb
dpb le 22 Fév 2021
You can certainly make a small piece and attach it..."help us help you!"
Ioana Cretu
Ioana Cretu le 22 Fév 2021
I attached a txt file with the annotations from one patient, hope it helps

Connectez-vous pour commenter.

Réponses (1)

Shadaab Siddiqie
Shadaab Siddiqie le 25 Fév 2021
From my understanding you want to replace few strings to few particular numbers. Here is the code which might help you.
content = fileread( 'ann.txt' ) ;
content = strrep( content, 'N', '1' ) ;
content = strrep( content, 'L', '1' ) ;
content = strrep( content, 'V', '3' ) ;
content = strrep( content, '+', '5' ) ;
fId = fopen( 'MyData_updated.txt', 'w' ) ;
fwrite( fId, content ) ;
fclose( fId ) ;
Then you can read new file as numbers.

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by