Guest User

Untitled

a guest
Dec 12th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. Code
  2. clc
  3. clear
  4. close all
  5. % wfdb2mat('mitdb/100')
  6. % save('Filter','BP_Filter');
  7. dataset='106';
  8. load Filter
  9. % load 100m.mat
  10. [Raw_ECG_Signal,Fs,tm]=rdsamp(dataset);
  11. [ann, anntype]=rdann(dataset,'atr',[],108000);
  12. % anntime=wfdbtime(dataset,ann);
  13. Channel1_Raw_ECG=Raw_ECG_Signal(1:108000,1);
  14. Filtered_Channel1=BP_Filter(Channel1_Raw_ECG);
  15. [p,s,mu] = polyfit((1:numel(Filtered_Channel1))',Filtered_Channel1,20);
  16. f_y = polyval(p,(1:numel(Filtered_Channel1))',[],mu);
  17. Detrended_Channel1_ECG = Filtered_Channel1 - f_y; % Detrend data
  18. Smoothed_Channel1=1.7.*smoothdata(Detrended_Channel1_ECG,'gaussian',20);
  19. [~,loc]=findpeaks(Smoothed_Channel1,'MinPeakHeight',0.5,'MinPeakDistance',200);
  20. for i=5:length(loc)-1
  21. pd=Smoothed_Channel1(loc(i)-70:loc(i)+145);
  22. fig=figure;
  23. fig.Visible='off';
  24. plot(pd)
  25. axis off
  26. fpname=strcat('C:UsersSHIFAT GILLANIDesktopUMAIRECGNormalImg',num2str(i),'.tiff');
  27. saveas(fig,fpname,'tiff')
  28. figrsz=imresize(imread(fpname,'tiff'),[227 227]);
  29. imwrite(figrsz,fpname,'tiff')
  30. end
  31. % TS = dsp.TimeScope('SampleRate',360,...
  32. % 'TimeSpan',5,...
  33. % 'YLimits',[-1 1],...
  34. % 'ShowGrid',true,...
  35. % 'NumInputPorts',3,...
  36. % 'LayoutDimensions',[3 1],...
  37. % 'TimeAxisLabels','Bottom',...
  38. % 'Title','Noisy and Filtered Signals');
  39. % tic;
  40. % while toc<5
  41. % toc
  42. % TS(Channel1_Raw_ECG, Detrended_Channel1_ECG, Smoothed_Channel1);
  43. % end
  44. % release(TS)
  45. wt = modwt(Smoothed_Channel1,5);
  46. wtrec = zeros(size(wt));
  47. wtrec(4:5,:) = wt(4:5,:);
  48. y = imodwt(wtrec,'sym4');
  49. y = abs(y).^2;
  50. [~,locs] = findpeaks(y,'MinPeakHeight',0.35,'MinPeakDistance',200);
  51. for i=1:length(locs)-1
  52. hr(i)=60*(360/(locs(i+1)-locs(i)));
  53. end
  54. [a,b,c,d,e,f]=rdann(dataset,'atr');
Add Comment
Please, Sign In to add comment