Borrar filtros
Borrar filtros

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

10 visualizaciones (últimos 30 días)
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 comentarios
dpb
dpb el 22 de Feb. de 2021
You can certainly make a small piece and attach it..."help us help you!"

Iniciar sesión para comentar.

Respuestas (1)

Shadaab Siddiqie
Shadaab Siddiqie el 25 de Feb. de 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.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by