The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Question about FFT

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
hcwalker Posted - 01/05/2007 : 09:31:10 AM
Origin Version (Select Help-->About Origin): 7.5
Operating System: Windows XP

I am new to doing FFTs in general, and things seem to be working fairly well so far. My data is acquired over 3-4 minutes at ~12,000 to 48,000 hertz, so I basically have 2 very long columns of X and Y data. My question is what is the most convenient way to do serial FFTs over an epoch that I can vary depending on the data.

Thanks for any suggestions,

Harrison
15   L A T E S T    R E P L I E S    (Newest First)
hcwalker Posted - 01/28/2008 : 2:45:20 PM
I have a few more questions about FFT, and I thought I would append them to this thread.

(1) I am using originpro 8, and the sample code for FFT from the origin c help file is not running when I place it verbatim into the code builder. There error that it returns is "Error, cannot convert argument in function call," and it references the this line of code:

//test 1d fft function for arbitrary source matrix.//
int Err = FFT(mRe, mResult);

This error does not occur with identical code in version 7.5, and the output is appropriate. Do you have any suggestions for this, or am I missing something obvious here?

(2) I have data acquired at 48 kHz for minutes at a time. I am trying to do FFT on this data and see a change before and after a stimulation period. STFT analysis is what I would like to use, however, the problem I had with it is that the frequency ranges of interest for this analysis are < 200 Hz, and the resolution of that frequency range is very poor, because the FFT calculation in the STFT goes up to 24000 Hz. So the result in the output window is very "blocky" or pixelated over such a small frequency range. In my last iteration of this type of analysis, I got around this by doing FFT on consecutive 10 second intervals of the data, because although conventional FFT will do calculations up to 24000 Hz as well, it has excellent resolution throughout the frequency spectrum. So I just plotted peaks and half-widths of the bands of interest over 10 second epochs, rather than making a 3D spectogram with STFT. Unless there is a way to tailor STFT for my needs, I think I will write a program to sample my data over the 10 second intervals as above, but I'm having some issues with the FFT function from origin C as stated in (1).

I'd appreciate any tips on coding this analysis, and I'd appreciate general comments on the analysis itself. I am not an expert on FFT.

Thanks!

Harrison


Edited by - hcwalker on 01/28/2008 2:52:34 PM
klunz Posted - 06/27/2007 : 04:32:44 AM
Hi Mike,

thank you very much for your help, that did it.

Greetings
Tobi

Edited by - klunz on 06/27/2007 04:33:21 AM
Mike Buess Posted - 06/21/2007 : 09:39:46 AM
Hi Tobi,

The difference arises from the FFT settings you used from the menu. If you uncheck the Normalize Amplitude and Shift Results output options the two results will agree. The Origin reference (Help> Origin) has a detailed discussion of the FFT tool and what those settings do.

Mike Buess
Origin WebRing Member
klunz Posted - 06/21/2007 : 04:12:40 AM
Origin Version: 7.5G SP6
Operating System: Windows XP

Hi there.
I have just about the same objective as Harrsion, 2 long columns of Data that need to be FFTd and I want to automize that.
Currently I am trying to understand the FFT function in OriginC and searching for it I stumbeld upon this thread.

Right now my problem is:
I tried to use the programm mentioned below, "fft_using_nag", but I am getting different results in comparisson to "the menu FFT".

quote:

Hi Harrison

Take a look at this link. Hope it helps.

Zachary
OriginLab Technical Services.



My input was:

1 24
2 45
3 23
4 76
5 43
6 1
7 87
8 8

Using "fft_using_nag" on column B I get:

Freq Real Imag Ampli Phase Power
0 307 0 307 0 11781,125
0,125 -35,97056 -15,19596 39,04867 -2,74188 190,59982
0,25 -43 38 57,38467 2,41784 411,625
0,375 -2,02944 -143,19596 143,21034 -1,58497 2563,65018
0,5 47 0 47 0 276,125
0,625 -2,02944 143,19596 143,21034 1,58497 2563,65018
0,75 -43 -38 57,38467 -2,41784 411,625
0,875 -35,97056 15,19596 39,04867 2,74188 190,59982

and using "the menu" I get:

Freq Real Imag r Phi Power
-0,5 11,75 0 11,75 0 17,25781
-0,375 -0,50736 35,79899 35,80258 90,81197 160,22814
-0,25 -10,75 -9,5 14,34617 221,46771 25,72656
-0,125 -8,99264 3,79899 9,76217 157,09811 11,91249
0 76,75 0 76,75 0 736,32031
0,125 -8,99264 -3,79899 9,76217 -157,09811 11,91249
0,25 -10,75 9,5 14,34617 -221,46771 25,72656
0,375 -0,50736 -35,79899 35,80258 -90,81197 160,22814
0,5 11,75 0 11,75 0 17,25781

I am fairly new to Origin and maybe I just understood something completly wrong but my understanding was that I should get basically the same results using the 2 different methods.

Thanks you very much in advance, I hope my question isnt to dumb ;)
And sorry for kind of taking over this thread, I didnt want to start a new one because the problem discussed here already seemed kind of related to mine.

Greetings
Tobi

Edit: sorry for the bad tabel-formatting, do I really need to take screenshots?

Edited by - klunz on 06/21/2007 05:05:18 AM
hcwalker Posted - 01/19/2007 : 3:08:59 PM
Hi again,

The low threshold FFT filter gets rid of the high frequency noise well, eliminating those frequencies almost entirely from the regular FFT and ST FFT operations. Now that has allowed me to see that the real problem is that my dT is so much smaller than the ST FFT sample that was provided that I am not getting resolution in the frequencies of interest.

This is derived from the ST FFT C code which defines the frequency range based upon iSize (the number of rows in the datasheet) and tSpacing (derived fromt the sampling interval). That makes my y axis on the ST FFT output matrix range between 0 and ~6000 Hz because the data I am currently analyzing was sampled at ~12000 Hz. I get one color block on the matrix for the entire frequency range between 0-10 Hz, 11-20 Hz, etc... So what I really need is resolution on par with the resolution obtained from the sample dataset provided with ST FFT. So in other words, I need the FFT to be the same number of iterations, but restricted more densely between say 0 and 500 Hz to best resolve my frequencies of interest.

I am working on this now within the program, just wanted to let you know what I'm doing to see if you have further suggestions.

Thanks again for any help.

Harrison

Edited by - hcwalker on 01/19/2007 3:19:39 PM
Mike Buess Posted - 01/18/2007 : 4:05:17 PM
FFT Filter is available only for graphs. That's why the first step was to plot your data. :)

...ComputeFFT() is in NAG STFT.c which is attached to the NAG STFT project. Open CodeBuilder and expand the Workspace's Project branch. Since it's not a built-in function the only documentation is probably in the project/file.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/18/2007 4:22:28 PM

Edited by - Mike Buess on 01/18/2007 4:29:29 PM
hcwalker Posted - 01/18/2007 : 3:18:18 PM
Hi Mike,

The FFT filter item is not present within the analysis drop-down window. My only similar choice is "FFT..." which accesses the FFT dialogue (which I have used successfully). I am aware of a low threshold FFT filter in the NAG library. Is that what you were referring to? Or is my software out of date. I attempted to install SR6 earlier, but I am not convinced that worked properly.

Oh, never mind. I have to have clicked on a graph rather than a Y column from a datasheet to do this. Duh.

I am not able to find the ComputeFFT() function in prgramming help files.

Thanks again,

Harrison

Edited by - hcwalker on 01/18/2007 3:58:33 PM

Edited by - hcwalker on 01/18/2007 4:09:23 PM
Mike Buess Posted - 01/18/2007 : 09:03:51 AM
Hi Harrison,

I would try the FFT low pass filter...

1. Create a standard 2D plot of your raw data.
2. Run Analysis > FFT Filter > Low Pass.
3. Set cuttoff frequency (Fc) and OK.
4. Perform the STFT operation on the resulting data which is in wks FFTfilter1.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/18/2007 4:03:59 PM
hcwalker Posted - 01/17/2007 : 11:54:40 PM
So I did the ST FFT NAG and it worked well except that it has done the transform on frequencies between 0 and 4000 hz. I am only interested in frequencies between 0 and 300 or so hz. Can anyone suggest a way for me to filter out all of this high frequencies within this program?

Many thanks,

Harrison
Deanna Posted - 01/08/2007 : 04:32:01 AM
Hi Harrison.

Although the STFT.opj and the Origin C program call two different NAG functions, they are subject to same limitations. According to the NAG documentation, the limitations include:
1) The size of the input signal must be a product of prime numbers;
2) The total number of these prime factors must not exceed 20;
3) Any prime factor must not be greater than 19.
(Please see the pages about nag_fft_real() and nag_fft_complex() in Origin Programming help.)

It seems that the size of your data does not meet the above requirements. I think you can try to truncate your data according to Mike's suggestion.

Deanna
OriginLab Technical Services
hcwalker Posted - 01/07/2007 : 11:54:00 PM
Hi, and thanks to both of you for the helpful suggestions.

I am able to run the NAG program with the data which is included in the file. If I paste my data and truncate to 1000 rows of X and Y data (the same length as the sample data provided in the file), it works. The problem is that my dataset has millions of data points.

Zachary, I compiled the program you suggested successfully. It did not make any immediate difference. Is the NAG program accessing that program or do I need to make a change in the NAG program so that it will access the altered FFT you suggested?

If I can't get that to work I will truncate to the power of 2 as suggested by Mike.

Harrison
zachary_origin Posted - 01/05/2007 : 9:37:07 PM
Hi Harrison

Take a look at this link. Hope it helps.

Zachary
OriginLab Technical Services.
Mike Buess Posted - 01/05/2007 : 8:56:05 PM
What happens when you try the data that comes with the project? If that gives you the same (or any) error messages I suggest you update to 7.5 SR6 available here.

...I deleted a few rows from the original data and got same error message. Turns out the message is literal in that the data size must be a product of primes. Easiest way to achieve that is to truncate to next lower power of two or pad with zeros to next higher power of two. (1 x prime doesn't count.)

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/05/2007 9:33:54 PM
hcwalker Posted - 01/05/2007 : 5:38:29 PM
Hi Mike,

Thanks very much for your guidance; that project appears to be very useful for my analysis. I have imported the X and Y columns from my dataset into the project, but whenever I try to press the "compute" button I receive the message "Dataset size not product of primes, truncate and try again."

This somehow arises from these lines of code:

// Call function to compute FFT
int iRet = ComputeFFT(iSize, vFFTReal, vFFTImag, vSig);

// If Err = 137,then dataset length is not a product of primes
if(iRet == 137)
return 2;

I have tried to truncate various lengths off the end of my dataset with little luck so far. Any suggestions?

Thanks again,

Harrison
Mike Buess Posted - 01/05/2007 : 10:53:47 AM
The NAG STFT.opj project in your Samples\Programming folder might be useful.

Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000