Advertisement
Advertisement
| 09.14.2008 at 11:24AM PDT, ID: 23730336 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: |
Source code for wheeze detection:
function wheeze_ratio = wheezefind(y,Fs)
%Spectrogram parameters:
NFFT = 2048;
WINDOW = 128;
numoverlap = 108;
DISPLAY_IMAGES = 0;
%window of interest (Hz, Seconds)
MINFREQ = 200;
MAXFREQ = 2200;
MINTIME = 0;
MAXTIME = 10;
%define length of wheezes
widthMIN=25;
widthMAX=10000;
[B,Freqs,Times] = specgram(y,NFFT,Fs,WINDOW,numoverlap);
MINFREQ = sum(Freqs <= MINFREQ);
MAXFREQ = sum(Freqs <= MAXFREQ);
MINTIME = sum(Times <= MINTIME);
MAXTIME = sum(Times <= MAXTIME);
B = abs(B);
if DISPLAY_IMAGES
figure
imagesc(Times(MINTIME:MAXTIME),Freqs,20*log10(B(:,MINTIME:MAXTIME))),axis xy, colormap('jet')
end
%image is B(freq,time)
specdata = B';
peaksmap = specdata;
% %%%%%%%%%VECTOR METHOD%%%%%%%%%%%
the_mean = repmat(mean(specdata(MINTIME:MAXTIME,:),2),1,length(Freqs));
column = specdata(MINTIME:MAXTIME,:) - the_mean;
variance = repmat(sqrt(1./(length(Freqs)*sum((column.^2),2))),1,length(Freqs));
column = column ./ variance;
peaks = (column > (.5*variance)) .* ((column - circshift(column,[0 1])) > 0) .* ((column - ...
circshift(column,[0 -1])) > 0);
peakdisp = peaks | circshift(peaks,[0 1]) | circshift(peaks,[1 1]) | circshift(peaks,[1 0]);
if DISPLAY_IMAGES
figure
imagesc(Times(MINTIME:MAXTIME),Freqs(MINFREQ:MAXFREQ),...
(peakdisp(MINTIME:MAXTIME,MINFREQ:MAXFREQ)')),axis xy, colormap('jet')
end
peakscore = peaks .* ((column - (circshift(column,[0 1]) + circshift(column,[0 2]) + ...
circshift(column,[0 3])) / 3) > (2.5*variance));
peakscore = peakscore + peaks .* ((column - ((circshift(column,[0 -1]) + ...
circshift(column,[0 -2]) + circshift(column,[0 -3])) / 3)) > (2.5*variance));
peakscore = peakscore + peaks .* (((column - circshift(column,[0 1])) > (2*variance)) .* ...
((column - circshift(column,[0 -1])) > (2*variance)));
peakscore = peakscore + peaks .* (((column - circshift(column,[0 2])) > (3.5*variance)) .* ...
((column - circshift(column,[0 -2])) > (3.5*variance)));
peakscore = peakscore - peaks .* (1 - (column - ((...
circshift(peaks,[0 1]) + circshift(peaks,[0 2]) + circshift(peaks,[0 3]) + ...
circshift(peaks,[0 -1]) + circshift(peaks,[0 -2]) + circshift(peaks,[0 -3])) / 6) > 0));
peakscore = peakscore + peaks .* ((column - ((...
circshift(column,[0 1]) + circshift(column,[0 2]) + circshift(column,[0 3]) + ...
circshift(column,[0 -1]) + circshift(column,[0 -2]) + circshift(column,[0 -3])) / 6)) ...
> (3*variance));
peaksmap = peakscore;
%%%%%%%%%%%%%%%%%
120
if DISPLAY_IMAGES
figure
imagesc(Times(MINTIME:MAXTIME),Freqs(MINFREQ:MAXFREQ), ...
(peaksmap(MINTIME:MAXTIME,MINFREQ:MAXFREQ)')),axis xy, colormap('jet')
end
line = sum(peaksmap(MINTIME:MAXTIME,MINFREQ:MAXFREQ),2);
if DISPLAY_IMAGES
figure
imagesc(Times(MINTIME:MAXTIME),Freqs(MINFREQ:MAXFREQ),line'),axis xy, colormap('jet')
end
newline = zeros(size(line));
ones=0; % ones counter
prom=0;
for i=1:length(line)
% increment the counter of pre-wheezes
if line(i)
prom = prom + line(i);
ones = ones + 1;
end
% a wheeze is defined as a set (width*prominence) product of 1s followed by a 0
if (line(i) == 0)
if (prom >= widthMIN) & (prom <= widthMAX)
%mark with a band
for n = 0:ones
if i-n > 0
newline(i-n) = 1;
end
end
end
ones=0;
prom=0;
end
end
if DISPLAY_IMAGES
figure
imagesc(Times(MINTIME:MAXTIME),Freqs,newline'),axis xy,colormap('jet')
end
wheeze_ratio = mean(newline);
end
|