IUBio Biosequences .. Software .. Molbio soft .. Network News .. FTP

Digital Low Pass?

Jan R. de Weille deweille at bigfoot.com
Tue Apr 27 15:28:41 EST 1999



Manuel Gebauer wrote:

> I would like to filter some voltage traces through a digital low
> pass. The filter should cut off frequencies of more than about
> 2 Hz. Hardware filtering is not possible because these data are
> allready recorded and digitized.
>
> Are there any software applications? Or do you know any algorithms
> wich may be implemented in a small program?
>
> --
> Manuel Gebauer

Hi Manuel,
The following C code is a 12db/octave phaseless recursive filter
that I use in my electrophysiology analysis program serf see
http://www.ipmc.cnrs.fr/~deweille/serf.html

void RCFilter(float *inp, float *outp)  // RC filter
{  short i;
 float a,b,y,mean;                // pi is half the circumference of a
unit circle
 float *in=inp,*out=outp;    // input and output arrays my be identical
 short np=short(npoints);    // array dimension
   np>>=1;                        // cutoff is in Hz, timebase is sample
interval in seconds
   if (np>200) np=200;
   for (i=0,mean=0;i<np;i++) mean+=in[i];
   for (i=npoints-np-1;i<npoints;i++) mean+=in[i];
   mean/=float(npoints);
   vadds(inp,-mean,npoints);
   np=short(npoints);
 y=in[0];
   if (npoints1>0)
 {  a=2-cos((pi+pi)*cutoff*(float)timebase1*1.0e-6);
    if (!Zero(a-1))
    { a=a-sqrt(a*a-1);
     b=1-a;
         y*=b;
       for (i=0;i<npoints1;i++) out[i]=y=b*in[i]+a*y;}
    in=&inp[npoints1];
      out=&outp[npoints1];
    np-=npoints1;}
   a=2-cos((pi+pi)*cutoff*(float)timebase*1.0e-6);
   if (!Zero(a-1))
   { a=a-sqrt(a*a-1);
    b=1-a;
      if (npoints1==0) y*=b;
    for (i=0;i<np;i++) out[i]=y=b*in[i]+a*y;
      y*=b;
      for (i=np-1;i>=0;i--) out[i]=y=b*out[i]+a*y;}
   if (npoints1>0)
   {  out=outp;
    a=2-cos((pi+pi)*cutoff*(float)timebase1*1.0e-6);
    if (!Zero(a-1))
    { a=a-sqrt(a*a-1);
     b=1-a;
       for (i=npoints1-1;i>=0;i--) out[i]=y=b*out[i]+a*y;}
   }
 vadds(outp,mean,npoints);}

I hope this is what you are looking for, Jan de Weille




More information about the Neur-sci mailing list

Send comments to us at biosci-help [At] net.bio.net