Rephrased FFT Question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Rephrased FFT Question

Rebecca Keller
Dear List,

Let me rephrase: what I am trying to do is locate oscillations of a certain
frequency onto a 2D visual field, i.e., convert the third
dimension (time) of a time-lapse image series into frequency space. Then I
could scan through frequency space (the new third dimension) to find groups
of pixels with similar oscillation frequencies.

So I guess what would need to be done is a 1D FFT for each pixel. Is there
any way easily to do this with the current imagej tools?

JPK

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

ERIC
Hi Rebecca,
You may have a look to Claire Smith's CiliaFA macro. It reveals  
frequencies of intensity variation in different zone of a brightfield  
image.
We are using it for high frequency Cilia beating.
here is a link to the paper and macro :
http://www.ciliajournal.com/content/1/1/14


Rebecca Keller <[hidden email]> a écrit :

> Dear List,
>
> Let me rephrase: what I am trying to do is locate oscillations of a certain
> frequency onto a 2D visual field, i.e., convert the third
> dimension (time) of a time-lapse image series into frequency space. Then I
> could scan through frequency space (the new third dimension) to find groups
> of pixels with similar oscillation frequencies.
>
> So I guess what would need to be done is a 1D FFT for each pixel. Is there
> any way easily to do this with the current imagej tools?
>
> JPK
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

Rebecca Keller
Thanks very much for this reference, but actually it is a bit cumbersome to
come in and out of imagej, since this "plugin" requires ms excel for the
fft'ing.

Seems like it should be possible to get the current fft algorithm to do a
1D FFT on each pixel over time, then re-output the timelapse stack as a 2D
image in frequency domain. Then it would be neat, for example, to make a 2D
image depth-coded by frequency. I, however, just need to get the pixels
which all have the same frequencies, which should be easy enough to do
using the 1D FFT pixelwise which I suggested.

JPK






On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
[hidden email]> wrote:

> Hi Rebecca,
> You may have a look to Claire Smith's CiliaFA macro. It reveals
> frequencies of intensity variation in different zone of a brightfield image.
> We are using it for high frequency Cilia beating.
> here is a link to the paper and macro :
> http://www.ciliajournal.com/content/1/1/14
>
>
> Rebecca Keller <[hidden email]> a écrit :
>
>  Dear List,
>>
>> Let me rephrase: what I am trying to do is locate oscillations of a
>> certain
>> frequency onto a 2D visual field, i.e., convert the third
>> dimension (time) of a time-lapse image series into frequency space. Then I
>> could scan through frequency space (the new third dimension) to find
>> groups
>> of pixels with similar oscillation frequencies.
>>
>> So I guess what would need to be done is a 1D FFT for each pixel. Is there
>> any way easily to do this with the current imagej tools?
>>
>> JPK
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

Herbie-3
Rebecca,

if you manage to extract 1D-"images" from your time series of images,
i.e. in fact pixel sequences as 1D-images, then you may use the
FFTJ-PlugIn to perform 1D-FFTs of each of these series.

<http://rsb.info.nih.gov/ij/plugins/fftj.html>

You may use a macro to extract the n^2 1D-images (assuming that your
images are of size n x n). To make use of the FFT speed advantage, your
stack must consist of m images (time slices), where m is a power of two.

The problem with FFTJ is, that it isn't perfectly macro-recordable. It
shows a dialog for choosing the result format. In other words, to fully
automatize processing by an IJ-macro, you need to modify the source code
of FFTJ.

HTH

Herbie

::::::::::::::::::::::::::::::::::::::::
On 20.03.14 02:04, Rebecca Keller wrote:

> Thanks very much for this reference, but actually it is a bit
> cumbersome to come in and out of imagej, since this "plugin" requires
> ms excel for the fft'ing.
>
> Seems like it should be possible to get the current fft algorithm to
> do a 1D FFT on each pixel over time, then re-output the timelapse
> stack as a 2D image in frequency domain. Then it would be neat, for
> example, to make a 2D image depth-coded by frequency. I, however,
> just need to get the pixels which all have the same frequencies,
> which should be easy enough to do using the 1D FFT pixelwise which I
> suggested.
>
> JPK
>
> On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
> [hidden email]> wrote:
>
>> Hi Rebecca, You may have a look to Claire Smith's CiliaFA macro. It
>> reveals frequencies of intensity variation in different zone of a
>> brightfield image. We are using it for high frequency Cilia
>> beating. here is a link to the paper and macro :
>> http://www.ciliajournal.com/content/1/1/14
>>
>>
>> Rebecca Keller <[hidden email]> a écrit :
>>
>> Dear List,
>>>
>>> Let me rephrase: what I am trying to do is locate oscillations of
>>> a certain frequency onto a 2D visual field, i.e., convert the
>>> third dimension (time) of a time-lapse image series into
>>> frequency space. Then I could scan through frequency space (the
>>> new third dimension) to find groups of pixels with similar
>>> oscillation frequencies.
>>>
>>> So I guess what would need to be done is a 1D FFT for each pixel.
>>> Is there any way easily to do this with the current imagej
>>> tools?
>>>
>>> JPK
>>>
>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

bnorthan
Hi Rebecca

I am not aware of a simple solution, hopefully someone else knows.   But
someone had a similar problem a while back and it ended up being a fairly
involved discussion.  He had to write some macros.

http://imagej.1557.x6.nabble.com/Automating-Image-Processing-and-Problems-with-FFTJ-td5004660.html

As Herbie mentioned FFTJ is not macro-recordable, I have a slightly
modified version of FFTJ which is recordable and is available here

https://github.com/bnorthan/RogueImageJPlugins/releases

It is really just a copy of the original except with the small changes
talked about in the other thread.

I played around with calling FFTJ on individual points in a time series
using a python macro.  I think the logic is right but keep in mind it is a
hack and pretty slow.   The proper way to do it would be to perform all
calculations in one plugin.   This approach loops through every pixel,
copies a time profile to a temp image then runs the plugin over and over.

https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scriptable/macros/Time_Macro.py




On Thu, Mar 20, 2014 at 6:02 AM, Herbie <[hidden email]> wrote:

> Rebecca,
>
> if you manage to extract 1D-"images" from your time series of images,
> i.e. in fact pixel sequences as 1D-images, then you may use the
> FFTJ-PlugIn to perform 1D-FFTs of each of these series.
>
> <http://rsb.info.nih.gov/ij/plugins/fftj.html>
>
> You may use a macro to extract the n^2 1D-images (assuming that your
> images are of size n x n). To make use of the FFT speed advantage, your
> stack must consist of m images (time slices), where m is a power of two.
>
> The problem with FFTJ is, that it isn't perfectly macro-recordable. It
> shows a dialog for choosing the result format. In other words, to fully
> automatize processing by an IJ-macro, you need to modify the source code of
> FFTJ.
>
> HTH
>
> Herbie
>
> ::::::::::::::::::::::::::::::::::::::::
>
> On 20.03.14 02:04, Rebecca Keller wrote:
>
>> Thanks very much for this reference, but actually it is a bit
>> cumbersome to come in and out of imagej, since this "plugin" requires
>> ms excel for the fft'ing.
>>
>> Seems like it should be possible to get the current fft algorithm to
>> do a 1D FFT on each pixel over time, then re-output the timelapse
>> stack as a 2D image in frequency domain. Then it would be neat, for
>> example, to make a 2D image depth-coded by frequency. I, however,
>> just need to get the pixels which all have the same frequencies,
>> which should be easy enough to do using the 1D FFT pixelwise which I
>> suggested.
>>
>> JPK
>>
>> On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
>> [hidden email]> wrote:
>>
>>  Hi Rebecca, You may have a look to Claire Smith's CiliaFA macro. It
>>> reveals frequencies of intensity variation in different zone of a
>>> brightfield image. We are using it for high frequency Cilia
>>> beating. here is a link to the paper and macro :
>>> http://www.ciliajournal.com/content/1/1/14
>>>
>>>
>>> Rebecca Keller <[hidden email]> a écrit :
>>>
>>> Dear List,
>>>
>>>>
>>>> Let me rephrase: what I am trying to do is locate oscillations of
>>>> a certain frequency onto a 2D visual field, i.e., convert the
>>>> third dimension (time) of a time-lapse image series into
>>>> frequency space. Then I could scan through frequency space (the
>>>> new third dimension) to find groups of pixels with similar
>>>> oscillation frequencies.
>>>>
>>>> So I guess what would need to be done is a 1D FFT for each pixel.
>>>> Is there any way easily to do this with the current imagej
>>>> tools?
>>>>
>>>> JPK
>>>>
>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>>
>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>>
>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

Rebecca Keller
Yes, this macro is exactly the right thing, but it is really slow even when
I make the stack 2^n (4096) images and bin it 4 x 4 x 2. (128 x 128 x 2048
total voxels.) I would think it could be much faster if implemented right,
in java perhaps? I would guess that opening all those windows is
unnecessary, but I am not sure how to *not* open them. But anyway, the
results are pretty cool--any idea what frequency is represented by each
image? Also, it's close to symmetrical over time--what's going on there,
exactly (see attached)? I would think if it were symmetrical it would be
largest in the center as well, but...

Anyway, thanks for this start--I'll see what can be done,

JPK





On Thu, Mar 20, 2014 at 12:01 PM, Brian Northan <[hidden email]> wrote:

> Hi Rebecca
>
> I am not aware of a simple solution, hopefully someone else knows.   But
> someone had a similar problem a while back and it ended up being a fairly
> involved discussion.  He had to write some macros.
>
>
> http://imagej.1557.x6.nabble.com/Automating-Image-Processing-and-Problems-with-FFTJ-td5004660.html
>
> As Herbie mentioned FFTJ is not macro-recordable, I have a slightly
> modified version of FFTJ which is recordable and is available here
>
> https://github.com/bnorthan/RogueImageJPlugins/releases
>
> It is really just a copy of the original except with the small changes
> talked about in the other thread.
>
> I played around with calling FFTJ on individual points in a time series
> using a python macro.  I think the logic is right but keep in mind it is a
> hack and pretty slow.   The proper way to do it would be to perform all
> calculations in one plugin.   This approach loops through every pixel,
> copies a time profile to a temp image then runs the plugin over and over.
>
>
> https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scriptable/macros/Time_Macro.py
>
>
>
>
> On Thu, Mar 20, 2014 at 6:02 AM, Herbie <[hidden email]> wrote:
>
> > Rebecca,
> >
> > if you manage to extract 1D-"images" from your time series of images,
> > i.e. in fact pixel sequences as 1D-images, then you may use the
> > FFTJ-PlugIn to perform 1D-FFTs of each of these series.
> >
> > <http://rsb.info.nih.gov/ij/plugins/fftj.html>
> >
> > You may use a macro to extract the n^2 1D-images (assuming that your
> > images are of size n x n). To make use of the FFT speed advantage, your
> > stack must consist of m images (time slices), where m is a power of two.
> >
> > The problem with FFTJ is, that it isn't perfectly macro-recordable. It
> > shows a dialog for choosing the result format. In other words, to fully
> > automatize processing by an IJ-macro, you need to modify the source code
> of
> > FFTJ.
> >
> > HTH
> >
> > Herbie
> >
> > ::::::::::::::::::::::::::::::::::::::::
> >
> > On 20.03.14 02:04, Rebecca Keller wrote:
> >
> >> Thanks very much for this reference, but actually it is a bit
> >> cumbersome to come in and out of imagej, since this "plugin" requires
> >> ms excel for the fft'ing.
> >>
> >> Seems like it should be possible to get the current fft algorithm to
> >> do a 1D FFT on each pixel over time, then re-output the timelapse
> >> stack as a 2D image in frequency domain. Then it would be neat, for
> >> example, to make a 2D image depth-coded by frequency. I, however,
> >> just need to get the pixels which all have the same frequencies,
> >> which should be easy enough to do using the 1D FFT pixelwise which I
> >> suggested.
> >>
> >> JPK
> >>
> >> On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
> >> [hidden email]> wrote:
> >>
> >>  Hi Rebecca, You may have a look to Claire Smith's CiliaFA macro. It
> >>> reveals frequencies of intensity variation in different zone of a
> >>> brightfield image. We are using it for high frequency Cilia
> >>> beating. here is a link to the paper and macro :
> >>> http://www.ciliajournal.com/content/1/1/14
> >>>
> >>>
> >>> Rebecca Keller <[hidden email]> a écrit :
> >>>
> >>> Dear List,
> >>>
> >>>>
> >>>> Let me rephrase: what I am trying to do is locate oscillations of
> >>>> a certain frequency onto a 2D visual field, i.e., convert the
> >>>> third dimension (time) of a time-lapse image series into
> >>>> frequency space. Then I could scan through frequency space (the
> >>>> new third dimension) to find groups of pixels with similar
> >>>> oscillation frequencies.
> >>>>
> >>>> So I guess what would need to be done is a 1D FFT for each pixel.
> >>>> Is there any way easily to do this with the current imagej
> >>>> tools?
> >>>>
> >>>> JPK
> >>>>
> >>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>>>
> >>>>
> >>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>>
> >>>
> >> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >>
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

whole_stack_FFT.png (26K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

James Ewing
Hi Rebecca - What you’re looking at is a spectrum that runs from 0 to the highest frequency you can sample. The high-frequency points are aliasing in - they are actually negative frequency points (points with a negative phase shift). You can employ various tricks to center the 0 frequency in the middle of the plot (modulation is straightforward - multiply every other image by -1), but the easiest thing to do is to right-shift (or left-shift, same thing) N/2 points, wrapping your high frequency points into the negative points.  Then, instead of IIIlliii…….iiilllIII, you get …..iiillIIIIllii…… I hope this makes sense.

I’m not clear about what the ‘fft’ plugin actually does.  Usually, fast fourier (finite) transforms are performed on complex data.  All your data is real, so you should be able to gain a factor of 2 in speed if the algorithm is correct. See the Wikipedia page on FFTs.

Now, judging by your spectrum, you have vastly oversampled the data.  Unless there is something interesting in the “grass" of your spectrum, you should be able to down-sample to 1024 without a loss of information and a substantial (factor of more than 4) gain in speed.  I’d recommend actually summing every 4 images and then doing the FFT.  That will give you a gain in signal-to-noise.

Now -about the spectrum - your low-frequency points are just related to the average intensity of the pixel you’re sampling. Not very interesting.  You can apodize in the frequency domain and do a back-FFT to see what the higher frequency points are doing, but that’s kind of clunky. Probably the easiest thing to do would be to run a high-pass filter (in the time direction) over your data before the transform.  That might actually reveal more of the behavior of the system you are studying than an FFT-apodize-backFFT. If you run a band-pass filter in the time direction, you can pick out the parts of the image that are moving in a particular frequency band.

I hope this helps.

 - Jim


On Mar 20, 2014, at 9:58 PM, Rebecca Keller <[hidden email]> wrote:

> Yes, this macro is exactly the right thing, but it is really slow even when
> I make the stack 2^n (4096) images and bin it 4 x 4 x 2. (128 x 128 x 2048
> total voxels.) I would think it could be much faster if implemented right,
> in java perhaps? I would guess that opening all those windows is
> unnecessary, but I am not sure how to *not* open them. But anyway, the
> results are pretty cool--any idea what frequency is represented by each
> image? Also, it's close to symmetrical over time--what's going on there,
> exactly (see attached)? I would think if it were symmetrical it would be
> largest in the center as well, but...
>
> Anyway, thanks for this start--I'll see what can be done,
>
> JPK
>
>
>
>
>
> On Thu, Mar 20, 2014 at 12:01 PM, Brian Northan <[hidden email]> wrote:
>
>> Hi Rebecca
>>
>> I am not aware of a simple solution, hopefully someone else knows.   But
>> someone had a similar problem a while back and it ended up being a fairly
>> involved discussion.  He had to write some macros.
>>
>>
>> http://imagej.1557.x6.nabble.com/Automating-Image-Processing-and-Problems-with-FFTJ-td5004660.html
>>
>> As Herbie mentioned FFTJ is not macro-recordable, I have a slightly
>> modified version of FFTJ which is recordable and is available here
>>
>> https://github.com/bnorthan/RogueImageJPlugins/releases
>>
>> It is really just a copy of the original except with the small changes
>> talked about in the other thread.
>>
>> I played around with calling FFTJ on individual points in a time series
>> using a python macro.  I think the logic is right but keep in mind it is a
>> hack and pretty slow.   The proper way to do it would be to perform all
>> calculations in one plugin.   This approach loops through every pixel,
>> copies a time profile to a temp image then runs the plugin over and over.
>>
>>
>> https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scriptable/macros/Time_Macro.py
>>
>>
>>
>>
>> On Thu, Mar 20, 2014 at 6:02 AM, Herbie <[hidden email]> wrote:
>>
>>> Rebecca,
>>>
>>> if you manage to extract 1D-"images" from your time series of images,
>>> i.e. in fact pixel sequences as 1D-images, then you may use the
>>> FFTJ-PlugIn to perform 1D-FFTs of each of these series.
>>>
>>> <http://rsb.info.nih.gov/ij/plugins/fftj.html>
>>>
>>> You may use a macro to extract the n^2 1D-images (assuming that your
>>> images are of size n x n). To make use of the FFT speed advantage, your
>>> stack must consist of m images (time slices), where m is a power of two.
>>>
>>> The problem with FFTJ is, that it isn't perfectly macro-recordable. It
>>> shows a dialog for choosing the result format. In other words, to fully
>>> automatize processing by an IJ-macro, you need to modify the source code
>> of
>>> FFTJ.
>>>
>>> HTH
>>>
>>> Herbie
>>>
>>> ::::::::::::::::::::::::::::::::::::::::
>>>
>>> On 20.03.14 02:04, Rebecca Keller wrote:
>>>
>>>> Thanks very much for this reference, but actually it is a bit
>>>> cumbersome to come in and out of imagej, since this "plugin" requires
>>>> ms excel for the fft'ing.
>>>>
>>>> Seems like it should be possible to get the current fft algorithm to
>>>> do a 1D FFT on each pixel over time, then re-output the timelapse
>>>> stack as a 2D image in frequency domain. Then it would be neat, for
>>>> example, to make a 2D image depth-coded by frequency. I, however,
>>>> just need to get the pixels which all have the same frequencies,
>>>> which should be easy enough to do using the 1D FFT pixelwise which I
>>>> suggested.
>>>>
>>>> JPK
>>>>
>>>> On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
>>>> [hidden email]> wrote:
>>>>
>>>> Hi Rebecca, You may have a look to Claire Smith's CiliaFA macro. It
>>>>> reveals frequencies of intensity variation in different zone of a
>>>>> brightfield image. We are using it for high frequency Cilia
>>>>> beating. here is a link to the paper and macro :
>>>>> http://www.ciliajournal.com/content/1/1/14
>>>>>
>>>>>
>>>>> Rebecca Keller <[hidden email]> a écrit :
>>>>>
>>>>> Dear List,
>>>>>
>>>>>>
>>>>>> Let me rephrase: what I am trying to do is locate oscillations of
>>>>>> a certain frequency onto a 2D visual field, i.e., convert the
>>>>>> third dimension (time) of a time-lapse image series into
>>>>>> frequency space. Then I could scan through frequency space (the
>>>>>> new third dimension) to find groups of pixels with similar
>>>>>> oscillation frequencies.
>>>>>>
>>>>>> So I guess what would need to be done is a 1D FFT for each pixel.
>>>>>> Is there any way easily to do this with the current imagej
>>>>>> tools?
>>>>>>
>>>>>> JPK
>>>>>>
>>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>>
>>>>>>
>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>
>>>>>
>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> <whole_stack_FFT.png>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

Herbie-3
In reply to this post by Rebecca Keller
Rebecca,

as others have correctly noted already, the result you are showing
in the graph in principle is sound.

What you show is (most probable) the logarithm of the power spectrum.
The power spectrum of a real-valued signal is always symmetric, so you
may consider only one (the left) half of the resulting spectra.
Furthermore, and as mentioned by James Ewing, the low spectral
amplitudes at frequencies above about 300 will allow you to reduce the
number of slices of the stack by a factor of three to four. Before doing
this subsampling, you are to low-pass filter the stack appropriately.

Of course, the computation of 16384 1D-FFTs is time-consuming and of
course the suggested implementation is suboptimum. Dedicated Java-code
could considerably speed-up the processing.

Best

Herbie

::::::::::::::::::::::::::::::::::::::::
On 21.03.14 02:58, Rebecca Keller wrote:

> Yes, this macro is exactly the right thing, but it is really slow
> even when I make the stack 2^n (4096) images and bin it 4 x 4 x 2.
> (128 x 128 x 2048 total voxels.) I would think it could be much
> faster if implemented right, in java perhaps? I would guess that
> opening all those windows is unnecessary, but I am not sure how to
> *not* open them. But anyway, the results are pretty cool--any idea
> what frequency is represented by each image? Also, it's close to
> symmetrical over time--what's going on there, exactly (see attached)?
> I would think if it were symmetrical it would be largest in the
> center as well, but...
>
> Anyway, thanks for this start--I'll see what can be done,
>
> JPK
>
>
>
>
>
> On Thu, Mar 20, 2014 at 12:01 PM, Brian Northan <[hidden email]>
> wrote:
>
>> Hi Rebecca
>>
>> I am not aware of a simple solution, hopefully someone else knows.
>> But someone had a similar problem a while back and it ended up
>> being a fairly involved discussion.  He had to write some macros.
>>
>>
>> http://imagej.1557.x6.nabble.com/Automating-Image-Processing-and-Problems-with-FFTJ-td5004660.html
>>
>>
>>
As Herbie mentioned FFTJ is not macro-recordable, I have a slightly

>> modified version of FFTJ which is recordable and is available here
>>
>> https://github.com/bnorthan/RogueImageJPlugins/releases
>>
>> It is really just a copy of the original except with the small
>> changes talked about in the other thread.
>>
>> I played around with calling FFTJ on individual points in a time
>> series using a python macro.  I think the logic is right but keep
>> in mind it is a hack and pretty slow.   The proper way to do it
>> would be to perform all calculations in one plugin.   This approach
>> loops through every pixel, copies a time profile to a temp image
>> then runs the plugin over and over.
>>
>>
>> https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scriptable/macros/Time_Macro.py
>>
>>
>>
>>
>>
>>
On Thu, Mar 20, 2014 at 6:02 AM, Herbie <[hidden email]> wrote:

>>
>>> Rebecca,
>>>
>>> if you manage to extract 1D-"images" from your time series of
>>> images, i.e. in fact pixel sequences as 1D-images, then you may
>>> use the FFTJ-PlugIn to perform 1D-FFTs of each of these series.
>>>
>>> <http://rsb.info.nih.gov/ij/plugins/fftj.html>
>>>
>>> You may use a macro to extract the n^2 1D-images (assuming that
>>> your images are of size n x n). To make use of the FFT speed
>>> advantage, your stack must consist of m images (time slices),
>>> where m is a power of two.
>>>
>>> The problem with FFTJ is, that it isn't perfectly
>>> macro-recordable. It shows a dialog for choosing the result
>>> format. In other words, to fully automatize processing by an
>>> IJ-macro, you need to modify the source code
>> of
>>> FFTJ.
>>>
>>> HTH
>>>
>>> Herbie
>>>
>>> ::::::::::::::::::::::::::::::::::::::::
>>>
>>> On 20.03.14 02:04, Rebecca Keller wrote:
>>>
>>>> Thanks very much for this reference, but actually it is a bit
>>>> cumbersome to come in and out of imagej, since this "plugin"
>>>> requires ms excel for the fft'ing.
>>>>
>>>> Seems like it should be possible to get the current fft
>>>> algorithm to do a 1D FFT on each pixel over time, then
>>>> re-output the timelapse stack as a 2D image in frequency
>>>> domain. Then it would be neat, for example, to make a 2D image
>>>> depth-coded by frequency. I, however, just need to get the
>>>> pixels which all have the same frequencies, which should be
>>>> easy enough to do using the 1D FFT pixelwise which I
>>>> suggested.
>>>>
>>>> JPK
>>>>
>>>> On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
>>>> [hidden email]> wrote:
>>>>
>>>> Hi Rebecca, You may have a look to Claire Smith's CiliaFA
>>>> macro. It
>>>>> reveals frequencies of intensity variation in different zone
>>>>> of a brightfield image. We are using it for high frequency
>>>>> Cilia beating. here is a link to the paper and macro :
>>>>> http://www.ciliajournal.com/content/1/1/14
>>>>>
>>>>>
>>>>> Rebecca Keller <[hidden email]> a écrit :
>>>>>
>>>>> Dear List,
>>>>>
>>>>>>
>>>>>> Let me rephrase: what I am trying to do is locate
>>>>>> oscillations of a certain frequency onto a 2D visual field,
>>>>>> i.e., convert the third dimension (time) of a time-lapse
>>>>>> image series into frequency space. Then I could scan
>>>>>> through frequency space (the new third dimension) to find
>>>>>> groups of pixels with similar oscillation frequencies.
>>>>>>
>>>>>> So I guess what would need to be done is a 1D FFT for each
>>>>>> pixel. Is there any way easily to do this with the current
>>>>>> imagej tools?
>>>>>>
>>>>>> JPK
>>>>>>
>>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>>
>>>>>>
>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>
>>>>>
>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>>
>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

Michael Doube-4
On 21/03/14 10:22, Herbie wrote:
> Dedicated Java-code
> could considerably speed-up the processing.

+1 to that: macros are very slow at doing pixel-by-pixel calculations. Experience shows that you will get some orders of magnitude speed-up by implementing your algorithm in Java rather than macro. (and some orders of magnitude more if it's amenable to being shifted onto the GPU)



<http://www.rvc.ac.uk>

This message, together with any attachments, is intended for the stated addressee(s) only and may contain privileged or confidential information. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Royal Veterinary College.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

bnorthan
Dedicated Java code is for sure the way to go.  In this case FFTJ is
already dedicated Java code.  The problem was the overhead in calling the
plugin.  Since the script was written in Python it is actually possible to
import and access java directly.

The first (inefficient) implementation of the Macro

IJ.run("FFTJ Script", "real=TimeProfile imaginary=<none> complex344=[Single
> Precision] fft=forward fourier=[At (0,0,0)] show_power_spectrum")
> spectrum_plus=IJ.getImage()
> spectrum_pix=spectrum_plus.getProcessor().getPixels()
>

 This actually can be easily reworked by using the java interfaces directly

transformer= SinglePrecFFT3D(timeprofile.getStack(), None)
> transformer.fft()
> spectrum_plus=transformer.toImagePlus(ComplexValueType.POWER_SPECTRUM,
> FourierDomainOrigin.AT_ZERO );
> spectrum_pix=spectrum_plus.getProcessor().getPixels()
>

I updated the "macro" (perhaps it should be called a script) and it should
be much faster now

https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scriptable/macros/Time_Macro.py

The source code for FFTJ is provided with the plugin

http://rsb.info.nih.gov/ij/plugins/fftj.html

By inspecting it one can see which java interfaces are available and play
with the different ways of presenting the output (real and complex parts,
phase spectrum, power spectrum, etc.)



On Fri, Mar 21, 2014 at 6:31 AM, Doube, Michael <[hidden email]> wrote:

> On 21/03/14 10:22, Herbie wrote:
> > Dedicated Java-code
> > could considerably speed-up the processing.
>
> +1 to that: macros are very slow at doing pixel-by-pixel calculations.
> Experience shows that you will get some orders of magnitude speed-up by
> implementing your algorithm in Java rather than macro. (and some orders of
> magnitude more if it's amenable to being shifted onto the GPU)
>
>
>
> <http://www.rvc.ac.uk>
>
> This message, together with any attachments, is intended for the stated
> addressee(s) only and may contain privileged or confidential information.
> Any views or opinions presented are solely those of the author and do not
> necessarily represent those of the Royal Veterinary College.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

James Ewing
In reply to this post by Rebecca Keller
Rebecca - The list has answered your questions about implementing an FFT on your time-stacked data very nicely, but I wonder if an FFT is what you want.  First, there’s an implicit assumption that whatever is moving is following a stationary process - things are moving at a constant frequency across the entire time of your sample. If that’s not true, you’ll get destructive interferences in your interesting frequencies, and a loss of power in the frequencies.  Second, there’s the idea that your pixels are uncorrelated, so that an independent analysis of pixel i,j completes your information about that pixel without knowing what’s happening in i,j+1.  

I wonder what the list thinks? Would it be better to use a band-pass filter in the time dimension and fiddle with the band-pass parameters until the movement becomes apparent? Or something like an auto-correlation? Autoregressive moving average (ARMA) comes to mind.  The computation is quick, and the information you get back is intuitive because the 2-d information is still in picture form. If you want to get fancy, you might start to think about correlations in all three dimensions, so that neighboring pixels get included in the picture.  Just to be clear - these techniques relate strongly to the FFT, but they allow non-stationary signals to be analyzed.

Thanks to the list for the information about FFTJ.  That was very useful to me.

- Jim Ewing

On Mar 20, 2014, at 9:58 PM, Rebecca Keller <[hidden email]> wrote:

> Yes, this macro is exactly the right thing, but it is really slow even when
> I make the stack 2^n (4096) images and bin it 4 x 4 x 2. (128 x 128 x 2048
> total voxels.) I would think it could be much faster if implemented right,
> in java perhaps? I would guess that opening all those windows is
> unnecessary, but I am not sure how to *not* open them. But anyway, the
> results are pretty cool--any idea what frequency is represented by each
> image? Also, it's close to symmetrical over time--what's going on there,
> exactly (see attached)? I would think if it were symmetrical it would be
> largest in the center as well, but...
>
> Anyway, thanks for this start--I'll see what can be done,
>
> JPK
>
>
>
>
>
> On Thu, Mar 20, 2014 at 12:01 PM, Brian Northan <[hidden email]> wrote:
>
>> Hi Rebecca
>>
>> I am not aware of a simple solution, hopefully someone else knows.   But
>> someone had a similar problem a while back and it ended up being a fairly
>> involved discussion.  He had to write some macros.
>>
>>
>> http://imagej.1557.x6.nabble.com/Automating-Image-Processing-and-Problems-with-FFTJ-td5004660.html
>>
>> As Herbie mentioned FFTJ is not macro-recordable, I have a slightly
>> modified version of FFTJ which is recordable and is available here
>>
>> https://github.com/bnorthan/RogueImageJPlugins/releases
>>
>> It is really just a copy of the original except with the small changes
>> talked about in the other thread.
>>
>> I played around with calling FFTJ on individual points in a time series
>> using a python macro.  I think the logic is right but keep in mind it is a
>> hack and pretty slow.   The proper way to do it would be to perform all
>> calculations in one plugin.   This approach loops through every pixel,
>> copies a time profile to a temp image then runs the plugin over and over.
>>
>>
>> https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scriptable/macros/Time_Macro.py
>>
>>
>>
>>
>> On Thu, Mar 20, 2014 at 6:02 AM, Herbie <[hidden email]> wrote:
>>
>>> Rebecca,
>>>
>>> if you manage to extract 1D-"images" from your time series of images,
>>> i.e. in fact pixel sequences as 1D-images, then you may use the
>>> FFTJ-PlugIn to perform 1D-FFTs of each of these series.
>>>
>>> <http://rsb.info.nih.gov/ij/plugins/fftj.html>
>>>
>>> You may use a macro to extract the n^2 1D-images (assuming that your
>>> images are of size n x n). To make use of the FFT speed advantage, your
>>> stack must consist of m images (time slices), where m is a power of two.
>>>
>>> The problem with FFTJ is, that it isn't perfectly macro-recordable. It
>>> shows a dialog for choosing the result format. In other words, to fully
>>> automatize processing by an IJ-macro, you need to modify the source code
>> of
>>> FFTJ.
>>>
>>> HTH
>>>
>>> Herbie
>>>
>>> ::::::::::::::::::::::::::::::::::::::::
>>>
>>> On 20.03.14 02:04, Rebecca Keller wrote:
>>>
>>>> Thanks very much for this reference, but actually it is a bit
>>>> cumbersome to come in and out of imagej, since this "plugin" requires
>>>> ms excel for the fft'ing.
>>>>
>>>> Seems like it should be possible to get the current fft algorithm to
>>>> do a 1D FFT on each pixel over time, then re-output the timelapse
>>>> stack as a 2D image in frequency domain. Then it would be neat, for
>>>> example, to make a 2D image depth-coded by frequency. I, however,
>>>> just need to get the pixels which all have the same frequencies,
>>>> which should be easy enough to do using the 1D FFT pixelwise which I
>>>> suggested.
>>>>
>>>> JPK
>>>>
>>>> On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
>>>> [hidden email]> wrote:
>>>>
>>>> Hi Rebecca, You may have a look to Claire Smith's CiliaFA macro. It
>>>>> reveals frequencies of intensity variation in different zone of a
>>>>> brightfield image. We are using it for high frequency Cilia
>>>>> beating. here is a link to the paper and macro :
>>>>> http://www.ciliajournal.com/content/1/1/14
>>>>>
>>>>>
>>>>> Rebecca Keller <[hidden email]> a écrit :
>>>>>
>>>>> Dear List,
>>>>>
>>>>>>
>>>>>> Let me rephrase: what I am trying to do is locate oscillations of
>>>>>> a certain frequency onto a 2D visual field, i.e., convert the
>>>>>> third dimension (time) of a time-lapse image series into
>>>>>> frequency space. Then I could scan through frequency space (the
>>>>>> new third dimension) to find groups of pixels with similar
>>>>>> oscillation frequencies.
>>>>>>
>>>>>> So I guess what would need to be done is a 1D FFT for each pixel.
>>>>>> Is there any way easily to do this with the current imagej
>>>>>> tools?
>>>>>>
>>>>>> JPK
>>>>>>
>>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>>
>>>>>>
>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>
>>>>>
>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> <whole_stack_FFT.png>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

Unruh, Jay-2
Not sure if this adds anything to the conversation at this point, but my open-source plugin distribution (http://research.stowers.org/imagejplugins/) has a fast temporal fft (it installs under Plugins>ICS Tools>stack temporal fft jru v1) which will calculate your fft much faster (around 5 seconds for 128x128x2048).  The output is a bit difficult to interpret (alternating real and imaginary images with first positive and then negative frequencies) as has been discussed before.  My plugin distribution also has tools for temporal and spatiotemporal correlation if you are interested in those approaches.

Jay



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of James Ewing
Sent: Friday, March 21, 2014 7:56 AM
To: [hidden email]
Subject: Re: Rephrased FFT Question

Rebecca - The list has answered your questions about implementing an FFT on your time-stacked data very nicely, but I wonder if an FFT is what you want.  First, there's an implicit assumption that whatever is moving is following a stationary process - things are moving at a constant frequency across the entire time of your sample. If that's not true, you'll get destructive interferences in your interesting frequencies, and a loss of power in the frequencies.  Second, there's the idea that your pixels are uncorrelated, so that an independent analysis of pixel i,j completes your information about that pixel without knowing what's happening in i,j+1.  

I wonder what the list thinks? Would it be better to use a band-pass filter in the time dimension and fiddle with the band-pass parameters until the movement becomes apparent? Or something like an auto-correlation? Autoregressive moving average (ARMA) comes to mind.  The computation is quick, and the information you get back is intuitive because the 2-d information is still in picture form. If you want to get fancy, you might start to think about correlations in all three dimensions, so that neighboring pixels get included in the picture.  Just to be clear - these techniques relate strongly to the FFT, but they allow non-stationary signals to be analyzed.

Thanks to the list for the information about FFTJ.  That was very useful to me.

- Jim Ewing

On Mar 20, 2014, at 9:58 PM, Rebecca Keller <[hidden email]> wrote:

> Yes, this macro is exactly the right thing, but it is really slow even
> when I make the stack 2^n (4096) images and bin it 4 x 4 x 2. (128 x
> 128 x 2048 total voxels.) I would think it could be much faster if
> implemented right, in java perhaps? I would guess that opening all
> those windows is unnecessary, but I am not sure how to *not* open
> them. But anyway, the results are pretty cool--any idea what frequency
> is represented by each image? Also, it's close to symmetrical over
> time--what's going on there, exactly (see attached)? I would think if
> it were symmetrical it would be largest in the center as well, but...
>
> Anyway, thanks for this start--I'll see what can be done,
>
> JPK
>
>
>
>
>
> On Thu, Mar 20, 2014 at 12:01 PM, Brian Northan <[hidden email]> wrote:
>
>> Hi Rebecca
>>
>> I am not aware of a simple solution, hopefully someone else knows.   But
>> someone had a similar problem a while back and it ended up being a
>> fairly involved discussion.  He had to write some macros.
>>
>>
>> http://imagej.1557.x6.nabble.com/Automating-Image-Processing-and-Prob
>> lems-with-FFTJ-td5004660.html
>>
>> As Herbie mentioned FFTJ is not macro-recordable, I have a slightly
>> modified version of FFTJ which is recordable and is available here
>>
>> https://github.com/bnorthan/RogueImageJPlugins/releases
>>
>> It is really just a copy of the original except with the small
>> changes talked about in the other thread.
>>
>> I played around with calling FFTJ on individual points in a time
>> series using a python macro.  I think the logic is right but keep in mind it is a
>> hack and pretty slow.   The proper way to do it would be to perform all
>> calculations in one plugin.   This approach loops through every pixel,
>> copies a time profile to a temp image then runs the plugin over and over.
>>
>>
>> https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scrip
>> table/macros/Time_Macro.py
>>
>>
>>
>>
>> On Thu, Mar 20, 2014 at 6:02 AM, Herbie <[hidden email]> wrote:
>>
>>> Rebecca,
>>>
>>> if you manage to extract 1D-"images" from your time series of
>>> images, i.e. in fact pixel sequences as 1D-images, then you may use
>>> the FFTJ-PlugIn to perform 1D-FFTs of each of these series.
>>>
>>> <http://rsb.info.nih.gov/ij/plugins/fftj.html>
>>>
>>> You may use a macro to extract the n^2 1D-images (assuming that your
>>> images are of size n x n). To make use of the FFT speed advantage,
>>> your stack must consist of m images (time slices), where m is a power of two.
>>>
>>> The problem with FFTJ is, that it isn't perfectly macro-recordable.
>>> It shows a dialog for choosing the result format. In other words, to
>>> fully automatize processing by an IJ-macro, you need to modify the
>>> source code
>> of
>>> FFTJ.
>>>
>>> HTH
>>>
>>> Herbie
>>>
>>> ::::::::::::::::::::::::::::::::::::::::
>>>
>>> On 20.03.14 02:04, Rebecca Keller wrote:
>>>
>>>> Thanks very much for this reference, but actually it is a bit
>>>> cumbersome to come in and out of imagej, since this "plugin"
>>>> requires ms excel for the fft'ing.
>>>>
>>>> Seems like it should be possible to get the current fft algorithm
>>>> to do a 1D FFT on each pixel over time, then re-output the
>>>> timelapse stack as a 2D image in frequency domain. Then it would be
>>>> neat, for example, to make a 2D image depth-coded by frequency. I,
>>>> however, just need to get the pixels which all have the same
>>>> frequencies, which should be easy enough to do using the 1D FFT
>>>> pixelwise which I suggested.
>>>>
>>>> JPK
>>>>
>>>> On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
>>>> [hidden email]> wrote:
>>>>
>>>> Hi Rebecca, You may have a look to Claire Smith's CiliaFA macro. It
>>>>> reveals frequencies of intensity variation in different zone of a
>>>>> brightfield image. We are using it for high frequency Cilia
>>>>> beating. here is a link to the paper and macro :
>>>>> http://www.ciliajournal.com/content/1/1/14
>>>>>
>>>>>
>>>>> Rebecca Keller <[hidden email]> a écrit :
>>>>>
>>>>> Dear List,
>>>>>
>>>>>>
>>>>>> Let me rephrase: what I am trying to do is locate oscillations of
>>>>>> a certain frequency onto a 2D visual field, i.e., convert the
>>>>>> third dimension (time) of a time-lapse image series into
>>>>>> frequency space. Then I could scan through frequency space (the
>>>>>> new third dimension) to find groups of pixels with similar
>>>>>> oscillation frequencies.
>>>>>>
>>>>>> So I guess what would need to be done is a 1D FFT for each pixel.
>>>>>> Is there any way easily to do this with the current imagej tools?
>>>>>>
>>>>>> JPK
>>>>>>
>>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>>
>>>>>>
>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>
>>>>>
>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> <whole_stack_FFT.png>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

Herbie-3
In reply to this post by James Ewing
Dear Jim Ewing,

thanks for your comments that appear to be "to the point".
I have doubts as well concerning the application of Fourier-analysis.

As long as the list doesn't know what the exact meaning of
"locate oscillations of a certain frequency onto a 2D visual field"
is, it appears impossible to recommend a _good approach_.

What we've tried so far is to help with the _desired approach_, not
knowing if it is adequate.

Best

Herbie

:::::::::::::::::::::::::::::::::::::
On 21.03.14 13:55, James Ewing wrote:

> Rebecca - The list has answered your questions about implementing an
> FFT on your time-stacked data very nicely, but I wonder if an FFT is
> what you want.  First, there’s an implicit assumption that whatever
> is moving is following a stationary process - things are moving at a
> constant frequency across the entire time of your sample. If that’s
> not true, you’ll get destructive interferences in your interesting
> frequencies, and a loss of power in the frequencies.  Second, there’s
> the idea that your pixels are uncorrelated, so that an independent
> analysis of pixel i,j completes your information about that pixel
> without knowing what’s happening in i,j+1.
>
> I wonder what the list thinks? Would it be better to use a band-pass
> filter in the time dimension and fiddle with the band-pass parameters
> until the movement becomes apparent? Or something like an
> auto-correlation? Autoregressive moving average (ARMA) comes to mind.
> The computation is quick, and the information you get back is
> intuitive because the 2-d information is still in picture form. If
> you want to get fancy, you might start to think about correlations in
> all three dimensions, so that neighboring pixels get included in the
> picture.  Just to be clear - these techniques relate strongly to the
> FFT, but they allow non-stationary signals to be analyzed.
>
> Thanks to the list for the information about FFTJ.  That was very
> useful to me.
>
> - Jim Ewing
>
> On Mar 20, 2014, at 9:58 PM, Rebecca Keller <[hidden email]>
> wrote:
>
>> Yes, this macro is exactly the right thing, but it is really slow
>> even when I make the stack 2^n (4096) images and bin it 4 x 4 x 2.
>> (128 x 128 x 2048 total voxels.) I would think it could be much
>> faster if implemented right, in java perhaps? I would guess that
>> opening all those windows is unnecessary, but I am not sure how to
>> *not* open them. But anyway, the results are pretty cool--any idea
>> what frequency is represented by each image? Also, it's close to
>> symmetrical over time--what's going on there, exactly (see
>> attached)? I would think if it were symmetrical it would be largest
>> in the center as well, but...
>>
>> Anyway, thanks for this start--I'll see what can be done,
>>
>> JPK
>>
>>
>>
>>
>>
>> On Thu, Mar 20, 2014 at 12:01 PM, Brian Northan
>> <[hidden email]> wrote:
>>
>>> Hi Rebecca
>>>
>>> I am not aware of a simple solution, hopefully someone else
>>> knows.   But someone had a similar problem a while back and it
>>> ended up being a fairly involved discussion.  He had to write
>>> some macros.
>>>
>>>
>>> http://imagej.1557.x6.nabble.com/Automating-Image-Processing-and-Problems-with-FFTJ-td5004660.html
>>>
>>>
>>>
As Herbie mentioned FFTJ is not macro-recordable, I have a slightly

>>> modified version of FFTJ which is recordable and is available
>>> here
>>>
>>> https://github.com/bnorthan/RogueImageJPlugins/releases
>>>
>>> It is really just a copy of the original except with the small
>>> changes talked about in the other thread.
>>>
>>> I played around with calling FFTJ on individual points in a time
>>> series using a python macro.  I think the logic is right but keep
>>> in mind it is a hack and pretty slow.   The proper way to do it
>>> would be to perform all calculations in one plugin.   This
>>> approach loops through every pixel, copies a time profile to a
>>> temp image then runs the plugin over and over.
>>>
>>>
>>> https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scriptable/macros/Time_Macro.py
>>>
>>>
>>>
>>>
>>>
>>>
On Thu, Mar 20, 2014 at 6:02 AM, Herbie <[hidden email]> wrote:

>>>
>>>> Rebecca,
>>>>
>>>> if you manage to extract 1D-"images" from your time series of
>>>> images, i.e. in fact pixel sequences as 1D-images, then you may
>>>> use the FFTJ-PlugIn to perform 1D-FFTs of each of these
>>>> series.
>>>>
>>>> <http://rsb.info.nih.gov/ij/plugins/fftj.html>
>>>>
>>>> You may use a macro to extract the n^2 1D-images (assuming that
>>>> your images are of size n x n). To make use of the FFT speed
>>>> advantage, your stack must consist of m images (time slices),
>>>> where m is a power of two.
>>>>
>>>> The problem with FFTJ is, that it isn't perfectly
>>>> macro-recordable. It shows a dialog for choosing the result
>>>> format. In other words, to fully automatize processing by an
>>>> IJ-macro, you need to modify the source code
>>> of
>>>> FFTJ.
>>>>
>>>> HTH
>>>>
>>>> Herbie
>>>>
>>>> ::::::::::::::::::::::::::::::::::::::::
>>>>
>>>> On 20.03.14 02:04, Rebecca Keller wrote:
>>>>
>>>>> Thanks very much for this reference, but actually it is a
>>>>> bit cumbersome to come in and out of imagej, since this
>>>>> "plugin" requires ms excel for the fft'ing.
>>>>>
>>>>> Seems like it should be possible to get the current fft
>>>>> algorithm to do a 1D FFT on each pixel over time, then
>>>>> re-output the timelapse stack as a 2D image in frequency
>>>>> domain. Then it would be neat, for example, to make a 2D
>>>>> image depth-coded by frequency. I, however, just need to get
>>>>> the pixels which all have the same frequencies, which should
>>>>> be easy enough to do using the 1D FFT pixelwise which I
>>>>> suggested.
>>>>>
>>>>> JPK
>>>>>
>>>>> On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
>>>>> [hidden email]> wrote:
>>>>>
>>>>> Hi Rebecca, You may have a look to Claire Smith's CiliaFA
>>>>> macro. It
>>>>>> reveals frequencies of intensity variation in different
>>>>>> zone of a brightfield image. We are using it for high
>>>>>> frequency Cilia beating. here is a link to the paper and
>>>>>> macro : http://www.ciliajournal.com/content/1/1/14
>>>>>>
>>>>>>
>>>>>> Rebecca Keller <[hidden email]> a écrit :
>>>>>>
>>>>>> Dear List,
>>>>>>
>>>>>>>
>>>>>>> Let me rephrase: what I am trying to do is locate
>>>>>>> oscillations of a certain frequency onto a 2D visual
>>>>>>> field, i.e., convert the third dimension (time) of a
>>>>>>> time-lapse image series into frequency space. Then I
>>>>>>> could scan through frequency space (the new third
>>>>>>> dimension) to find groups of pixels with similar
>>>>>>> oscillation frequencies.
>>>>>>>
>>>>>>> So I guess what would need to be done is a 1D FFT for
>>>>>>> each pixel. Is there any way easily to do this with the
>>>>>>> current imagej tools?
>>>>>>>
>>>>>>> JPK
>>>>>>>
>>>>>>> -- ImageJ mailing list:
>>>>>>> http://imagej.nih.gov/ij/list.html
>>>>>>>
>>>>>>>
>>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>>
>>>>>>
>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>
>>>>>
>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>
>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>> <whole_stack_FFT.png>
>
> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Rephrased FFT Question

Klaus Michel
In reply to this post by Unruh, Jay-2
Hello,

just an additional thought. Maybe it is a good idea to have a "look" at the data by turning the
stack around the x- or y-axis (TransformJ, Turn, x-angle=90 or y-angle=90). If the oscillations
are not to small, they can now easily be seen. It may then be easier to decide how to analyze
the data.

Regards,

Klaus

On 21 Mar 2014 at 15:03, Unruh, Jay wrote:

> Not sure if this adds anything to the conversation at this point, but my open-source plugin distribution (http://research.stowers.org/imagejplugins/) has a fast temporal fft (it installs under Plugins>ICS Tools>stack temporal fft jru v1) which will calculate your fft much faster (around 5 seconds for 128x128x2048).  The output is a bit difficult to interpret (alternating real and imaginary images with first positive and then negative frequencies) as has been discussed before.  My plugin distribution also has tools for temporal and spatiotemporal correlation if you are interested in those approaches.
>
> Jay
>
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of James Ewing
> Sent: Friday, March 21, 2014 7:56 AM
> To: [hidden email]
> Subject: Re: Rephrased FFT Question
>
> Rebecca - The list has answered your questions about implementing an FFT on your time-stacked data very nicely, but I wonder if an FFT is what you want.  First, there's an implicit assumption that whatever is moving is following a stationary process - things are moving at a constant frequency across the entire time of your sample. If that's not true, you'll get destructive interferences in your interesting frequencies, and a loss of power in the frequencies.  Second, there's the idea that your pixels are uncorrelated, so that an independent analysis of pixel i,j completes your information about that pixel without knowing what's happening in i,j+1.
>
> I wonder what the list thinks? Would it be better to use a band-pass filter in the time dimension and fiddle with the band-pass parameters until the movement becomes apparent? Or something like an auto-correlation? Autoregressive moving average (ARMA) comes to mind.  The computation is quick, and the information you get back is intuitive because the 2-d information is still in picture form. If you want to get fancy, you might start to think about correlations in all three dimensions, so that neighboring pixels get included in the picture.  Just to be clear - these techniques relate strongly to the FFT, but they allow non-stationary signals to be analyzed.
>
> Thanks to the list for the information about FFTJ.  That was very useful to me.
>
> - Jim Ewing
>
> On Mar 20, 2014, at 9:58 PM, Rebecca Keller <[hidden email]> wrote:
>
> > Yes, this macro is exactly the right thing, but it is really slow even
> > when I make the stack 2^n (4096) images and bin it 4 x 4 x 2. (128 x
> > 128 x 2048 total voxels.) I would think it could be much faster if
> > implemented right, in java perhaps? I would guess that opening all
> > those windows is unnecessary, but I am not sure how to *not* open
> > them. But anyway, the results are pretty cool--any idea what frequency
> > is represented by each image? Also, it's close to symmetrical over
> > time--what's going on there, exactly (see attached)? I would think if
> > it were symmetrical it would be largest in the center as well, but...
> >
> > Anyway, thanks for this start--I'll see what can be done,
> >
> > JPK
> >
> >
> >
> >
> >
> > On Thu, Mar 20, 2014 at 12:01 PM, Brian Northan <[hidden email]> wrote:
> >
> >> Hi Rebecca
> >>
> >> I am not aware of a simple solution, hopefully someone else knows.   But
> >> someone had a similar problem a while back and it ended up being a
> >> fairly involved discussion.  He had to write some macros.
> >>
> >>
> >> http://imagej.1557.x6.nabble.com/Automating-Image-Processing-and-Prob
> >> lems-with-FFTJ-td5004660.html
> >>
> >> As Herbie mentioned FFTJ is not macro-recordable, I have a slightly
> >> modified version of FFTJ which is recordable and is available here
> >>
> >> https://github.com/bnorthan/RogueImageJPlugins/releases
> >>
> >> It is really just a copy of the original except with the small
> >> changes talked about in the other thread.
> >>
> >> I played around with calling FFTJ on individual points in a time
> >> series using a python macro.  I think the logic is right but keep in mind it is a
> >> hack and pretty slow.   The proper way to do it would be to perform all
> >> calculations in one plugin.   This approach loops through every pixel,
> >> copies a time profile to a temp image then runs the plugin over and over.
> >>
> >>
> >> https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scrip
> >> table/macros/Time_Macro.py
> >>
> >>
> >>
> >>
> >> On Thu, Mar 20, 2014 at 6:02 AM, Herbie <[hidden email]> wrote:
> >>
> >>> Rebecca,
> >>>
> >>> if you manage to extract 1D-"images" from your time series of
> >>> images, i.e. in fact pixel sequences as 1D-images, then you may use
> >>> the FFTJ-PlugIn to perform 1D-FFTs of each of these series.
> >>>
> >>> <http://rsb.info.nih.gov/ij/plugins/fftj.html>
> >>>
> >>> You may use a macro to extract the n^2 1D-images (assuming that your
> >>> images are of size n x n). To make use of the FFT speed advantage,
> >>> your stack must consist of m images (time slices), where m is a power of two.
> >>>
> >>> The problem with FFTJ is, that it isn't perfectly macro-recordable.
> >>> It shows a dialog for choosing the result format. In other words, to
> >>> fully automatize processing by an IJ-macro, you need to modify the
> >>> source code
> >> of
> >>> FFTJ.
> >>>
> >>> HTH
> >>>
> >>> Herbie
> >>>
> >>> ::::::::::::::::::::::::::::::::::::::::
> >>>
> >>> On 20.03.14 02:04, Rebecca Keller wrote:
> >>>
> >>>> Thanks very much for this reference, but actually it is a bit
> >>>> cumbersome to come in and out of imagej, since this "plugin"
> >>>> requires ms excel for the fft'ing.
> >>>>
> >>>> Seems like it should be possible to get the current fft algorithm
> >>>> to do a 1D FFT on each pixel over time, then re-output the
> >>>> timelapse stack as a 2D image in frequency domain. Then it would be
> >>>> neat, for example, to make a 2D image depth-coded by frequency. I,
> >>>> however, just need to get the pixels which all have the same
> >>>> frequencies, which should be easy enough to do using the 1D FFT
> >>>> pixelwise which I suggested.
> >>>>
> >>>> JPK
> >>>>
> >>>> On Wed, Mar 19, 2014 at 5:18 PM, Eric Denarier <
> >>>> [hidden email]> wrote:
> >>>>
> >>>> Hi Rebecca, You may have a look to Claire Smith's CiliaFA macro. It
> >>>>> reveals frequencies of intensity variation in different zone of a
> >>>>> brightfield image. We are using it for high frequency Cilia
> >>>>> beating. here is a link to the paper and macro :
> >>>>> http://www.ciliajournal.com/content/1/1/14
> >>>>>
> >>>>>
> >>>>> Rebecca Keller <[hidden email]> a écrit :
> >>>>>
> >>>>> Dear List,
> >>>>>
> >>>>>>
> >>>>>> Let me rephrase: what I am trying to do is locate oscillations of
> >>>>>> a certain frequency onto a 2D visual field, i.e., convert the
> >>>>>> third dimension (time) of a time-lapse image series into
> >>>>>> frequency space. Then I could scan through frequency space (the
> >>>>>> new third dimension) to find groups of pixels with similar
> >>>>>> oscillation frequencies.
> >>>>>>
> >>>>>> So I guess what would need to be done is a 1D FFT for each pixel.
> >>>>>> Is there any way easily to do this with the current imagej tools?
> >>>>>>
> >>>>>> JPK
> >>>>>>
> >>>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>>>>>
> >>>>>>
> >>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>>>>
> >>>>>
> >>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>>>
> >>>>
> >>> --
> >>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>>
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> > <whole_stack_FFT.png>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
Dr. Klaus Michel
Dept. of Human Biology
TU München
Liesel-Beckmann-Strasse 4
D-85354 Freising Weihenstephan
Tel.: +49 (0)8161 715079
Fax: +49 (0)8161 715785
email: [hidden email]

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html