%ARRHYTHMIA 452 objects with 279 features in 13 classes
%
%        X = ARRHYTHMIA(VAL)
%
% The aim is to distinguish between the presence and absence of cardiac
% arrhythmia and to classify it in one of the 13 groups. Class 1 refers
% to 'normal' ECG classes 2 to 13 refer to different classes of
% arrhythmia. 
%
% By default features with missing values are removed. When something else
% is desired, use one of the options in MISVAL for VAL.
%
% SEE ALSO <a href="http://37steps.com/prtools">PRTools Guide</a>, <a href="http://archive.ics.uci.edu/ml/">UCI Website</a>
% PRTOOLS, DATASETS, MISVAL

% Copyright: R.P.W. Duin, r.p.w.duin@37steps.com

function a = arrhythmia(val)

if nargin < 1,   val = 'f-remove'; end
a = pr_loadmatfile;
if isempty(a)
  opt.delimeter = ' ';
  opt.labfeat   = 280;
  fl = {'age' 'sex' 'height' 'weight' 'QRS duration' 'P-R interval' ...
    'Q-T interval' 'T interval' 'P interval' 'QRS' 'T' 'P' 'QRST' ...
    'J' 'heartrate'};
  fl1 = {'Q wave width' 'R wave width' 'S wave width' 'R'' wave width' ...
    'S'' wave width' 'number of intrinsic deflections' ...
    'ragged R wave' 'diphasic derivation of R wave' ...
    'ragged P wave' 'diphasic derivation of P wave' ...
    'ragged T wave' 'diphasic derivation of T wave'};
  fl = [fl strcat('DI-',fl1) strcat('DII-',fl1) strcat('DIII-',fl1) ...
    strcat('AVR-',fl1) strcat('AVL-',fl1) strcat('AVF-',fl1) ...
    strcat('V1-',fl1) strcat('V2-',fl1) strcat('V3-',fl1) ...
    strcat('V4-',fl1) strcat('V5-',fl1) strcat('V6-',fl1)];
  fl2 = {'JJ wave ampl' 'Q wave ampl' 'R wave ampl' ...
    'S wave ampl' 'R'' wave ampl' 'S'' wave ampl' 'P wave ampl' ...
    'T wave ampl' 'QRSA sum' 'QRSTA'};
  fl = [fl strcat('DI-',fl2) strcat('DII-',fl2) strcat('DIII-',fl2) ...
    strcat('AVR-',fl2) strcat('AVL-',fl2) strcat('AVF-',fl2) ...
    strcat('V1-',fl2) strcat('V2-',fl2) strcat('V3-',fl2) ...
    strcat('V4-',fl2) strcat('V5-',fl2) strcat('V6-',fl2)];
  opt.featnames = fl;
  opt.dsetname = 'Arrhythmia normal';
%   opt.classnames = {'benign' 'malignant'};
  opt.desc=['The Arrhymthmia database from UCI. The aim is to ' ...
           'distinguish between the presence and absence of cardiac ' ...
           'arrhythmia and to classify it in one of the 16 groups.'];
  opt.link = 'ftp://ftp.ics.uci.edu/pub/machine-learning-databases/arrhythmia';  
  a = pr_download('http://prtools.tudelft.nl/prdatasets/arrhythmia.dat',[],opt);
end
a = misval(a,val);

return
