Detect signal clipping and remove

40 views (last 30 days)
Kcire L
Kcire L on 22 Jul 2021
Commented: Image Analyst on 31 Jul 2021
Hi,
I have a signal from a microphone that is listening for respiratory audio. When the test subject talks or moves too much, the signal clipps. I am not interested in data that occurs when the subject is talking but I am trying to figure out how to eliminate these sections of the signal from my file. Either remove them entirely, or replace them with a mid level value.
Would anyone here have a good suggestion as to how I could execute this?
Thank you very much in advanced.

Answers (3)

Star Strider
Star Strider on 22 Jul 2021
Edited: Star Strider on 30 Jul 2021
Without an example signal, I am guessing that the ‘clipped’ or ‘railed’ parts of the sound would be equal to ±1, with the valid data being within those limits, however not equal to them. One option would be to set all the values equal to ±1 as NaN, then use rmmissing to delete them, or similar functions (all introduced in R2016b) to interpolate them.
It will likely be necessary to experiment to get the result you want.
—————
EDIT — (30 Jul 2021 at 18:26)
With respect to your Comment, choose a threshold slightly less than 1, (or sllightly greater than 0, or both), assign NaN to all values exceeding than that threshold in either direction, then use rmmissing to delete them. I would need the actual data to write and test specific code.
.
  2 Comments
Kcire L
Kcire L on 30 Jul 2021
I don't think the threshold idea will work, if I choose 0.9 as my threshold I will still get all of the noise in that particular area that is 0.9 and below. I'd really like to omit the entire area in the red blocks. Ideally re-assign them to the mid point without altering the time domain.
Again, I am unable to use rmmissing because the software I have does not support it.
Thank you for your replies.
Star Strider
Star Strider on 30 Jul 2021
The rmmissing function was introduced in R2016b, as was fillmissing that would replace them with 0 or alternatively interpolate the missing values. We have no idea what version or rlelease you are using, since that was not posted. (I assume the latest release unless otherwise stated.)
An alternative would be to simply set the values exceeding the thresholds to 0. That would essentially remove them without disrupting the rest of the file, or the associated time vector (if one exists).
.

Sign in to comment.


Image Analyst
Image Analyst on 22 Jul 2021
Try this
clipValue = max(yourSignal); % Assume clipping occurs, or else just assign some known value, like 1.
badIndexes = yourSIgnal == clipValue;
% Set those elements to zero (won't change the time scale);
yourSignal(badIndexes) = 0;
% Or, delete those elements to zero (will change the time scale);
yourSignal(badIndexes) = [];
If you need more help, attach your signal in a .mat file with the paperclip icon along with a screenshot indicating what values you'd like to process, and whether you'd like to delete them or just set them to zero.

Kcire L
Kcire L on 30 Jul 2021
I'd like the areas highlighted in red to be removed (or zeroed out) but without altering the time domain. I am not able to use the rmmissing funciton to do this.
I have attached a photo if anyone could please help with this I would appreciate it.
Thank you in advanced.
  1 Comment
Image Analyst
Image Analyst on 31 Jul 2021
Remember when I said "If you need more help, attach your signal in a .mat file with the paperclip icon along with a screenshot indicating what values you'd like to process, and whether you'd like to delete them or just set them to zero."?
Well you attached the screenshots, and that's good, but what can we do now? Nothing, because you forgot to attach the signal in a .mat or text file.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!