40 Replies to “A Basic Fourier Transform Calculator in Excel – video preview”
When I say variable periods I mean create a mega series (2000 points) with a certain period between the 20 elementary series, then create more of these mega (fake) series with different periods. All these series are fairly close to each others. It’s more an optimization process using both visual clues and calculated clues.
My model tries to be a very basic implementation of a classic algorithm.
Try the following:
1. Plot the series and try to visually clean the ends (series of zeros?)
2. plot the about 100 points (less after cleanup) say, 20 times with variable periods and visually try to adjust the spacing to create a large series with a dominant fundamental freq.
3. Do the fourier calculations on the compound series and try to choose the one with the cleanest spectrum (largest power in the fundamental compared to the remaining spectrum). Keep finely adjusting the time distance between these 20 series until you reach a sweet spot. Use your eyes and common sense too. The tool is blind and should be used sparingly. People love black boxes but they rarely are the best solution. Also work on centering the series.
Keith, “N” points is enough for a given precision. One advice, mirror the data (padd it with the same thing and multiply it by 2). Ultrasound is cheap, why not take more points?
The camera is limited too 102 picture frames in each exposure, so i cannot create any more( i wish i could). Matlab was used to analyze the image and get an average pixel count for each frame. Which i then put into excel and plotted the change in pixel size over time. I have tried using your algorithm, but for example if i put the frequency range from 0 to 2MHz, there is a peak at 1MHz and spectrum is mirrored both sides, if i change it to 1 MHz, there is a peak at 500 Khz. Makes me think there is something wrong.
Here is the raw data for a single video: 102 points, dt= 2us. startings at 0s
It appears from the raw data, that when the ultrasound is on and the bubble is at it minimum size, corresponds to pixel data at its minimum, but the bubble is oscillating to the frequency of the ultrasound, so the time difference between minimum is approximately every 16us(manually calculated from the graph), which refers to 62.5 KHz, so the bubble is oscillating at this frequency?
i imagined the FT would highlight this frequency?
Am i mistaken? Sorry for adding the detail, but i think this FT calculator is very useful, if i can get it working properly for this experiment.
I have 102 data points relating to the oscillation of a bubble inside a water medium when subject to ultrasound. The bubble was recorded using a high speed camera @ 500,000 FPS ( 2us between frames) with 102 frames and then a dark pixel algorithm detected the size and oscilllations of the bubble over 202 us time period. Each data point relates to a single camera frame, where it counts the number of pixels in the picture( The bubble appears white with the background black) If you plot the pixels over time you get an idea of the bubble oscillation, but i wanted to work out the frequency. Do you think 102 points is enough, i have used your software but it seems to be symetrical about the middle point, which makes me doubt it. I am not sure tho, what do you reckon?
Paul, this is a digital approximation but not an FFT. You need to check and apply the formula for the FFT. Basically this particular model is not good for your application. How many points of data you have?
Hi George,
I am new to this technique so it is very difficult to understand, but i have to do this because it is related to my research work i have two component to do this one is number of laminae and second one is thickness of laminae. So fist i have to do harmonic analysis than transform into fft. So pls tell your valuable guidance how i will run my data for harmonic analysis then transform to fft.
It will be great help for my research.
thankyou.
One more observation,the codomain of arcsin() would not work for (0,pi) anyway, I believe injectivity of sin() is violated. For instance if sin(x)=0.5 there are 2 different values of x in the interval (0,pi) satisfying that, therefore you cannot simply define the codomain or arcsin() as 0,pi. It has to be (-pi/2,pi/2), or (pi/2, 3pi/2), etc. So I was wrong, it is not purely a convention issue.
Grace, I will just give you some hints and I apologize if my language is not proper (might not in line with the US terminology). Go check in the middle school books about function properties. The way we learned them was: injectivity, surjectivity and bijectivity. As I remember correctly from 7th grade a function can have an inverse only on a domain on which it is bijective. By definition (and you need to check yourself in the books), the codomain of the arcsin(x) or asin(x) (same thing) is defined as (-pi/2,+pi/2) and not (0,pi). It’s just the definition. You need to go back and read about this. I am rusty myself and our system of education back in the day, in my old country was mainly based on the French/German style. And I cannot stress enough, the creators of these inverse trig, function decided as codomains for symmetrical intervals centered in origin. Of course if you like you can change the definition (by adding a pi/2) but then it will not be in line with international definitions.
George, awesome spreadsheet, your youtube video was really helpful. Thank you!
I have actually developed my own spreadsheet which is quite similar to yours, but I am having trouble calculating the phase shift correctly. When graphed against frequency, my shift values all lie between 1.57r and -1.57r (obviously pi/2 and -pi/2). Initially I thought my equations were wrong but I notice on youtube your phase values lie in this range as well.
When I use a simple sine wave, with no shift (sin(2pift)), as my input data, my fourier transform returns the phase shift (using atan(imaginary/real)) of approximately 1.57 (approaches the maximum). I get the same answer when using a shift of pi and a shift of 2pi in my input data.
Would you mind explaining if you could why there is negative shift instead of all positive beginning from zero, and why the shift only encompasses pi radians, not the full 2pi?
When I say variable periods I mean create a mega series (2000 points) with a certain period between the 20 elementary series, then create more of these mega (fake) series with different periods. All these series are fairly close to each others. It’s more an optimization process using both visual clues and calculated clues.
My model tries to be a very basic implementation of a classic algorithm.
Try the following:
1. Plot the series and try to visually clean the ends (series of zeros?)
2. plot the about 100 points (less after cleanup) say, 20 times with variable periods and visually try to adjust the spacing to create a large series with a dominant fundamental freq.
3. Do the fourier calculations on the compound series and try to choose the one with the cleanest spectrum (largest power in the fundamental compared to the remaining spectrum). Keep finely adjusting the time distance between these 20 series until you reach a sweet spot. Use your eyes and common sense too. The tool is blind and should be used sparingly. People love black boxes but they rarely are the best solution. Also work on centering the series.
Keith, “N” points is enough for a given precision. One advice, mirror the data (padd it with the same thing and multiply it by 2). Ultrasound is cheap, why not take more points?
The camera is limited too 102 picture frames in each exposure, so i cannot create any more( i wish i could). Matlab was used to analyze the image and get an average pixel count for each frame. Which i then put into excel and plotted the change in pixel size over time. I have tried using your algorithm, but for example if i put the frequency range from 0 to 2MHz, there is a peak at 1MHz and spectrum is mirrored both sides, if i change it to 1 MHz, there is a peak at 500 Khz. Makes me think there is something wrong.
Here is the raw data for a single video: 102 points, dt= 2us. startings at 0s
The zeros represent no ultrasound on( Hence no cavitation bubble)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 15 12 19 16 26 12 12 23 31 30 34 28 28 25 0 25 31 28 28 28 25 25 16 28 29 35 29 39 30 36 0 41 33 46 30 44 28 36 0 45 43 48 43 47 39 46 23 37 0 29 0 0 0 0 0 0 0 0
Does all the zeros affect the algorithm?
It appears from the raw data, that when the ultrasound is on and the bubble is at it minimum size, corresponds to pixel data at its minimum, but the bubble is oscillating to the frequency of the ultrasound, so the time difference between minimum is approximately every 16us(manually calculated from the graph), which refers to 62.5 KHz, so the bubble is oscillating at this frequency?
i imagined the FT would highlight this frequency?
Am i mistaken? Sorry for adding the detail, but i think this FT calculator is very useful, if i can get it working properly for this experiment.
Dear George,
I have 102 data points relating to the oscillation of a bubble inside a water medium when subject to ultrasound. The bubble was recorded using a high speed camera @ 500,000 FPS ( 2us between frames) with 102 frames and then a dark pixel algorithm detected the size and oscilllations of the bubble over 202 us time period. Each data point relates to a single camera frame, where it counts the number of pixels in the picture( The bubble appears white with the background black) If you plot the pixels over time you get an idea of the bubble oscillation, but i wanted to work out the frequency. Do you think 102 points is enough, i have used your software but it seems to be symetrical about the middle point, which makes me doubt it. I am not sure tho, what do you reckon?
Hi George,
This technique i so useful but need your guidance.
Paul, this is a digital approximation but not an FFT. You need to check and apply the formula for the FFT. Basically this particular model is not good for your application. How many points of data you have?
I have 400 points
Hi George,
I am new to this technique so it is very difficult to understand, but i have to do this because it is related to my research work i have two component to do this one is number of laminae and second one is thickness of laminae. So fist i have to do harmonic analysis than transform into fft. So pls tell your valuable guidance how i will run my data for harmonic analysis then transform to fft.
It will be great help for my research.
thankyou.
One more observation,the codomain of arcsin() would not work for (0,pi) anyway, I believe injectivity of sin() is violated. For instance if sin(x)=0.5 there are 2 different values of x in the interval (0,pi) satisfying that, therefore you cannot simply define the codomain or arcsin() as 0,pi. It has to be (-pi/2,pi/2), or (pi/2, 3pi/2), etc. So I was wrong, it is not purely a convention issue.
That helps a lot, thank you!
Grace, I will just give you some hints and I apologize if my language is not proper (might not in line with the US terminology). Go check in the middle school books about function properties. The way we learned them was: injectivity, surjectivity and bijectivity. As I remember correctly from 7th grade a function can have an inverse only on a domain on which it is bijective. By definition (and you need to check yourself in the books), the codomain of the arcsin(x) or asin(x) (same thing) is defined as (-pi/2,+pi/2) and not (0,pi). It’s just the definition. You need to go back and read about this. I am rusty myself and our system of education back in the day, in my old country was mainly based on the French/German style. And I cannot stress enough, the creators of these inverse trig, function decided as codomains for symmetrical intervals centered in origin. Of course if you like you can change the definition (by adding a pi/2) but then it will not be in line with international definitions.
George, awesome spreadsheet, your youtube video was really helpful. Thank you!
I have actually developed my own spreadsheet which is quite similar to yours, but I am having trouble calculating the phase shift correctly. When graphed against frequency, my shift values all lie between 1.57r and -1.57r (obviously pi/2 and -pi/2). Initially I thought my equations were wrong but I notice on youtube your phase values lie in this range as well.
When I use a simple sine wave, with no shift (sin(2pift)), as my input data, my fourier transform returns the phase shift (using atan(imaginary/real)) of approximately 1.57 (approaches the maximum). I get the same answer when using a shift of pi and a shift of 2pi in my input data.
Would you mind explaining if you could why there is negative shift instead of all positive beginning from zero, and why the shift only encompasses pi radians, not the full 2pi?
Any help would be much appreciated! Thanks!