eliminate peaks from audio signal

Hi , i'm recorded sound using microphone. The signal isn't noisy , but it has few peaks that sounds like glitches , i need help eliminate this peaks from my signal. I've recorded few time , i'm showing 2 of them

2 Comments

What are the characteristics of these peaks? are all high peaks "glitches" or are the ones that do not go rail to rail okay.
i'm sorry but i'm not sure if i understood your meaning , they are all saturated peaks , there is no info in , almost all of them is +1 or -1 values.

Sign in to comment.

 Accepted Answer

Star Strider
Star Strider on 8 Jun 2015
Edited: Star Strider on 8 Jun 2015
I don’t have your data, but one approach would be to take the mean, then simply threshold your signal using a specific probability.
For instance, to include 99.9% of your data:
CV = @(alpha) -sqrt(2) * erfcinv(2*alpha); % Equivalent to ‘norminv’
alpha = 0.9995;
tail2p = 1-(1-alpha)*2;
zs = CV([(1-alpha)/2 1-(1-alpha)/2])
so your clipping limits would be:
clip = mean(signal) + zs*std(signal);
You would keep everything less than ‘clip(2)’ and greater than ‘clip(1)’.
If that retains too many ‘glitches’, then decrease ‘alpha’ until you get an acceptable result. (The ‘tail2p’ assignment just tells you the percent of your signal you are keeping. It is otherwise not necessary for the code.)

6 Comments

ok , after i'v got the values clip(1) and clip(2) , how i apply it on my vector ? i also included my data
Apologise for the delay. Still asleep here (GMT-6).
You will have to adjust the clipping level to your liking by adjusting ‘alpha’ (increasing it increases the clipping bounds). The rest of the code plots the data to be eliminated and then eliminates the values outside the desired range and interpolates to fill the missing values. This produces a signal vector the same size as the original vector, substituting interpolated values for the out-of-range values. In figure(2), it plots the resulting signal.
The code:
CV = @(alpha) -sqrt(2) * erfcinv(2*alpha); % Equivalent to ‘norminv’
alpha = 0.9995; % Set Clipping Level Here
tail2p = 1-(1-alpha)*2; % Fraction Of Signal Kept
zs = CV([(1-alpha)/2 1-(1-alpha)/2]); % Z-Score
d = load('cob my_data.mat');
sig = d.y; % Signal Vector
tv = [0:length(d.y)-1]./d.Fs; % Time Vector
clip = mean(sig) + zs*std(sig); % Clipping Limits
clpidx = (sig > clip(2)) | (sig < clip(1)); % Eliminate Out-Of-Range Values
nrclipd = sum(clpidx); % Number Of Out-Of-Range Values
figure(1)
plot(tv, sig)
hold on
plot(tv(clpidx), sig(clpidx), '.k')
plot(tv, ones(size(tv))*clip(1), '-r', tv, ones(size(tv))*clip(2), '-r')
hold off
grid
legend('Signal', 'Out-Of-Range Data', 'Clipping Limits','Location','NorthOutside')
title('Original Signal With Clipping Limits & Values To Be Deleted')
xlabel('Time (s)')
ylabel('Amplitude')
clpsig = sig(~clpidx); % Signal Vector To Keep
clptv = tv(~clpidx); % Time Vector To Keep
sigitp = interp1(clptv, clpsig, tv, 'linear'); % Interpolate Clipped Values
figure(2)
plot(tv, sigitp)
grid
axis([xlim -1 +1])
title('Signal After Clipping & Interpolation')
xlabel('Time (s)')
ylabel('Amplitude')
Hi Star Strider , you helped me so much , thank you very very much , it solves me many problems. instead of alpha = 0.9995 , I've used alpha = 0.9985 , and applied notch filter for 50 Hz and LPF for 1000 Hz , and it works and sounds excellent.
THANK YOU !!!!
My pleasure!
The notch filter and LPF are frequently necessary, so good choices on those.
Yours is an interesting project, with potentially significant clinical applications. If you want to expand it, develop ways to detect wheezes, râles, and rhonchi. Those could be valuable in acute care (ICU) monitoring, since to the best of my knowledge, nothing currently exists to detect those.
Hi, the first step is to record , the next step is to recognize wheezes and crackles on the recorded signal. the project is only one semester , and the assignment date is september. so i have to find or develop techniques during then next few weeks . any knowledge and help will be appreciated.
I always suggest starting with a PubMed search. When I did this one just now, one article ‘Computerized lung sound analysis as diagnostic aid for the detection of abnormal lung sounds: a systematic review and meta-analysis’ (it’s free) seems particularly relevant, and two others (none of which I’ve read) seem promising: ‘Validation of computerized wheeze detection in young infants during the first months of life’ (it’s free) and ‘Robust features for detection of crackles: An exploratory study’ (it isn’t). You should be able to get most if not all of the others from your university library.
Click on the ‘Similar articles’ link below a citation to bring up a list of related citations. (I always right-click and choose ‘Open link in new tab’ so I can just close the tab when I’m finished with it, and don’t have to go back through several pages, waiting for each to load.) There are display options just under the gray bar at the top that make it easier to work with. Under ‘Resources’ and ‘How To’ at the very top of the page you can select ‘Training and Tutorials’ for documentation on how to most effectively use PubMed. I’ve been using it for about 20 years, but it changes occasionally so looking through the tutorials every few months to see what has changed is worthwhile.

Sign in to comment.

More Answers (0)

Categories

Asked:

cob
on 8 Jun 2015

Edited:

cob
on 15 Jul 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!