run("Z Project...","projection=[MAX Intensity]"); doesnt open the MAX file

Hi everybody,
I wrote a Macro which should open all files of one folder and process them as Z project MAX intensity. Normally this command should open a “MAX_…” picture where all layers are overlayed. Maybe it is a stupid mistake, but my macro is opening the pictures and it says “Z project” and counts up, but it doesn’t open the “MAX_…”, it just continues with closing the original picture…I hope somebody can help me!

dir1 = getDirectory(“Choose Source Directory”);
list = getFileList(dir1)
for (i=0; i<list.length; i++)
if (File.isDirectory(dir1+list[i])){}
path = dir1+list[i];
if (endsWith(path, “.db”)){}

		run("Bio-Formats", "open=[path] autoscale color_mode=Custom open_all_series split_channels view=Hyperstack stack_order=XYCZT use_virtual_stack series_0_channel_0_red=0 series_0_channel_0_blue=255 series_0_channel_1_red=255 series_0_channel_1_blue=0 series_1_channel_0_red=0 series_1_channel_0_blue=255 series_1_channel_1_red=255 series_1_channel_1_blue=0");

                            title = File.nameWithoutExtension;

selectWindow(title+".vsi - TRITC, FITC, DAPI - C=0");
run(“Z Project…”, “projection=[Max Intensity]”);
saveAs(“JPEG”, title+“red.jpg”);
selectWindow(title+".vsi - TRITC, FITC, DAPI - C=0");

Thanks in advance ;D

I believe it is because you have setBatchMode(true). When in batchmode, opening an image does not open a new image window. If you want to see unclosed images after the script has finished, use setBatchMode("exit and display"). If the script exits while still in batchmode, it automatically exits batchmode and disposes of all hidden images.

Thanks!! You are right, this was the problem =) Now I have a new problem, I defined a title, so it can do the whole folder. After he did the MAX files, the macro should overly them. My macro recognizes the title+".vsi - TRITC, FITC, DAPI - C=0", but how do I have to write it for the MAX image? I tryed this, but the macro tells me that this is invalid for c1:

run(“Merge Channels…”, “c3=[(MAX_ + title + .vsi - TRITC, FITC, DAPI - C=2] c1=[MAX_ + title + .vsi - TRITC, FITC, DAPI - C=0] c2=[MAX_ +title+ .vsi - TRITC, FITC, DAPI - C=1] create”);
saveAs(“JPEG”, title+“merged.jpd”);

Thanks again in advance =)

Is what you posted the entire macro? I suspect what is happening is that you are not using the correct name. When you use saveAs, it also changes the name of the window. For example, let’s say you have a window named Image1.png and then do saveAs("JPEG", "Image2.jpg"). The window’s name would change from Image1.png to Image2.jpg.

Also, I think run("Red") is just a display thing. I don’t think it actually does anything to the values. You could probably remove it if you want. Well, unless that is the point of resaving it.

Thanks, this is a good tip, but this was not the problem. I found the problem now:

I wrote:
run(“Merge Channels…”, “c3=[(MAX_+title+.vsi - TRITC, FITC, DAPI - C=2)]…
But it has to be in the “MergeChannels” function like this:
run(“Merge Channels…”, “c3=[(MAX_"+title+".vsi - TRITC, FITC, DAPI - C=2)]…

Thanks anyway!! =)