function fta(fileuse); %FTA(fileuse) Frequency Transform Analysis % % fileuse ('choosenew'): whether to choose a new file set or use an old one % %Examples: % fta % fta('useold'); % PRODUCE PLOTS FROM RR DATA (script emailed from Thanos to Bob 8/1/00; % modified a fair bit; later modified by Brandon Beck 5/11/02): % --------------------------------------------------------------------------- % RR intervals and instantaneous heart rate graphs % Tests on the input arguments if (nargin==0) fileuse = 'choosenew'; end %if [ecgfilename, cdfilename, rrfilename, hrfilename, ecgfilenameonly] = chooser(fileuse); fs = textread(cdfilename, '%f', 1); [rt rr] = textread(rrfilename, '%f %f', -1, 'headerlines', 1); [hrt hr] = textread(hrfilename, '%f %f', -1, 'headerlines', 1); rrsize = size(rr,1); figure(1); subplot(2,1,1); plot(1:rrsize,rr,'k','linewidth',1); axis tight; xlabel('RR interval number'); ylabel('RR interval (ms)'); title('Sample DataSet', 'fontsize', 16, 'fontweight', 'b') subplot(2,1,2); plot(hrt, hr,'k','linewidth',1); axis tight; xlabel('Time (ms)'); ylabel('Heart Rate (Hz)'); % --------------------------------------------------------------------------- % WELCH'S PSD figure(2); clf; nfft = 4*1024; lwdth=1; fsize=12; fweight='b'; [p,f] = psd(hr, nfft, fs, kaiser(nfft/4,5), 0 , 0.99,'mean'); [p2,f2] = psd(hr, nfft, fs, hanning(nfft/4), 0 , 0.99,'mean'); plot(f, sqrt(p),'k', 'linewidth', lwdth);set(gca, 'xlim', [0 10]);% z; hold on plot(f2, sqrt(p2), 'r', 'linewidth', lwdth); set(gca, 'xlim', [0 10]);% z; hold off xlabel('Frequency (Hz)', 'fontsize', fsize, 'fontweight', fweight ); ylabel('Sqrt(Power)', 'fontsize', fsize, 'fontweight', fweight ); title('Welch modified periodogram', 'fontsize', 16, 'fontweight', 'b') legend('Kaiser \beta = 4', 'Hanning' ); % --------------------------------------------------------------------------- % Yule-Walker AR method figure(3); clf; nfft = 1024; np = 15; [p,f] = pyulear( hr-median(hr), np, nfft, fs); np = 15; [p2,f2] = pburg( hr-median(hr), np, nfft, fs); plot(f, sqrt(p),'k', 'linewidth', lwdth); set(gca, 'xlim', [0 10]); %z; hold on plot(f2, sqrt(p2), 'r', 'linewidth', lwdth); set(gca, 'xlim', [0 10]); %z; hold off xlabel('Frequency (Hz)', 'fontsize', fsize, 'fontweight', fweight ); ylabel('Sqrt(Power)', 'fontsize', fsize, 'fontweight', fweight ); title('Autoregressive Methods', 'fontsize', 16, 'fontweight', 'b') legend('Yule-Walker', 'Burg'); % --------------------------------------------------------------------------- % MUSIC figure(4); clf; nfft = 2*1024; [p,f] = pmusic( hr-median(hr), 20, nfft, fs ); plot(f, sqrt(p),'k', 'linewidth', lwdth); set(gca, 'xlim', [0 10]); %z; xlabel('Frequency (Hz)', 'fontsize', fsize, 'fontweight', fweight ); ylabel('Sqrt(Power)', 'fontsize', fsize, 'fontweight', fweight ); title('Multiple Signal Classification Method (MUSIC)', 'fontsize', 16, 'fontweight', 'b')