Hi!<div><br></div><div>I don't understand why to use a IIR filter. They always cause some (phase) distorsion.</div><div>I suggest you to use a FIR filter. If you use Matlab, just type "fdatool" (Filter design & analysis tool). Than select: High pass and FIR (Equiripple). Set the Srate to 512 and the Fstop to 0.01. You did not specfied which frequencies you do not want to distort. I guess you could set Fpass to 0.5 Hz (all frequencies higher than 0.5 Hz won't be modified). Then set Dstop to 0.0005 and Dpass to 0.01.</div>
<div>Now you can click on Design Filter. When done...click on File -> Export (It export the filter on Matlab workspace). Set Numerator to "HP_Filter" (it s just a name for the filter).</div><div><br></div><div>
Now you are ready to filter your data: </div><div><br></div><div>    HP_Delay = round( mean(grpdelay(HP_filter)) ); % a FIR filter introduces a delay in the signal. you need to compensate it.</div><div><br></div><div><div>
    HP_Data = filter( HP_filter, 1, your_data ) ;  % Filter the data</div><div>    HP_Data  = circshift( 
HP_Data , [1 -HP_Delay] ); %compensate the delay introduced by the HP filter</div><div><br></div><div>I hope it helps you.</div><div><br></div><div>Ciao!</div><div><br></div><div>Davide.</div><br><div class="gmail_quote">
On Mon, Aug 6, 2012 at 6:38 PM, Andreas Widmann <span dir="ltr"><<a href="mailto:widmann@uni-leipzig.de" target="_blank">widmann@uni-leipzig.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Sophie,<br>
<br>
a 0.01 Hz highpass filter with 512 Hz sampling frequency is very extreme. My personal rule of thumb is that the srate / cutoff ratio for IIR highpass filtering should not be much higher than ~1000 (acknowledgement to BM). The problem is increased by the EEGLAB default estimation of required filter order by a very narrow transition band (defined as cutoff/3 in your case; the help text in pop_iirfilt is wrong!). The extreme filter cutoff with narrow transition band requires a high filter order (here 6), but the resulting 6th order filter is instable.<br>

<br>
I would suggest first downsampling the data to an as low as possible sampling frequency (after lowpass filtering the data to 1/4-1/5 of new sampling frequency!).<br>
<br>
Then, I would suggest filtering the data with a butterworth filter at 0.1 Hz cutoff frequency. Roll-off is a function of filter order (approx. order times -6dB/octave).<br>
E.g.:<br>
>> [b, a] = butter(4, 0.1 / (srate / 2), 'high')<br>
for a forth order filter.<br>
<br>
Check frequency response with<br>
>> freqz(b, a, 2^14, srate)<br>
At 256 Hertz this gives a reasonable frequency response and very good DC attenuation. Downsampling your data to 128 Hz you can use the same filter for a 0.05 Hz highpass.<br>
<br>
Check filter stability with<br>
>> zplane(b, a)<br>
All poles should be inside the unit circle. If you test the 6th order butterworth filter you will see that also this filter is instable.<br>
<br>
Causal filtering can be done easily on the command line using the MATLAB built in filter function. Take care not to filter across boundaries/DC offsets! Filter each segment separately.<br>
<br>
Hope this helps, best,<br>
Andreas<br>
<br>
Am 06.08.2012 um 17:44 schrieb Sophie Herbst <<a href="mailto:ksherbst@googlemail.com">ksherbst@googlemail.com</a>>:<br>
<br>
> Hi EEGlablist,<br>
><br>
> I am trying to apply a causal bandpass filter with a very low cutoff (0.01Hz) to my EEG data (continuos data with ~2,700,000 points, srate = 512Hz)<br>
> by using iirfilt.m:<br>
><br>
> iirfilt(EEG.data, EEG.srate, 0.01, 40, 0, 0, 0, [], [], 'on')<br>
><br>
> I seem to run into similar problems as described in EEGLAB Bug #1011: the default values for transition bandwidth and passband/ stopband ripple do not seem to work as<br>
> the filter runs but leaves a matrix of NaNs.<br>
><br>
> I have been playing around with values for the transition bandwidth etc, but I could not get a satisfying frequency response.<br>
> Any idea why this is and which filter would be better to use?<br>
><br>
> Thanks a lot,<br>
> Sophie<br>
<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">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">eeglablist-request@sccn.ucsd.edu</a><br>
</blockquote></div><br></div>