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.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

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!

9.2

How do I modify this matlab program to read in a wave file to do some calculations

Asked by yankeebushsoftware in Signal Processing, Programming Languages, MatLab Programming Language

I have this program to detect wheezing in some wave files, but I need to read in the wave file, can someone show me how to do that, I don't know matlab that well.Start Free Trial
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
[+][-]09.19.2008 at 12:31AM PDT, ID: 22518674

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09.20.2008 at 06:56PM PDT, ID: 22532871

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Signal Processing, Programming Languages, MatLab Programming Language
Sign Up Now!
Solution Provided By: LukeyJay
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628