<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">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. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><a href="http://melodi.ee.washington.edu/courses/ee518/notes/lec9.pdf">http://melodi.ee.washington.edu/courses/ee518/notes/lec9.pdf</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">So, my two cents are the filtering process should be done before down-sampling. <o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">-Iman<o:p></o:p></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">-------------------------------------------------------------<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Iman M.Rezazadeh, Ph.D.<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">HRL Laboratories, Malibu , CA | UCLA Semel Intitute, Los Angeles, CA | Center for Mind and Brain, UC DAVIS, CA<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> eeglablist-bounces@sccn.ucsd.edu [mailto:eeglablist-bounces@sccn.ucsd.edu]
<b>On Behalf Of </b>Makoto Miyakoshi<br>
<b>Sent:</b> Friday, December 9, 2016 8:43 PM<br>
<b>To:</b> Ahmad, Jumana <jumana.ahmad@kcl.ac.uk><br>
<b>Cc:</b> eeglablist@sccn.ucsd.edu<br>
<b>Subject:</b> Re: [Eeglablist] Down sample issue<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Dear Jumana,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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().<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Makoto<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">>> help upfirdn<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> upfirdn Upsample, apply a specified FIR filter, and downsample a signal.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> upfirdn(X,H,P,Q) is a cascade of three systems applied to input signal X:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> (1) Upsampling by P (zero insertion). P defaults to 1 if not <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> specified.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> (2) FIR filtering with the filter specified by the impulse response <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> given in H.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> (3) Downsampling by Q (throwing away samples). Q defaults to 1 if not <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> specified.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> upfirdn uses an efficient polyphase implementation.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> Usually X and H are vectors, and the output is a (signal) vector. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> upfirdn permits matrix arguments under the following rules:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> If X is a matrix and H is a vector, each column of X is filtered through H.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> If X is a vector and H is a matrix, each column of H is used to filter X.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> If X and H are both matrices with the same number of columns, then the i-th<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> column of H is used to filter the i-th column of X.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> Specifically, these rules are carried out as follows. Note that the length<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> of the output is Ly = ceil( ((Lx-1)*P + Lh)/Q ) where Lx = length(X) and <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> Lh = length(H). <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> Input Signal X Input Filter H Output Signal Y Notes<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> -----------------------------------------------------------------<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 1) length Lx vector length Lh vector length Ly vector Usual case.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 2) Lx-by-Nx matrix length Lh vector Ly-by-Nx matrix Each column of X<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> is filtered by H.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 3) length Lx vector Lh-by-Nh matrix Ly-by-Nh matrix Each column of H is<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> used to filter X.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 4) Lx-by-N matrix Lh-by-N matrix Ly-by-N matrix i-th column of H is<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> used to filter i-th<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> column of X.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> For an easy-to-use alternative to upfirdn, which does not require you to <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> supply a filter or compensate for the signal delay introduced by filtering,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> use RESAMPLE.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> EXAMPLE: Sample-rate conversion by a factor of 147/160. It is used to<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> % downconvert from 48kHz to 44.1kHz.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> L = 147; M = 160; % Interpolation/decimation factors.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> Lp = 24; % Filter length of each phase<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> N = Lp*L-1; % Filter Order<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> h = fir1(N,1/M,kaiser(N+1,7.8562));<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> h = L*h; % Passband gain = L<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> Fs = 48e3; % Original sampling frequency: 48kHz<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> n = 0:10239; % 10240 samples, 0.213 seconds long<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> x = sin(2*pi*1e3/Fs*n); % Original signal, sinusoid at 1kHz<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> y = upfirdn(x,h,L,M); % 9430 samples, still 0.213 seconds<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> % Overlay original (48kHz) with resampled signal (44.1kHz) in red.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> stem(n(1:49)/Fs,x(1:49)); hold on <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> stem(n(1:45)/(Fs*L/M),y(12:56),'r','filled'); <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> xlabel('Time (sec)');ylabel('Signal value');<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> See also resample, interp, decimate, fir1, intfilt.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> Reference page in Help browser<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> doc upfirdn<o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Fri, Dec 9, 2016 at 12:50 AM, Ahmad, Jumana <<a href="mailto:jumana.ahmad@kcl.ac.uk" target="_blank">jumana.ahmad@kcl.ac.uk</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Dear All,<br>
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.<br>
Best wishes,<br>
Jumana<br>
_______________________________________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" target="_blank">
http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu" target="_blank">
eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu" target="_blank">
eeglablist-request@sccn.ucsd.edu</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">Makoto Miyakoshi<br>
Swartz Center for Computational Neuroscience<br>
Institute for Neural Computation, University of California San Diego<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>