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

10 ビュー (過去 30 日間)
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 件のコメント
dpb
dpb 2021 年 2 月 22 日
You can certainly make a small piece and attach it..."help us help you!"
Ioana Cretu
Ioana Cretu 2021 年 2 月 22 日
I attached a txt file with the annotations from one patient, hope it helps

サインインしてコメントする。

回答 (1 件)

Shadaab Siddiqie
Shadaab Siddiqie 2021 年 2 月 25 日
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.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by