SAVING RESULTS

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

SAVING RESULTS

Walsh, K. (Katherine)
Hi all,

I am really new to imageJ and java, this is the first macro that I have written and it does everything I need it to apart from save my results tables.

macro "Batch Find Area" {
dir = getDirectory("Choose a Directory ");
list = getFileList(dir);
setBatchMode(true);
for (i=0; i<list.length; i++) {
path = dir+list[i];
open(path);
run("8-bit");
run("Make Binary");
run("Convert to Mask");
makeRectangle(482, 230, 1174, 1252);
run("Analyze Particles...", "size=150-Infinity circularity=0.00-1.00 show=Nothing display");
dotIndex = lastIndexOf(path, ".");
if (dotIndex!=-1)
path = substring(path, 0, dotIndex); // remove extension
save(path+"-bin.tif");
close();
selectWindow("Results");
dotIndex = lastIndexOf(path, ".");
if (dotIndex!=-1)
path = substring(path, 0, dotIndex); // remove extension
save(path+"-results.txt");
close()
}

I need the "results" windows for each picture to save with the name of the picture (so I can identify which is which) but I can't seem to do it.
If anyone could help that would be great

Thanks
Kat

Katherine Walsh
R&D
T  +44(0)1753 874019
E  [hidden email]<mailto:[hidden email]>
AkzoNobel Decorative Paints
Imperial Chemical Industries Limited, 26th floor, Bressenden Place, London SW1E 5GB
www.akzonobel.com<http://www.akzonobel.com/>
Follow AkzoNobel online at www.akzonobel.com/followus<http://www.akzonobel.com/followus>

-----------------------------------------------------------------------------------------
The information contained in this message, including any attachments, may be privileged and confidential and is intended only for the use of the individual and/or entity identified in the address of this message. If you are not an intended recipient, please notify the sender and delete and destroy this message, including any back-up copies. Please refer to www.akzonobel.com/legal-entities<http://www.akzonobel.com/legal-entities> for further legal information regarding the sending entity if from the EU, Croatia, Norway, Turkey, Ukraine or Switzerland.
-----------------------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: SAVING RESULTS

Rasband, Wayne (NIH/NIMH) [E]
On Nov 24, 2011, at 11:53 AM, Walsh, K. (Katherine) wrote:

> Hi all,
>
> I am really new to imageJ and java, this is the first macro that I have written and it does everything I need it to apart from save my results tables.

Something like this should work (untested):

  macro "Batch Find Area" {
     dir = getDirectory("Choose a Directory ");
     list = getFileList(dir);
     setBatchMode(true);
     for (i=0; i<list.length; i++) {
        path = dir+list[i];
        open(path);
        run("8-bit");
        run("Make Binary");
        run("Convert to Mask");
        makeRectangle(482, 230, 1174, 1252);
        run("Analyze Particles...",
           "size=150-Infinity circularity=0.00-1.00 show=Nothing clear display");
        path2 = dir+File.nameWithoutExtension;
        saveAs("tiff", path2+"-bin.tif");
        close();
        saveAs("results", path2+"-results.txt");
     }
  }

-wayne

> macro "Batch Find Area" {
> dir = getDirectory("Choose a Directory ");
> list = getFileList(dir);
> setBatchMode(true);
> for (i=0; i<list.length; i++) {
> path = dir+list[i];
> open(path);
> run("8-bit");
> run("Make Binary");
> run("Convert to Mask");
> makeRectangle(482, 230, 1174, 1252);
> run("Analyze Particles...", "size=150-Infinity circularity=0.00-1.00 show=Nothing display");
> dotIndex = lastIndexOf(path, ".");
> if (dotIndex!=-1)
> path = substring(path, 0, dotIndex); // remove extension
> save(path+"-bin.tif");
> close();
> selectWindow("Results");
> dotIndex = lastIndexOf(path, ".");
> if (dotIndex!=-1)
> path = substring(path, 0, dotIndex); // remove extension
> save(path+"-results.txt");
> close()
> }
>
> I need the "results" windows for each picture to save with the name of the picture (so I can identify which is which) but I can't seem to do it.
> If anyone could help that would be great
>
> Thanks
> Kat
>
> Katherine Walsh
> R&D
> T  +44(0)1753 874019
> E  [hidden email]<mailto:[hidden email]>
> AkzoNobel Decorative Paints
> Imperial Chemical Industries Limited, 26th floor, Bressenden Place, London SW1E 5GB
> www.akzonobel.com<http://www.akzonobel.com/>
> Follow AkzoNobel online at www.akzonobel.com/followus<http://www.akzonobel.com/followus>
>
> -----------------------------------------------------------------------------------------
> The information contained in this message, including any attachments, may be privileged and confidential and is intended only for the use of the individual and/or entity identified in the address of this message. If you are not an intended recipient, please notify the sender and delete and destroy this message, including any back-up copies. Please refer to www.akzonobel.com/legal-entities<http://www.akzonobel.com/legal-entities> for further legal information regarding the sending entity if from the EU, Croatia, Norway, Turkey, Ukraine or Switzerland.
> -----------------------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: SAVING RESULTS

dschones
hi there, what i want to do is drawing lines at a definite position in a
bunch of pictures extracting the pixelvalues. id like to combine the values
in one table with the picturenames in first line. my idea is opening every
picture and run("Image to Results") in batch, somehow like the following:

dir=getDirectory("image");
run("8-bit");
run("Enhance Contrast...", "saturated=0.3 normalize");
ids=newArray(nImages);
for (i=0;i<nImages;i++) {
        selectImage(i+1);
title = getTitle();
makeRectangle(936, 516, 3, 201);
run("Image to Results");

saveAs("Results",  dir+title.txt);

}


the saveA doesnt work for me and i have no clou how to combine the data in a
table. can anybody help me please :)



--
Sent from: http://imagej.1557.x6.nabble.com/

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

Re: SAVING RESULTS

Michael Schmid-3
HI dschones,

probably you want to have:
...
   saveAs("Results",  dir+title+".txt");


Michael
________________________________________________________________
On 26/03/2018 18:08, dschones wrote:

> hi there, what i want to do is drawing lines at a definite position in a
> bunch of pictures extracting the pixelvalues. id like to combine the values
> in one table with the picturenames in first line. my idea is opening every
> picture and run("Image to Results") in batch, somehow like the following:
>
> dir=getDirectory("image");
> run("8-bit");
> run("Enhance Contrast...", "saturated=0.3 normalize");
> ids=newArray(nImages);
> for (i=0;i<nImages;i++) {
>          selectImage(i+1);
> title = getTitle();
> makeRectangle(936, 516, 3, 201);
> run("Image to Results");
>
> saveAs("Results",  dir+title.txt);
>
> }
>
>
> the saveA doesnt work for me and i have no clou how to combine the data in a
> table. can anybody help me please :)
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> 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: SAVING RESULTS

dschones
jup, thats it! :) merci! Any idea of how to combine all the textfiles to one
table?



--
Sent from: http://imagej.1557.x6.nabble.com/

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

imglib2 FFT and Complex images

Fred Damen
Greetings,

I have a need to do complex operations of complex images and/or kspace and
view everything.  I found the imglib2 tutorial at
https://imagej.net/ImgLib2_Examples and its a good start.  Although I have a
quandary that I need to resolve before I can dive in.


How to produce an 'Img< ComplexFloatType >' from two ImagePlus(ImageStack)(s),
i.e., one real and one imaginary; both 2D and 3D Fourier Domains. I have found
plenty of examples which feed a real image into an FFT and play with the
complex results.  But nothing that starts with a complex image.

Thanks in advance,

Fred

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

Re: imglib2 FFT and Complex images

Herbie
Good day Fred,

be careful with the ImageJ-2 Fourier-transformation algorithm because it
doesn't use the classic FFT-algorithm and it shows a number of
peculiarities. See my recent contribution to the forum:
<http://forum.imagej.net/t/help-with-imglib2-algorithm-fft-fouriertransform/9946/2>

I'd recommend to have a look at "Parallel FFTJ" which is a classic
implementation
<https://sites.google.com/site/piotrwendykier/software/parallelfftj>
that is able to do 2D and 3D as well as complex input and complex output.

Regards

Herbie



--
Sent from: http://imagej.1557.x6.nabble.com/

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

Re: SAVING RESULTS

Herbie
In reply to this post by dschones
Good day!

please study the macro coding docs:

<https://imagej.nih.gov/ij/developer/macro/macros.html>
<https://imagej.nih.gov/ij/developer/macro/functions.html>

Regards

Herbie

:::::::::::::::::::::::::::::::::::::
Am 26.03.18 um 22:58 schrieb dschones:

> jup, thats it! :) merci! Any idea of how to combine all the textfiles to one
> table?
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> 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: imglib2 FFT and Complex images

Stephan.Preibisch@mdc-berlin.de
In reply to this post by Herbie
Hi, sorry to disagree but it uses a classic FFT algorithm and it also has been reimplemented to give access to functionality at any level (with or without automatic padding):

https://github.com/imglib/imglib2-algorithm-fft/tree/master/src/main/java/net/imglib2/algorithm/fft2 and
https://github.com/imglib/imglib2-algorithm-gpl/tree/master/src/main/java/net/imglib2/algorithm/fft2

Anyways, this is besides the point of the question. What you need to do Fred, is create an Img<ComplexFloatType> of the same dimensions as the two input stacks. Then you iterate over all pixels of your input using for-loops while setting a RandomAccess on the Img<ComplexFloatType> to the respective coordinate. There you call randomAccess.get().get() and you can set the real and imaginary part of each pixel.

Hope this helps,
Stephan

---

Dr. Stephan Preibisch
Group Leader

Berlin Institute for Medical Systems Biology (BIMSB), Max Delbrück Center for Molecular Medicine (MDC)
Building 89, 1.08b
Robert-Rössle-Str. 10
13125 Berlin

email: [hidden email]<mailto:[hidden email]>
web: http://preibischlab.mdc-berlin.de
twitter: http://twitter.com/preibischs

On Mar 27, 2018, at 8:39 AM, Herbie <[hidden email]<mailto:[hidden email]>> wrote:

Good day Fred,

be careful with the ImageJ-2 Fourier-transformation algorithm because it
doesn't use the classic FFT-algorithm and it shows a number of
peculiarities. See my recent contribution to the forum:
<http://forum.imagej.net/t/help-with-imglib2-algorithm-fft-fouriertransform/9946/2>

I'd recommend to have a look at "Parallel FFTJ" which is a classic
implementation
<https://sites.google.com/site/piotrwendykier/software/parallelfftj>
that is able to do 2D and 3D as well as complex input and complex output.

Regards

Herbie



--
Sent from: http://imagej.1557.x6.nabble.com/

--
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: imglib2 FFT and Complex images

Robert Smith
In reply to this post by Herbie
Thank you very much for this information.

I am planning on using FFT quite a lot and any fore knowledge is greatly appreciated.

Bob


________________________________
From: Herbie <[hidden email]>
Sent: Tuesday, March 27, 2018 2:39 AM
To: [hidden email]
Subject: Re: imglib2 FFT and Complex images

Good day Fred,

be careful with the ImageJ-2 Fourier-transformation algorithm because it
doesn't use the classic FFT-algorithm and it shows a number of
peculiarities. See my recent contribution to the forum:
<http://forum.imagej.net/t/help-with-imglib2-algorithm-fft-fouriertransform/9946/2>
[http://forum.imagej.net/letter_avatar_proxy/v2/letter/h/85f322/200.png]<http://forum.imagej.net/t/help-with-imglib2-algorithm-fft-fouriertransform/9946/2>

Help with ImgLib2 algorithm.fft.FourierTransform<http://forum.imagej.net/t/help-with-imglib2-algorithm-fft-fouriertransform/9946/2>
forum.imagej.net
Good day! Although I have very little insights to ImageJ-2, I know that it comprises a module that performs a certain kind of Fourier transformation. The implementation is said to be mostly faster than the classic FFT and is widely independent of the image format (no need for square-sized 2^x support). As you’ve observed already, the output format takes some getting used to … I have no idea whether the ImageJ-1 FFT-implementation was conserved or re-programmed in ImageJ-2. At least the ImageJ-...




I'd recommend to have a look at "Parallel FFTJ" which is a classic
implementation
<https://sites.google.com/site/piotrwendykier/software/parallelfftj>
that is able to do 2D and 3D as well as complex input and complex output.

Regards

Herbie



--
Sent from: http://imagej.1557.x6.nabble.com/

--
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: imglib2 FFT and Complex images

Fred Damen
In reply to this post by Stephan.Preibisch@mdc-berlin.de
Greetings Stephan,

Thanks for the information that you provided.  I finally got a chance to work
on this again, and I have a few questions...

From https://imagej.net/ImgLib2_Examples Example 6c, it states that an inverse
FFT can not be performed without a preceding forward FFT.  Is this still the
case with fft2?  MRI starts with kspace (i.e., Fourier domain).

From
https://github.com/imglib/imglib2-algorithm-fft/blob/master/src/test/java/net/imglib2/algorithm/fft2/FFTTest.java
calls FFT.complexToRealUnpad(fft, inverse);
and from related comments i've seen for fft1...

Does fft2 do a unadulterated FFT? As per your comments below I assume that it
only does the vanilla FFT but the aforementioned test code suggests otherwise.
 If there is other manipulation of k-space / image space beyond the FFT, how
do I avoid disable it?.

Does fft2 assume the center of k-space is at the center of the dataset or is
the 1/2 FOV / 180 phase shift being ignored in the examples, i.e., I do not
see any pre/post fft shift in any example code I've seen.

From https://imagej.net/ImgLib2_-_Accessors I assume I need to do:
int[] dimensions = new int[] { NX, NY };
Img< ComplexFloatType > kspace = new ArrayImgFactory< ComplexFloatType >()
            .create( dimensions, new ComplexFloatType() );

RandomAccess< ComplexFloatType > r = kspace.randomAccess();
for each kspace value {
  r.setPosition( x, 0 );
  r.setPosition( y, 1 );
  r.get().set(rv,iv);
  }

From your email you suggest that the last line would be r.get().get().set(...);

Then I assume that the fft is simply:
FFT.complexToComplexInverse(kspace);
Img< ComplexFloatType > img = kspace;

Thanks in advance,

Fred

On Tue, March 27, 2018 4:13 am, [hidden email] wrote:

> Hi, sorry to disagree but it uses a classic FFT algorithm and it also has been
> reimplemented to give access to functionality at any level (with or without
> automatic padding):
>
> https://github.com/imglib/imglib2-algorithm-fft/tree/master/src/main/java/net/imglib2/algorithm/fft2
> and
> https://github.com/imglib/imglib2-algorithm-gpl/tree/master/src/main/java/net/imglib2/algorithm/fft2
>
> Anyways, this is besides the point of the question. What you need to do Fred,
> is create an Img<ComplexFloatType> of the same dimensions as the two input
> stacks. Then you iterate over all pixels of your input using for-loops while
> setting a RandomAccess on the Img<ComplexFloatType> to the respective
> coordinate. There you call randomAccess.get().get() and you can set the real
> and imaginary part of each pixel.
>
> Hope this helps,
> Stephan
>
> ---
>
> Dr. Stephan Preibisch
> Group Leader
>
> Berlin Institute for Medical Systems Biology (BIMSB), Max Delbrück Center for
> Molecular Medicine (MDC)
> Building 89, 1.08b
> Robert-Rössle-Str. 10
> 13125 Berlin
>
> email: [hidden email]<mailto:[hidden email]>
> web: http://preibischlab.mdc-berlin.de
> twitter: http://twitter.com/preibischs
>
> On Mar 27, 2018, at 8:39 AM, Herbie <[hidden email]<mailto:[hidden email]>>
> wrote:
>
> Good day Fred,
>
> be careful with the ImageJ-2 Fourier-transformation algorithm because it
> doesn't use the classic FFT-algorithm and it shows a number of
> peculiarities. See my recent contribution to the forum:
> <http://forum.imagej.net/t/help-with-imglib2-algorithm-fft-fouriertransform/9946/2>
>
> I'd recommend to have a look at "Parallel FFTJ" which is a classic
> implementation
> <https://sites.google.com/site/piotrwendykier/software/parallelfftj>
> that is able to do 2D and 3D as well as complex input and complex output.
>
> Regards
>
> Herbie
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> 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: imglib2 FFT and Complex images

Fred Damen
Greeting,

I tried compiling using imglib2 and the following line failed:
import net.imglib2.img.Img;

So I went poking around my ImageJ installation and did not find imglib or
imglib2.
The aforementioned Example webpage says imglib2 exists in Imagej 1.  I just
downloaded Imagej for linux from the download page and do not seem to find it
there either.

Do I need to install it?

Thanks,

Fred

On Sun, April 15, 2018 7:27 pm, Fred Damen wrote:

> Greetings Stephan,
>
> Thanks for the information that you provided.  I finally got a chance to work
> on this again, and I have a few questions...
>
>>From https://imagej.net/ImgLib2_Examples Example 6c, it states that an
>> inverse
> FFT can not be performed without a preceding forward FFT.  Is this still the
> case with fft2?  MRI starts with kspace (i.e., Fourier domain).
>
> From
> https://github.com/imglib/imglib2-algorithm-fft/blob/master/src/test/java/net/imglib2/algorithm/fft2/FFTTest.java
> calls FFT.complexToRealUnpad(fft, inverse);
> and from related comments i've seen for fft1...
>
> Does fft2 do a unadulterated FFT? As per your comments below I assume that it
> only does the vanilla FFT but the aforementioned test code suggests otherwise.
>  If there is other manipulation of k-space / image space beyond the FFT, how
> do I avoid disable it?.
>
> Does fft2 assume the center of k-space is at the center of the dataset or is
> the 1/2 FOV / 180 phase shift being ignored in the examples, i.e., I do not
> see any pre/post fft shift in any example code I've seen.
>
>>From https://imagej.net/ImgLib2_-_Accessors I assume I need to do:
> int[] dimensions = new int[] { NX, NY };
> Img< ComplexFloatType > kspace = new ArrayImgFactory< ComplexFloatType >()
>             .create( dimensions, new ComplexFloatType() );
>
> RandomAccess< ComplexFloatType > r = kspace.randomAccess();
> for each kspace value {
>   r.setPosition( x, 0 );
>   r.setPosition( y, 1 );
>   r.get().set(rv,iv);
>   }
>
>>From your email you suggest that the last line would be
>> r.get().get().set(...);
>
> Then I assume that the fft is simply:
> FFT.complexToComplexInverse(kspace);
> Img< ComplexFloatType > img = kspace;
>
> Thanks in advance,
>
> Fred
>
> On Tue, March 27, 2018 4:13 am, [hidden email] wrote:
>> Hi, sorry to disagree but it uses a classic FFT algorithm and it also has
>> been
>> reimplemented to give access to functionality at any level (with or without
>> automatic padding):
>>
>> https://github.com/imglib/imglib2-algorithm-fft/tree/master/src/main/java/net/imglib2/algorithm/fft2
>> and
>> https://github.com/imglib/imglib2-algorithm-gpl/tree/master/src/main/java/net/imglib2/algorithm/fft2
>>
>> Anyways, this is besides the point of the question. What you need to do
>> Fred,
>> is create an Img<ComplexFloatType> of the same dimensions as the two input
>> stacks. Then you iterate over all pixels of your input using for-loops while
>> setting a RandomAccess on the Img<ComplexFloatType> to the respective
>> coordinate. There you call randomAccess.get().get() and you can set the real
>> and imaginary part of each pixel.
>>
>> Hope this helps,
>> Stephan
>>
>> ---
>>
>> Dr. Stephan Preibisch
>> Group Leader
>>
>> Berlin Institute for Medical Systems Biology (BIMSB), Max Delbrück Center
>> for
>> Molecular Medicine (MDC)
>> Building 89, 1.08b
>> Robert-Rössle-Str. 10
>> 13125 Berlin
>>
>> email:
>> [hidden email]<mailto:[hidden email]>
>> web: http://preibischlab.mdc-berlin.de
>> twitter: http://twitter.com/preibischs
>>
>> On Mar 27, 2018, at 8:39 AM, Herbie
>> <[hidden email]<mailto:[hidden email]>>
>> wrote:
>>
>> Good day Fred,
>>
>> be careful with the ImageJ-2 Fourier-transformation algorithm because it
>> doesn't use the classic FFT-algorithm and it shows a number of
>> peculiarities. See my recent contribution to the forum:
>> <http://forum.imagej.net/t/help-with-imglib2-algorithm-fft-fouriertransform/9946/2>
>>
>> I'd recommend to have a look at "Parallel FFTJ" which is a classic
>> implementation
>> <https://sites.google.com/site/piotrwendykier/software/parallelfftj>
>> that is able to do 2D and 3D as well as complex input and complex output.
>>
>> Regards
>>
>> Herbie
>>
>>
>>
>> --
>> Sent from: http://imagej.1557.x6.nabble.com/
>>
>> --
>> 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: imglib2 FFT and Complex images

Saalfeld, Stephan
ImgLib2 is not included in ImageJ1 but in ImageJ2.  Please download
Fiji from https://fiji.sc.

Best,
Stephan

On Sun, 2018-04-15 at 21:39 -0500, Fred Damen wrote:

> Greeting,
>
> I tried compiling using imglib2 and the following line failed:
> import net.imglib2.img.Img;
>
> So I went poking around my ImageJ installation and did not find
> imglib or
> imglib2.
> The aforementioned Example webpage says imglib2 exists in Imagej
> 1.  I just
> downloaded Imagej for linux from the download page and do not seem to
> find it
> there either.
>
> Do I need to install it?
>
> Thanks,
>
> Fred
>
> On Sun, April 15, 2018 7:27 pm, Fred Damen wrote:
> >
> > Greetings Stephan,
> >
> > Thanks for the information that you provided.  I finally got a
> > chance to work
> > on this again, and I have a few questions...
> >
> > >
> > > From https://imagej.net/ImgLib2_Examples Example 6c, it states
> > > that an
> > > inverse
> > FFT can not be performed without a preceding forward FFT.  Is this
> > still the
> > case with fft2?  MRI starts with kspace (i.e., Fourier domain).
> >
> > From
> > https://github.com/imglib/imglib2-algorithm-fft/blob/master/src/tes
> > t/java/net/imglib2/algorithm/fft2/FFTTest.java
> > calls FFT.complexToRealUnpad(fft, inverse);
> > and from related comments i've seen for fft1...
> >
> > Does fft2 do a unadulterated FFT? As per your comments below I
> > assume that it
> > only does the vanilla FFT but the aforementioned test code suggests
> > otherwise.
> >  If there is other manipulation of k-space / image space beyond the
> > FFT, how
> > do I avoid disable it?.
> >
> > Does fft2 assume the center of k-space is at the center of the
> > dataset or is
> > the 1/2 FOV / 180 phase shift being ignored in the examples, i.e.,
> > I do not
> > see any pre/post fft shift in any example code I've seen.
> >
> > >
> > > From https://imagej.net/ImgLib2_-_Accessors I assume I need to
> > > do:
> > int[] dimensions = new int[] { NX, NY };
> > Img< ComplexFloatType > kspace = new ArrayImgFactory<
> > ComplexFloatType >()
> >             .create( dimensions, new ComplexFloatType() );
> >
> > RandomAccess< ComplexFloatType > r = kspace.randomAccess();
> > for each kspace value {
> >   r.setPosition( x, 0 );
> >   r.setPosition( y, 1 );
> >   r.get().set(rv,iv);
> >   }
> >
> > >
> > > From your email you suggest that the last line would be
> > > r.get().get().set(...);
> > Then I assume that the fft is simply:
> > FFT.complexToComplexInverse(kspace);
> > Img< ComplexFloatType > img = kspace;
> >
> > Thanks in advance,
> >
> > Fred
> >
> > On Tue, March 27, 2018 4:13 am, [hidden email]
> > wrote:
> > >
> > > Hi, sorry to disagree but it uses a classic FFT algorithm and it
> > > also has
> > > been
> > > reimplemented to give access to functionality at any level (with
> > > or without
> > > automatic padding):
> > >
> > > https://github.com/imglib/imglib2-algorithm-fft/tree/master/src/m
> > > ain/java/net/imglib2/algorithm/fft2
> > > and
> > > https://github.com/imglib/imglib2-algorithm-gpl/tree/master/src/m
> > > ain/java/net/imglib2/algorithm/fft2
> > >
> > > Anyways, this is besides the point of the question. What you need
> > > to do
> > > Fred,
> > > is create an Img<ComplexFloatType> of the same dimensions as the
> > > two input
> > > stacks. Then you iterate over all pixels of your input using for-
> > > loops while
> > > setting a RandomAccess on the Img<ComplexFloatType> to the
> > > respective
> > > coordinate. There you call randomAccess.get().get() and you can
> > > set the real
> > > and imaginary part of each pixel.
> > >
> > > Hope this helps,
> > > Stephan
> > >
> > > ---
> > >
> > > Dr. Stephan Preibisch
> > > Group Leader
> > >
> > > Berlin Institute for Medical Systems Biology (BIMSB), Max
> > > Delbrück Center
> > > for
> > > Molecular Medicine (MDC)
> > > Building 89, 1.08b
> > > Robert-Rössle-Str. 10
> > > 13125 Berlin
> > >
> > > email:
> > > [hidden email]<mailto:stephan.preibisch@mdc-berl
> > > in.de>
> > > web: http://preibischlab.mdc-berlin.de
> > > twitter: http://twitter.com/preibischs
> > >
> > > On Mar 27, 2018, at 8:39 AM, Herbie
> > > <[hidden email]<mailto:[hidden email]>>
> > > wrote:
> > >
> > > Good day Fred,
> > >
> > > be careful with the ImageJ-2 Fourier-transformation algorithm
> > > because it
> > > doesn't use the classic FFT-algorithm and it shows a number of
> > > peculiarities. See my recent contribution to the forum:
> > > <http://forum.imagej.net/t/help-with-imglib2-algorithm-fft-fourie
> > > rtransform/9946/2>
> > >
> > > I'd recommend to have a look at "Parallel FFTJ" which is a
> > > classic
> > > implementation
> > > <https://sites.google.com/site/piotrwendykier/software/parallelff
> > > tj>
> > > that is able to do 2D and 3D as well as complex input and complex
> > > output.
> > >
> > > Regards
> > >
> > > Herbie
> > >
> > >
> > >
> > > --
> > > Sent from: http://imagej.1557.x6.nabble.com/
> > >
> > > --
> > > 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
--

Stephan Saalfeld, Ph.D.
Group Leader
Janelia Research Campus
19700 Helix Drive | Ashburn, VA 20147
Phone: 571-209-4184 | Fax: 571-209-4946
[hidden email]



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

signature.asc (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: imglib2 FFT and Complex images

Stephan.Preibisch@mdc-berlin.de
In reply to this post by Fred Damen
Hi Fred,

no, that is not the case in FFT2 anymore, you can do forward and reverse FFT’s. The center is assumed to be at 0 in x and 1/2 the size in all other dimensions. Just display a forward FFT to see how it looks.

Yes, you should fill up your kSpace image like that, using a LocalizingCursor instead of a RandomAccess would be maybe easier avoid loops over each dimension.

Otherwise looks good. Let me know if you run into trouble, I wrote this quite some time ago, so I might have to check it out as well for details.

All the best,
Stephan

---

Dr. Stephan Preibisch
Group Leader

Berlin Institute for Medical Systems Biology (BIMSB), Max Delbrück Center for Molecular Medicine (MDC)
Building 89, 1.08b
Robert-Rössle-Str. 10
13125 Berlin

email: [hidden email]<mailto:[hidden email]>
web: http://preibischlab.mdc-berlin.de
twitter: http://twitter.com/preibischs

On Apr 16, 2018, at 2:27 AM, Fred Damen <[hidden email]<mailto:[hidden email]>> wrote:

Greetings Stephan,

Thanks for the information that you provided.  I finally got a chance to work
on this again, and I have a few questions...

From https://imagej.net/ImgLib2_Examples Example 6c, it states that an inverse
FFT can not be performed without a preceding forward FFT.  Is this still the
case with fft2?  MRI starts with kspace (i.e., Fourier domain).

From
https://github.com/imglib/imglib2-algorithm-fft/blob/master/src/test/java/net/imglib2/algorithm/fft2/FFTTest.java
calls FFT.complexToRealUnpad(fft, inverse);
and from related comments i've seen for fft1...

Does fft2 do a unadulterated FFT? As per your comments below I assume that it
only does the vanilla FFT but the aforementioned test code suggests otherwise.
If there is other manipulation of k-space / image space beyond the FFT, how
do I avoid disable it?.

Does fft2 assume the center of k-space is at the center of the dataset or is
the 1/2 FOV / 180 phase shift being ignored in the examples, i.e., I do not
see any pre/post fft shift in any example code I've seen.

From https://imagej.net/ImgLib2_-_Accessors I assume I need to do:
int[] dimensions = new int[] { NX, NY };
Img< ComplexFloatType > kspace = new ArrayImgFactory< ComplexFloatType >()
           .create( dimensions, new ComplexFloatType() );

RandomAccess< ComplexFloatType > r = kspace.randomAccess();
for each kspace value {
 r.setPosition( x, 0 );
 r.setPosition( y, 1 );
 r.get().set(rv,iv);
 }

From your email you suggest that the last line would be r.get().get().set(...);

Then I assume that the fft is simply:
FFT.complexToComplexInverse(kspace);
Img< ComplexFloatType > img = kspace;

Thanks in advance,

Fred

On Tue, March 27, 2018 4:13 am, [hidden email]<mailto:[hidden email]> wrote:
Hi, sorry to disagree but it uses a classic FFT algorithm and it also has been
reimplemented to give access to functionality at any level (with or without
automatic padding):

https://github.com/imglib/imglib2-algorithm-fft/tree/master/src/main/java/net/imglib2/algorithm/fft2
and
https://github.com/imglib/imglib2-algorithm-gpl/tree/master/src/main/java/net/imglib2/algorithm/fft2

Anyways, this is besides the point of the question. What you need to do Fred,
is create an Img<ComplexFloatType> of the same dimensions as the two input
stacks. Then you iterate over all pixels of your input using for-loops while
setting a RandomAccess on the Img<ComplexFloatType> to the respective
coordinate. There you call randomAccess.get().get() and you can set the real
and imaginary part of each pixel.

Hope this helps,
Stephan

---

Dr. Stephan Preibisch
Group Leader

Berlin Institute for Medical Systems Biology (BIMSB), Max Delbrück Center for
Molecular Medicine (MDC)
Building 89, 1.08b
Robert-Rössle-Str. 10
13125 Berlin

email: [hidden email]<mailto:[hidden email]><mailto:[hidden email]>
web: http://preibischlab.mdc-berlin.de<http://preibischlab.mdc-berlin.de/>
twitter: http://twitter.com/preibischs

On Mar 27, 2018, at 8:39 AM, Herbie <[hidden email]<mailto:[hidden email]><mailto:[hidden email]>>
wrote:

Good day Fred,

be careful with the ImageJ-2 Fourier-transformation algorithm because it
doesn't use the classic FFT-algorithm and it shows a number of
peculiarities. See my recent contribution to the forum:
<http://forum.imagej.net/t/help-with-imglib2-algorithm-fft-fouriertransform/9946/2>

I'd recommend to have a look at "Parallel FFTJ" which is a classic
implementation
<https://sites.google.com/site/piotrwendykier/software/parallelfftj>
that is able to do 2D and 3D as well as complex input and complex output.

Regards

Herbie



--
Sent from: http://imagej.1557.x6.nabble.com/

--
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