Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code
- clc
- clear
- close all
- % wfdb2mat('mitdb/100')
- % save('Filter','BP_Filter');
- dataset='106';
- load Filter
- % load 100m.mat
- [Raw_ECG_Signal,Fs,tm]=rdsamp(dataset);
- [ann, anntype]=rdann(dataset,'atr',[],108000);
- % anntime=wfdbtime(dataset,ann);
- Channel1_Raw_ECG=Raw_ECG_Signal(1:108000,1);
- Filtered_Channel1=BP_Filter(Channel1_Raw_ECG);
- [p,s,mu] = polyfit((1:numel(Filtered_Channel1))',Filtered_Channel1,20);
- f_y = polyval(p,(1:numel(Filtered_Channel1))',[],mu);
- Detrended_Channel1_ECG = Filtered_Channel1 - f_y; % Detrend data
- Smoothed_Channel1=1.7.*smoothdata(Detrended_Channel1_ECG,'gaussian',20);
- [~,loc]=findpeaks(Smoothed_Channel1,'MinPeakHeight',0.5,'MinPeakDistance',200);
- for i=5:length(loc)-1
- pd=Smoothed_Channel1(loc(i)-70:loc(i)+145);
- fig=figure;
- fig.Visible='off';
- plot(pd)
- axis off
- fpname=strcat('C:UsersSHIFAT GILLANIDesktopUMAIRECGNormalImg',num2str(i),'.tiff');
- saveas(fig,fpname,'tiff')
- figrsz=imresize(imread(fpname,'tiff'),[227 227]);
- imwrite(figrsz,fpname,'tiff')
- end
- % TS = dsp.TimeScope('SampleRate',360,...
- % 'TimeSpan',5,...
- % 'YLimits',[-1 1],...
- % 'ShowGrid',true,...
- % 'NumInputPorts',3,...
- % 'LayoutDimensions',[3 1],...
- % 'TimeAxisLabels','Bottom',...
- % 'Title','Noisy and Filtered Signals');
- % tic;
- % while toc<5
- % toc
- % TS(Channel1_Raw_ECG, Detrended_Channel1_ECG, Smoothed_Channel1);
- % end
- % release(TS)
- wt = modwt(Smoothed_Channel1,5);
- wtrec = zeros(size(wt));
- wtrec(4:5,:) = wt(4:5,:);
- y = imodwt(wtrec,'sym4');
- y = abs(y).^2;
- [~,locs] = findpeaks(y,'MinPeakHeight',0.35,'MinPeakDistance',200);
- for i=1:length(locs)-1
- hr(i)=60*(360/(locs(i+1)-locs(i)));
- end
- [a,b,c,d,e,f]=rdann(dataset,'atr');
Add Comment
Please, Sign In to add comment