Merge channels problem

imagej
macro

#1

Hey,

I am new to macro writing but I am trying to streamline my work.
The macro I am trying to make should split a time lapse hyperstack into three channels, apply fixed levels to each channel (separately) and stitch them back together into a hyperstack. I was trying to engineer it in such a way that the file name is not lost during processing so a file could be saved with the original file name.

Problem- The macro works until the “Merge Channels…” function.

What I am doing wrong? Thanks :slight_smile:

Here is the code:

macro "Process 26-10-2016 DJW" {
    imageTitle=getTitle();//
    run("8-bit");
    run("Split Channels");
    selectWindow("C1-"+imageTitle);
    setMinAndMax(16, 118);
    call("ij.ImagePlus.setDefault16bitRange", 16);
    run("Apply LUT", "stack");
    selectWindow("C2-"+imageTitle);
    setMinAndMax(3, 78);
    call("ij.ImagePlus.setDefault16bitRange", 16);
    run("Apply LUT", "stack");
    selectWindow("C3-"+imageTitle);
    setMinAndMax(5, 39);
    call("ij.ImagePlus.setDefault16bitRange", 16);
    run("Apply LUT", "stack");
    run("Merge Channels...", "c1=["C3-"+imageTitle] c2=["C2-"+imageTitle] c4=["C1-"+imageTitle] create ignore");
}

#2

Welcome to the forum, @Darren_Wight!

Have a look at the syntax highlighting (which I added to your post to allow spotting the error more easily): your quoting is wrong, leading to an invalid expression instead of proper String concatenation.

This line should probably read:

run("Merge Channels...", "c1=[C3-"+imageTitle +"] c2=[C2-"+imageTitle+"] c4=[C1-"+imageTitle+"] create ignore");

Does that make sense?


#3

Thanks @imagejan, that worked perfectly.

I think I understand my mistake and thanks for the wiki page.