HELP: Plugin and Macro Development Question

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

HELP: Plugin and Macro Development Question

Michael Miller
Hello everyone!

I have a question about ImageJ plug-in and macro scripting, but let me
give you a bit of background before asking.  I've been working on a
Vascular Network Toolkit that will be used to perform image processing
and analysis on (hopefully) all sorts of in vitro vasculogenesis
experiments.  

The goals for my project (which will be completed and announced
officially in the upcoming weeks) are:
1) Polynomial Lighting Correction - useful for images taken with
irregular lighting
(such as
http://vh216202.truman.edu/imageweb/images/HUVECwinhib040622at24hrsE642z2.jpg)
2) Automatic Vessel Segmentation (tested with Matrigel assays)
3) Skeletonization using the Blum Medial Axis Transform
4) Quantification of various properties - network lengths, enclosed mesh
areas, total area of the network, etc.
5) Graph Theoretic Analysis - nodes and adjacencies for vascular network
reliability

In testing my toolkit I've encountered some inconsistant behavior which
has been baffling me lately. My problem is that it seems certain
commands are running out of order. I am running ImageJ 1.33u at work and
1.34p at home, both are on Debian Linux machines.

I first observed this when running seven or so of my custom plug-ins in
a macro. I get lots of "The image is locked." errors as it appears all
the plug-ins attempt to run at about the same time when called from a macro.

I call the series of plugins I've written with the following command in
macro:
run("Compile and Run...", "compile="+pluginPath+"My_First_Plugin.java");
run("Compile and Run...", "compile="+pluginPath+"My_Second_Plugin.java");
.. etc..

Some of these plugins require several seconds of intensive CPU calculations.
I've noticed that they tend to run without allowing the first to finish,
and this generates the "locked" errors.

Also, in some of my plug-ins (implements PlugInFilter) for example:
// I use the NewImage static method to create a new ImagePlus
// and I put image stuff in it
beforethinImp.show();
// I make a copy of the image
afterthinImp.show();
// and this is what behaves strangely
IJ.run("Skeletonize");

And sometimes the beforethinImp is the image that ImageJ performs the
Binary->Skeletonize command on instead of the afterthinImp!

In addition, at the end of all this I perform:
finalImp.show();
IJ.save("/home/whatever/somefile.tif");

And finalImp is not always saved, but instead some other previous images
is saved.

What's odd is that this behavior is inconsistant.  Sometimes everything
runs in proper order and other times it seems to run out of sync. It
seems to depend on how busy the server I am VNC'ing into is at the time
of the plugin execution.

Are these all related to the IJ.* calls? Am I just calling things at the
wrong level?

Thank you for your time and for any consideration and advice you can offer.

-Michael D. Miller
[hidden email]
Truman State University
Reply | Threaded
Open this post in threaded view
|

Re: HELP: Plugin and Macro Development Question

Gabriel Landini
On Friday 29 July 2005 22:08, Michael Miller wrote:
> I call the series of plugins I've written with the following command in
> macro:
> run("Compile and Run...", "compile="+pluginPath+"My_First_Plugin.java");
> run("Compile and Run...", "compile="+pluginPath+"My_Second_Plugin.java");
> .. etc..

You should not call the plugin for *compilation* each time. Once you have the
class file, call it by its name (or use the macro/plugin recorder to see how
to pass the parameters if the plugin has a dialog).

> Some of these plugins require several seconds of intensive CPU
> calculations. I've noticed that they tend to run without allowing the first
> to finish, and this generates the "locked" errors.

Sure these are separate threads, I guess that one compilation may not be
finieshed by the time the next one is called. Just call the class files, not
the "compile & run" command.
So: compile the plugin, restart IJ, now you can call the class by its name.

> Also, in some of my plug-ins (implements PlugInFilter) for example:
> // I use the NewImage static method to create a new ImagePlus
> // and I put image stuff in it
> beforethinImp.show();
> // I make a copy of the image
> afterthinImp.show();
> // and this is what behaves strangely
> IJ.run("Skeletonize");
> And sometimes the beforethinImp is the image that ImageJ performs the
> Binary->Skeletonize command on instead of the afterthinImp!

The plugInFilter, acts on the file that was selected when you called (and
locks it). Implement the procedure as a PlugIn instead and use
IJ.selectWindow("my_image") befor calling the next command.

> In addition, at the end of all this I perform:
> finalImp.show();
> IJ.save("/home/whatever/somefile.tif");
>
> And finalImp is not always saved, but instead some other previous images
> is saved.

Same reason, I guess.

I hope it helps

Gabriel