Main Content

固定小数点設計の並列調査

この例では、多くのコンピューターにテストを並列に分散して固定小数点設計を調査およびテストする方法を示します。この例では、parfor ループを使用して QRS 検出アルゴリズムの精度をテストします。

設計調査のための並列 for ループの使用

標準の for ループと同様に、parfor ループは、値の範囲に対して一連のステートメントを実行します。parfor コマンドを使用して、コードで並列 for ループを設定し、多くのコンピューターにテストを分散して固定小数点設計を調査します。parfor ループでは、ループ反復が並列で実行され、標準の for ループに比べ、パフォーマンスが向上します。

test_heart_rate_detector_in_parallel スクリプトでは、テスト対象のシステムを設定し、parfor ループ外の結果を含む配列を初期化します。次に、parfor ループを使用して各レコードを並列にテストします。parfor ループはデータを読み込み、システムを実行してから、結果を並列に分類および保存します。parfor ループが完了すると、スクリプトによって結果が表示されます。

%% Run test of all records in a database in parallel
record_names = {'ecg_01','ecg_02','ecg_03','ecg_04','ecg_05','ecg_06',...
    'ecg_07','ecg_08','ecg_09','ecg_10','ecg_11','ecg_12','ecg_13'};

%% Set up the system under test
data_type = 'fixedwrap';
T = heart_rate_detector_types(data_type);
[mex_function_name,Fs_target] = setup_heart_rate_detector(record_names,data_type,T);
 
%% Initialize array to contain results 
results_file_names = cell(size(record_names));

%% Test each record in the database in parallel
parfor record_number = 1:length(record_names);
    % Load data
    record_name = record_names{record_number};
    [ecg,tm,ann,Fs] = load_ecg_data(record_name,Fs_target);
    
    % Run system under test
    detector_outputs = run_heart_rate_detector(mex_function_name,ecg,T);
    
    % Classify results
    [qrs_struct,qrs_stats] = classify_qrs(ann, Fs, detector_outputs);
    
    % Save results
    results_file_names{record_number} = save_heart_rate_data(...
        mex_function_name,record_name,...
        data_type,ecg,tm,ann,Fs,...
        detector_outputs,...
        qrs_struct,qrs_stats);

end

%% Display results
display_ecg_results(record_names, results_file_names);

ループ反復は互いに完全に独立していなければならないため、save および load コマンドを parfor ループ内で直接呼び出すことはできません。ただし、これらのコマンドを呼び出す関数を呼び出すことはできます。この例では、関数 load_ecg_data および save_heart_rate_data が必要なデータを読み込み、保存しています。

テスト対象システムの説明

この例のテスト対象システムでは、QRS 検出間の時間差を測定して心拍数を計算する単純な QRS 検出器をテストします。test_heart_rate_detector_in_parallel スクリプトは ECG 記録を検出アルゴリムに渡します。

以下のプロットは、検出アルゴリズムによって心拍数を算出する QRS 検出を正確に識別する例を示しています。

parfor-plot-good-ecg_04.png

この例では検出アルゴリズムを簡素化しています。例を実行すると表示されるプロットおよび結果を調べると、アルゴリズムが常に正確ではないことが分かります。

      Record    #QRS      TP      FP      FN     DER      Se      +P
      ecg_01     253     195       1      58   23.32   77.08   99.49
      ecg_02     133     133      18       0   13.53  100.00   88.08
      ecg_03      94      94       1       0    1.06  100.00   98.95
      ecg_04      92      91       0       1    1.09   98.91  100.00
      ecg_05      93      91       1       2    3.23   97.85   98.91
      ecg_06     131     131      22       0   16.79  100.00   85.62
      ecg_07     174     173       2       0    1.15  100.00   98.86
      ecg_08     117     116      10       1    9.40   99.15   92.06
      ecg_09     137     137       1       0    0.73  100.00   99.28
      ecg_10      96      96       3       0    3.12  100.00   96.97
      ecg_11      73      73       1       0    1.37  100.00   98.65
      ecg_12     146     145      71       0   48.63  100.00   67.13
      ecg_13     144     144       5       0    3.47  100.00   96.64
      Totals    1683    1619     136      62   11.76   96.31   92.25


Legend:
   #QRS: Total number of QRS Complexes
   TP:   Number of true positive
   FP:   Number of false positive
   FN:   Number of false negative
   DER:  Detection error rate in percent
   Se:   Sensitivity in percent
   +P:   Positive prediction in percent

次のプロットは、検出アルゴリズムによって録音のノイズによる誤検知を識別する例です。

parfor-plot-bad-ecg_02.png

この例で使用されるすべての ECG 記録は、ホビイストの機器で計測されています。PhysioNet データベースの記録された生体信号を使用して、同様の解析を独自に実行できます。これらの記録に関する注釈は医師によって検証されていません。

例の実行

スクリプト例 test_heart_rate_detector_in_parallel を実行します。

test_heart_rate_detector_in_parallel

参考文献

[1] Patrick S. Hamilton, Open Source ECG Analysis Software (OSEA), E.P. Limited, Somerville, MA, 2002.

[2] Gari D Clifford, Francisco Azuaje, and Patrick E. McSharry. Advanced Methods and Tools for ECG Data Analysis, Artech House, 2006.

[3] American National Standard ANSI/AAMI EC38:2007 Medical electrical equipment — Part 2–47: Particular requirements for the safety, including essential performance, of ambulatory electrocardiographic systems, Association for the Advancement of Medical Instrumentation, 2008.

[4] George B. Moody, "Evaluating ECG Analyzers", WaveForm DataBase Applications Guide, Harvard-MIT Division of Health Sciences and Technology, Cambridge, MA, WFDB10.5.23, 13 March 2014.

[5] Ida Laila binti Ahmad, Masnani binti Mohamed, Norul Ain binti Ab Ghani, "Development of a Concept Demonstrator for QRS Complex Detection using Combined Algorithms", 2012 IEEE EMBS International Conference on Biomedical Engineering and Sciences, Langkawi, 17th–19th December 2012.

[6] R. Harikumar, S.N. Shivappriya, "Analysis of QRS Detection Algorithm for Cardiac Abnormalities—A Review", International Journal of Soft Computing and Engineering (IJSCE), ISSN: 2231–2307, Volume–1, Issue–5, November 2011.

参考

| (Parallel Computing Toolbox) | (Parallel Computing Toolbox)