Macro programming

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

Macro programming

karo03
Hi ImageJ gurus and Java experts,
I need some help in macro programming:

Goal: reading in a hyperstack, Z projecting it and preparing a simple  
display:

        open();
        id=getImageID();
        run("Z Project...", "projection=[Average Intensity]");
        idavg=getImageID();
        for (i=1; i<nSlices(); i++) {
                setSlice(i);
                run("Enhance Contrast", "saturated=0.5");
        }
        run("Channels...","Composite [Channel 1] [Channel 2] [Channel 3]");
        run("Stack to RGB","[Convert to RGB]");

The last two commands are not well formed. I have difficulties to  
deduce from the GUI comming up the necessary options. The macro  
recording does not wait for the add. options and gives only  
run("Channels...");

I would like to select three channels and convert them to RGB.  
"Composite" is seemingly an accepted option, but what about the  
channels. The actual peace of code delivers an RGB image with channel  
3 only.

Any help is appreciated
Regards
Karsten Rodenacker
Reply | Threaded
Open this post in threaded view
|

Re: Macro programming

Wayne Rasband
This example macro opens the "Organ of Corti" sample hyperstack, Z
projects it, contrast enhances the first two channels, disable channel
4, and converts to RGB. It requires the v1.41b daily build, which adds
the Stack.setActiveChannels() macro function and updates the "Enhance
Contrast" command to work with composite color images.

    requires("1.41b");
    setBatchMode(true);
    run("Organ of Corti (2.8M, 4D stack)");
    run("Z Project...", "projection=[Average Intensity]");
    Stack.setChannel(1);
    run("Enhance Contrast", "saturated=0.25");
    Stack.setChannel(2);
    run("Enhance Contrast", "saturated=1.0");
    Stack.setActiveChannels("1110");
    run("Stack to RGB");
    setBatchMode(false);

-wayne

On Apr 30, 2008, at 3:13 AM, Karsten Rodenacker wrote:

> Hi ImageJ gurus and Java experts,
> I need some help in macro programming:
>
> Goal: reading in a hyperstack, Z projecting it and preparing a simple
> display:
>
> open();
> id=getImageID();
> run("Z Project...", "projection=[Average Intensity]");
> idavg=getImageID();
> for (i=1; i<nSlices(); i++) {
> setSlice(i);
> run("Enhance Contrast", "saturated=0.5");
> }
> run("Channels...","Composite [Channel 1] [Channel 2] [Channel 3]");
> run("Stack to RGB","[Convert to RGB]");
>
> The last two commands are not well formed. I have difficulties to
> deduce from the GUI comming up the necessary options. The macro
> recording does not wait for the add. options and gives only
> run("Channels...");
>
> I would like to select three channels and convert them to RGB.
> "Composite" is seemingly an accepted option, but what about the
> channels. The actual peace of code delivers an RGB image with channel
> 3 only.
>
> Any help is appreciated
> Regards
> Karsten Rodenacker
>