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

5 Ansichten (letzte 30 Tage)
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 Kommentare
dpb
dpb am 22 Feb. 2021
You can certainly make a small piece and attach it..."help us help you!"

Melden Sie sich an, um zu kommentieren.

Antworten (1)

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

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by