Hi Jacob,
I think I can help you, but I had to make some guesses about what you wanted based on your description and macro code.
I think the code below does what you want as far as creating the montage. It's not in batch mode yet, but I can get it there pretty easily. I just want to make sure this does what you want before we get into batch processing.
Your method is a little convoluted, but not by much. I modified your code a bit to keep from having to go in and out of stacks so much.
First I grab the name for you and modify it slightly so that the montage is saved as "original name montage.tif" Not knowing your exact file name format it may not come out exactly right, but it can be modified. Then I rearrange the stack to the order (I
think) you want. It should proceed automatically now, with the addition of the "new=" code. If you need a different order, modify the numbers in this line. run("Arrange Channels...", "new=3214");
Then I set up the colors, again guessing based on what I think you want, create the merged image by having the hyperstack spit out an RGB, convert the original hyperstack to RGB as well, add a new blank frame to the end of this hyperstack into which I paste
the merged image (so you don't have to go out of stack, merge and back into stack). Then I make the montage and rename it in preparation for saving.
Does this all make sense to you? Can you modify it to be closer to exactly what you want in terms of colors and names, test and then post/send it back? Then I can help you get the code into batch mode (or you could try this code with the Process --> Batch
--> Macro feature and see if you can automate whole folder processing that way).
Best,
Christine
------------------------begin macro after this line--------------------------
t=getTitle();
s=lastIndexOf(t, '.');
t=substring(t, 0,s);
t=replace(t," ","_");
t2= t +' montage.tif';
run("Images to Stack", "name=Stack title=[] use");
run("Stack to Hyperstack...", "order=xyczt(default) channels=4 slices=1 frames=1 display=Composite");
run("Arrange Channels...", "new=3214");
Stack.setDisplayMode("color");
Stack.setChannel(1);
run("Red");
Stack.setChannel(2);
run("Green");
Stack.setChannel(3);
run("Blue");
Stack.setChannel(4);
run("Magenta");
Stack.setDisplayMode("composite");
run("Stack to RGB");
rename("merge");
selectWindow("Stack");
Stack.setDisplayMode("color");
run("RGB Color");
run("Add Slice");
selectWindow("merge");
run("Copy");
selectWindow("Stack (RGB)");
run("Paste");
run("Make Montage...", "columns=5 rows=1 scale=1 first=1 last=5 increment=1 border=0 font=12");
rename(t2);
------------------------end macro after this line--------------------------
--------------------------------------------
Christine Labno, Ph.D.
Asst. Technical Director
Light Microscopy Core
University of Chicago
Office of Shared Research Facilities
KCBD 1250 900 E. 57th St.
(773) 834-9040 (phone)
________________________________________
From: ImageJ Interest Group [
[hidden email]] on behalf of jacob goodwin [
[hidden email]]
Sent: Monday, February 16, 2015 1:58 PM
To:
[hidden email]
Subject: batch processing macro problem.
Hi everyone,
I have used imagej a bit in the past (not much, and very basic) but I have
absolutely no ideas about how to approach this problem.
We recently had a 384 well, 4 channel microscopy screen performed on drug
treatment of cells. We received data files that were 12bit images, that I
was able to convert to 8bit tiffs so we could view the grey scale images.
(the company has done some analysis, but we still want to view the image
files, to see if we can get any further data from it.
The data is in one folder, and the order of the image files is A1-1 to A1-6,
A2-1 to A2-6 etc
each file name then having the wavelength name at the end (in the following
order)
488
555
647
Dapi
What I would like to do, is pseudo colour all the images, make an overlay,
and then if I am not pushing my luck too far, to make a montage of all the
images while keeping the A1-1 name.
So far I am unable to record a macro that allows me to do this, to keep it
simple first I open the 4 images, then start recording the macro. I convert
the images to a stack, then hyperstack, make it composite with display mode
set to colour. I then Arrange the colours so that they are in the correct
order, split the channels again then merge the images (while keeping the
source images) to create the combined image (which is still in a stack). To
get rid of the stack I convert the merged image to a RGB colour file and
close the merged stack.
This leaves me with 5 open files, four individual colours plus the merged.
I then turn this into a stack, and then create a montage (with 5 columns and
1 row). I then save the montage file, and close down the stack. End the
recording, create and save the macro to the macro folder.
To me this seems a very convoluted process, but I cannot find a simpler
method. If I do this manually as described, I save the image that I want
(the montage of 4+1merge), however, if I open up another 4 images and then
run the macro a number of issues occur.
First the macro stops at the Arrange channels, so I then have to go and
reassign the colours. After that it goes through and makes the montage, but
now all images in the montage are all of one colour (whichever is the first
in the arrange channel)
This also doesn't solve the problem of applying this to the whole folder
If anyone has any ideas that would be great, and I am sorry if anything I
have asked has been solved previously, I was unable to find what I needed.
Cheers
Jacob
This is the macro as it stands now.
run("Images to Stack", "name=Stack title=[] use");
run("Stack to Hyperstack...", "order=xyczt(default) channels=1 slices=4
frames=1 display=Color");
run("Make Composite", "display=Color");
run("Arrange Channels...");
run("Stack to Images");
run("Merge Channels...", "c1=Stack-0003 c2=Stack-0002 c3=Stack-0001
c6=Stack-0004 create keep");
run("RGB Color");
run("Close");
run("Images to Stack", "name=Stack title=[] use");
run("Make Montage...", "columns=5 rows=1 scale=1 first=1 last=5 increment=1
border=0 font=12");
saveAs("Tiff", "C:\\Users\\Jacob\\Desktop\\Montage new macro.tif");
run("Close");
run("Close");
--
View this message in context:
http://imagej.1557.x6.nabble.com/batch-processing-macro-problem-tp5011621.html
Sent from the ImageJ mailing list archive at Nabble.com.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html