[Eeglablist] Down sample issue
Iman Mohammad-Rezazadeh
irezazadeh at ucdavis.edu
Sat Dec 10 00:07:10 PST 2016
Up-sampling makes the data smoother and consequently compresses its frequency spectrum. On the other hand, down-sampling the data makes it to change faster/ sharper which means broadening the frequency spectrum; however, increasing the highest frequency content in the spectrum may cause aliasing in the data.
http://melodi.ee.washington.edu/courses/ee518/notes/lec9.pdf
So, my two cents are the filtering process should be done before down-sampling.
-Iman
-------------------------------------------------------------
Iman M.Rezazadeh, Ph.D.
HRL Laboratories, Malibu , CA | UCLA Semel Intitute, Los Angeles, CA | Center for Mind and Brain, UC DAVIS, CA
From: eeglablist-bounces at sccn.ucsd.edu [mailto:eeglablist-bounces at sccn.ucsd.edu] On Behalf Of Makoto Miyakoshi
Sent: Friday, December 9, 2016 8:43 PM
To: Ahmad, Jumana <jumana.ahmad at kcl.ac.uk>
Cc: eeglablist at sccn.ucsd.edu
Subject: Re: [Eeglablist] Down sample issue
Dear Jumana,
I don't know much about this process, but it looks like it upsample first, filter, then downsample to the desired frequency in the following way (hence the function name!) upfirdn() is a function called from within resample().
Makoto
>> help upfirdn
upfirdn Upsample, apply a specified FIR filter, and downsample a signal.
upfirdn(X,H,P,Q) is a cascade of three systems applied to input signal X:
(1) Upsampling by P (zero insertion). P defaults to 1 if not
specified.
(2) FIR filtering with the filter specified by the impulse response
given in H.
(3) Downsampling by Q (throwing away samples). Q defaults to 1 if not
specified.
upfirdn uses an efficient polyphase implementation.
Usually X and H are vectors, and the output is a (signal) vector.
upfirdn permits matrix arguments under the following rules:
If X is a matrix and H is a vector, each column of X is filtered through H.
If X is a vector and H is a matrix, each column of H is used to filter X.
If X and H are both matrices with the same number of columns, then the i-th
column of H is used to filter the i-th column of X.
Specifically, these rules are carried out as follows. Note that the length
of the output is Ly = ceil( ((Lx-1)*P + Lh)/Q ) where Lx = length(X) and
Lh = length(H).
Input Signal X Input Filter H Output Signal Y Notes
-----------------------------------------------------------------
1) length Lx vector length Lh vector length Ly vector Usual case.
2) Lx-by-Nx matrix length Lh vector Ly-by-Nx matrix Each column of X
is filtered by H.
3) length Lx vector Lh-by-Nh matrix Ly-by-Nh matrix Each column of H is
used to filter X.
4) Lx-by-N matrix Lh-by-N matrix Ly-by-N matrix i-th column of H is
used to filter i-th
column of X.
For an easy-to-use alternative to upfirdn, which does not require you to
supply a filter or compensate for the signal delay introduced by filtering,
use RESAMPLE.
EXAMPLE: Sample-rate conversion by a factor of 147/160. It is used to
% downconvert from 48kHz to 44.1kHz.
L = 147; M = 160; % Interpolation/decimation factors.
Lp = 24; % Filter length of each phase
N = Lp*L-1; % Filter Order
h = fir1(N,1/M,kaiser(N+1,7.8562));
h = L*h; % Passband gain = L
Fs = 48e3; % Original sampling frequency: 48kHz
n = 0:10239; % 10240 samples, 0.213 seconds long
x = sin(2*pi*1e3/Fs*n); % Original signal, sinusoid at 1kHz
y = upfirdn(x,h,L,M); % 9430 samples, still 0.213 seconds
% Overlay original (48kHz) with resampled signal (44.1kHz) in red.
stem(n(1:49)/Fs,x(1:49)); hold on
stem(n(1:45)/(Fs*L/M),y(12:56),'r','filled');
xlabel('Time (sec)');ylabel('Signal value');
See also resample, interp, decimate, fir1, intfilt.
Reference page in Help browser
doc upfirdn
On Fri, Dec 9, 2016 at 12:50 AM, Ahmad, Jumana <jumana.ahmad at kcl.ac.uk<mailto:jumana.ahmad at kcl.ac.uk>> wrote:
Dear All,
The EEGlab function let me down sample from 1000 to 256, but as 256 isn't a multiple into 1000 I wonder how it's possible. HP filtered at 1.5. This is what I did for the purpose of ICA (was trying to equate sampling rates of data sets collected across sites) and will apply the weights to the 0.1Hz HP filtered and 1000Hz sampling rate data. Thank you.
Best wishes,
Jumana
_______________________________________________
Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu<mailto:eeglablist-unsubscribe at sccn.ucsd.edu>
For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu<mailto:eeglablist-request at sccn.ucsd.edu>
--
Makoto Miyakoshi
Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20161210/cd4522c3/attachment.html>
More information about the eeglablist
mailing list