extract valuable data from signal

11 vues (au cours des 30 derniers jours)
FeiMing
FeiMing le 15 Déc 2012
Commenté : Mansour Aljohani le 25 Juil 2015
I have a signal (vector) consists of many blocks (for example five blocks).I want to extract, separate, these blocks (that contain a valuable information ) from the main signal and store every block in a vector.
So if I have an input vector (V), The result , in our case, should be five mini vectors (v1, v2, v3, v4, v5).
I tried to apply this method: If a specific consecutive elements from (V) vector have a value above a threshold (for example 0.02 > Thr) start put the elements in a a mini vector, but it does not work because values in the input vector (V) are getting positive and negative.
  1 commentaire
Mansour Aljohani
Mansour Aljohani le 25 Juil 2015
Hi,
Did you find the answer. please tell me how? Thank you.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 16 Déc 2012
Modifié(e) : Image Analyst le 16 Déc 2012
Try something like this, where I take the absolute value, then filter it to get rid of the oscillating parts, then take the difference, and finally extract the 5 bursts:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
% Generate sample data.
signal = 0.003 * rand(1, 550) - 0.0015
signal(50:100) = 0.03 * rand(1, 51) - 0.015
signal(150:200) = 0.03 * rand(1, 51) - 0.015
signal(250:300) = 0.03 * rand(1, 51) - 0.015
signal(350:400) = 0.03 * rand(1, 51) - 0.015
signal(450:500) = 0.03 * rand(1, 51) - 0.015
subplot(3, 1, 1);
plot(signal);
title('Original Signal', 'FontSize', fontSize);
grid on;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Take absolute value and median filter to get rid of oscillations.
filteredSignal = medfilt1(abs(signal), 13);
subplot(3, 1, 2);
plot(filteredSignal);
title('Filtered Signal', 'FontSize', fontSize);
% Find the quiet parts between the bursts.
quietParts = filteredSignal < 0.002;
subplot(3, 1, 3);
plot(quietParts, 'LineWidth', 3);
ylim([0 1.2]);
title('Quiet Parts', 'FontSize', fontSize);
% Find the starting and ending elements of the bursts.
startingBlockIndexes = find(diff(quietParts) < 0)
endingBlockIndexes = find(diff(quietParts) > 0)
% Extract the 5 blocks (known to be exactly 5)
v1 = signal(startingBlockIndexes(1):endingBlockIndexes(1));
v2 = signal(startingBlockIndexes(2):endingBlockIndexes(2));
v3 = signal(startingBlockIndexes(3):endingBlockIndexes(3));
v4 = signal(startingBlockIndexes(4):endingBlockIndexes(4));
v5 = signal(startingBlockIndexes(5):endingBlockIndexes(5));
% Plot the 5 signals.
figure;
subplot(5, 1, 1);
plot(v1);
grid on;
title('V1', 'FontSize', fontSize);
subplot(5, 1, 2);
plot(v2);
grid on;
title('V2', 'FontSize', fontSize);
subplot(5, 1, 3);
plot(v3);
grid on;
title('V3', 'FontSize', fontSize);
subplot(5, 1, 4);
plot(v4);
grid on;
title('V4', 'FontSize', fontSize);
subplot(5, 1, 5);
plot(v5);
grid on;
title('V5', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
  2 commentaires
FeiMing
FeiMing le 17 Déc 2012
That is right but only for the signal you generated. It does not work for other signals (I tried to apply your codes on real signals).
Comments:
1- Applying median filter in some cases does not give the required result.
2-Using a filter sometimes removes important information from the original signal, that leads to wrong analysis (the same thing regarding choosing the order of the filter, in your example n=15, changing n gives a wrong result).
3- The same thing regarding choosing threshold level (which determines the length of the block). Changing it does not give the nice train of pulses in Quiet Parts(as you named it).
It will be far better to find a way to split the signal without filtering it, the main idea behind splitting is, to study every block alone without affecting the other block.
To remove the noises in the signal I tried to use this:
filteredSignal=abs((a.*abs(a)/max(abs(a))));
% ( a ) is the signal We want to split it. But it does not work well.
At the end, I constructed high pass filter (hpF) by using filtfilt. The same problem, choosing cut frequency and sampling frequency (for sampling frequency, it is solved by Nyquist).
I followed the same steps you sent(only by changing the median filter and using hpF) it gave almost a good result.
4-One point I used padding zero at the beginning of the signal, to avoid any malfunction in calculating “startingBlockIndexes” and “endingBlockIndexes”. Because at the beginning of the measurements some unwanted noises added to the signal from different sources(of course, putting zeros done after plotting the signal).
At the end, as mentioned above using filter is not the right way to split the signal, but maybe is the only way.
Thanks for the idea.
Image Analyst
Image Analyst le 17 Déc 2012
OK, well as you know, you did not provide your data so I had to make up some. Of course it may need to be tweaked to work with your data. Glad I could point you in the right direction. Mark it as Answered if you're all done with this discussion.

Connectez-vous pour commenter.

Plus de réponses (1)

bym
bym le 15 Déc 2012
Then use
v = V(abs(V)>thr);
  1 commentaire
FeiMing
FeiMing le 16 Déc 2012
Modifié(e) : FeiMing le 16 Déc 2012
That is right, it is (abs), but in this case the output is a one vector that contains all blocks together. But the question is, how to get every block in a mini vector. So the result should be, in our example, five mini vectors not only one.
The reason, I want to study every block alone.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by