How to normalize signal to have mean=0 and amplitude 0 to 1

조회 수: 137 (최근 30일)
Shay
Shay 2021년 10월 18일
댓글: DGM 2021년 10월 19일
I have single channel EEG data. I have to normalize it to have mean=0 and amplitude should be between 0 to 1 using the formula
N = normalize(A)
I used this but I'm not sure what this is doing to my data. Then I tried the following code, I dont know what to choose for the scale-type so that the amplitude will range between 0 and 1.
N = normalize(A,'center',mean,'scale',scaletype)

답변 (2개)

Mathieu NOE
Mathieu NOE 2021년 10월 18일
hello
if you are not confident how to use normalize , you can do the same thing by
x = x - mean(x); % remove mean value (you can also use detrend)
x = x./max(abs(x)); % normalise data in range +/-1

DGM
DGM 2021년 10월 18일
편집: DGM 2021년 10월 18일
If you have a dataset where the mean is zero and the amplitude is within the interval [0 1], then the entire dataset is zero-valued. In order for the data range to span the interval, the mean must not equal either interval extrema.
I'm going to assume you mean either an interval of [0 1] and a mean of 0.5, or an interval of [-1 1] and a mean of 0.
With simple scaling and translation, you can do one of two things:
  • adjust the data to fit within an interval, with a new mean within that interval
  • adjust the data to span an interval, where the relationship between mean and extrema is unchanged
The expression you give indicates that you want the data to span the interval. Can you distort the symmetry of the data such that both constraints are met? Yes. Is that what you want? Is that appropriate for the analysis?
Disregarding the latter possibility, consider the examples:
% create example data
x = linspace(0,6*pi,100);
y = 2*sin(x).^6 + 1;
% show example
plot(x,y); hold on
plot([0 6*pi],[1 1]*mean(y),':')
% normalize to span [0 1]
yspan = (y-min(y))./(max(y)-min(y));
% yspan = normalize(y,'range',[0 1]);
clf; plot(x,yspan); hold on
plot([0 6*pi],[1 1]*mean(yspan),':')
% normalize to fit within [0 1] with a specified mean
newmean = 0.5; % specify mean constraint
os = max(abs(mean(y)-min(y)),abs(mean(y)-max(y)));
yfitmean = (y-mean(y))./(2*os) + newmean;
% yfitmean = normalize(y,'center',newmean);
clf; plot(x,yfitmean); hold on
plot([0 6*pi],[1 1]*mean(yfitmean),':')
  댓글 수: 2
Shay
Shay 2021년 10월 19일
@DGM I normalized tthe data to have mean = 0 inititally and then rescaled it to the range 0-1. Taking A as my input, I did the following thing.
X = normalize(A,'center');
Y = normalize(X,'range')
DGM
DGM 2021년 10월 19일
The effect of the first operation is discarded by doing the second. Just use the 'range' normalization if that's what you want, since that's what the result is.
x = linspace(0,6*pi,100);
y = 2*sin(x).^6 + 1;
% do both operations in sequence
A = normalize(y,'center');
A = normalize(A,'range');
plot(x,A); hold on
plot([0 6*pi],[1 1]*mean(A),':')
% just do a range normalization
B = normalize(y,'range');
clf
plot(x,B); hold on
plot([0 6*pi],[1 1]*mean(B),':')

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 EEG/MEG/ECoG에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by