HELP - Changing image focus in between macro calls

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

HELP - Changing image focus in between macro calls

Daniel Kalthoff
Dear Community,

I am facing a problem with irreproducible behaviour of ImageJ macro calls involving resizing, cropping, duplicating etc.
It seems that some of these routines silently change the focus, i.e. the image processed will loose the focus and subsequent calls will erroneously manipulate another image. I am running ImageJ 1.45g on a MacBook with MacOS 10.6.7. I have, however, also faced similar problems on Windows systems.

I have put together a short macro that illustrates the problem:

> run("Bat Cochlea Volume (19K)");
> run("MRI Stack (528K)");
> run("Size...", "width=100 height=121 depth=20 constrain average interpolation=Bilinear");
> write(getTitle());

After a couple of runs (subsequently closing all open images after each run), the log window looks like this

> mri-stack.tif
> mri-stack.tif
> bat-cochlea-volume.tif
> bat-cochlea-volume.tif
> bat-cochlea-volume.tif
> mri-stack.tif
> mri-stack.tif
> mri-stack.tif
> bat-cochlea-volume.tif

Any ideas?

Thanks in advance!

Daniel
Reply | Threaded
Open this post in threaded view
|

Re: HELP - Changing image focus in between macro calls

Albert Cardona-2
2011/5/9 Daniel Kalthoff <[hidden email]>:

> Dear Community,
>
> I am facing a problem with irreproducible behaviour of ImageJ macro calls involving resizing, cropping, duplicating etc.
> It seems that some of these routines silently change the focus, i.e. the image processed will loose the focus and subsequent calls will erroneously manipulate another image. I am running ImageJ 1.45g on a MacBook with MacOS 10.6.7. I have, however, also faced similar problems on Windows systems.
>
> I have put together a short macro that illustrates the problem:
>
>> run("Bat Cochlea Volume (19K)");
>> run("MRI Stack (528K)");
>> run("Size...", "width=100 height=121 depth=20 constrain average interpolation=Bilinear");
>> write(getTitle());
>
> After a couple of runs (subsequently closing all open images after each run), the log window looks like this
>
>> mri-stack.tif
>> mri-stack.tif
>> bat-cochlea-volume.tif
>> bat-cochlea-volume.tif
>> bat-cochlea-volume.tif
>> mri-stack.tif
>> mri-stack.tif
>> mri-stack.tif
>> bat-cochlea-volume.tif
>
> Any ideas?
>
> Thanks in advance!


You could do it in python, so that you always know which image you are
manipulating:

cochlea = IJ.openImage("http://imagej.nih.gov/ij/images/bat-cochlea-volume.zip")
IJ.run(cochlea, "Size...", "width=100 height=121 depth=20 constrain
average interpolation=Bilinear")

mri = IJ.openImage("http://imagej.nih.gov/ij/images/mri-stack.zip")
IJ.run(mri, "Size...", "width=100 height=121 depth=20 constrain
average interpolation=Bilinear")


See examples in python:
http://www.ini.uzh.ch/~acardona/fiji-tutorial/
http://pacific.mpi-cbg.de/wiki/index.php/Jython_Scripting

Albert

--
http://albert.rierol.net
http://www.ini.uzh.ch/~acardona/
Reply | Threaded
Open this post in threaded view
|

Re: HELP - Changing image focus in between macro calls

Krs5
In reply to this post by Daniel Kalthoff
Hi Daniel,

For your example the only way to solve this problem seems to be to use:

selectWindow("mri-stack.tif");

I noticed that the combination:
 
id = getImageID();
selectImage(id);

or

wait(1000);

does not solve the problem.

Best wishes

Kees


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Daniel Kalthoff
Sent: 09 May 2011 14:14
To: [hidden email]
Subject: HELP - Changing image focus in between macro calls

Dear Community,

I am facing a problem with irreproducible behaviour of ImageJ macro calls involving resizing, cropping, duplicating etc.
It seems that some of these routines silently change the focus, i.e. the image processed will loose the focus and subsequent calls will erroneously manipulate another image. I am running ImageJ 1.45g on a MacBook with MacOS 10.6.7. I have, however, also faced similar problems on Windows systems.

I have put together a short macro that illustrates the problem:

> run("Bat Cochlea Volume (19K)");
> run("MRI Stack (528K)");
> run("Size...", "width=100 height=121 depth=20 constrain average interpolation=Bilinear");
> write(getTitle());

After a couple of runs (subsequently closing all open images after each run), the log window looks like this

> mri-stack.tif
> mri-stack.tif
> bat-cochlea-volume.tif
> bat-cochlea-volume.tif
> bat-cochlea-volume.tif
> mri-stack.tif
> mri-stack.tif
> mri-stack.tif
> bat-cochlea-volume.tif

Any ideas?

Thanks in advance!

Daniel
Reply | Threaded
Open this post in threaded view
|

Re: HELP - Changing image focus in between macro calls

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Daniel Kalthoff
On May 9, 2011, at 9:13 AM, Daniel Kalthoff wrote:

> Dear Community,
>
> I am facing a problem with irreproducible behaviour of ImageJ macro calls involving resizing, cropping, duplicating etc.
> It seems that some of these routines silently change the focus, i.e. the image processed will loose the focus and subsequent calls will erroneously manipulate another image. I am running ImageJ 1.45g on a MacBook with MacOS 10.6.7. I have, however, also faced similar problems on Windows systems.
>
> I have put together a short macro that illustrates the problem:
>
>> run("Bat Cochlea Volume (19K)");
>> run("MRI Stack (528K)");
>> run("Size...", "width=100 height=121 depth=20 constrain average interpolation=Bilinear");
>> write(getTitle());
>
> After a couple of runs (subsequently closing all open images after each run), the log window looks like this
>
>> mri-stack.tif
>> mri-stack.tif
>> bat-cochlea-volume.tif
>> bat-cochlea-volume.tif
>> bat-cochlea-volume.tif
>> mri-stack.tif
>> mri-stack.tif
>> mri-stack.tif
>> bat-cochlea-volume.tif
>
> Any ideas?

Thanks to Michael Schmid, this bug is fixed in the 1.45h3 daily build. You can upgrade by using the Help>Update ImageJ command and selecting "daily build" from the drop down menu.

-wayne