Batch processing of 4 color Z stack images

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

Batch processing of 4 color Z stack images

cas229
Hello- I'm looking for help on macro coding. I have done the macro recorder
and this works as needed but I would like to figure out a way to do batch
processing of multiple images. I only want to analyze 2 of the color
channels in the z stack. Could someone help guide me on the correct coding
terms to get multiple images processed without having to retype the file
names each time? I've read the batch processing guidelines on imageJ but am
still confused. I'm getting stuck on how to handle different window names
and different files (example: "SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif
copy - Series009 - C=1" is one channel and
"SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 - C=0" is the
other of interest, but those names would be different for each file and each
z stack image: Each series is a z stack-
SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif- Series009 ... then there is
Series010, Series011 and so on...)

Any help making this macro more streamlined and less complication is VERY
much appreciated.

Thank you!

Colleen



open("/Users/colleensilky/Desktop/PhD Files/TBI-organoid IHC
repeat/SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy");
close();
selectWindow("SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 -
C=1");
close();
selectWindow("SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 -
C=0");
run("Z Project...", "projection=[Max Intensity]");
run("Median...", "radius=1");
run("Subtract Background...", "rolling=10");
run("Duplicate...", "title=[MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif
copy - Series009 - Mask]");
setAutoThreshold("Otsu dark");
//run("Threshold...");
//setThreshold(68, 255);
setOption("BlackBackground", true);
run("Convert to Mask");
run("Create Selection");
run("Create Mask");
saveAs("ZIP", "/Users/colleensilky/Desktop/Fiji Results/Results1/Mask
control 01 ROI.zip");
selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
Series009 - Mask");
roiManager("Add");
selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
Series009 - C=0");
setAutoThreshold("Otsu dark");
//run("Threshold...");
run("From ROI Manager");
run("Analyze Particles...", "pixel show=Overlay exclude clear add");
roiManager("Measure");
saveAs("Results", "/Users/colleensilky/Desktop/Fiji Results/Results1/Results
control 1 Homer.csv");
saveAs("Tiff", "/Users/colleensilky/Desktop/Fiji
Results/Results1/MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
Series009 - C=0.tif");
selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
Series009 - Mask");
selectWindow("SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 -
C=0");
selectWindow("SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 -
C=2");
run("Z Project...", "projection=[Max Intensity]");
run("Median...", "radius=1");
run("Subtract Background...", "rolling=10");
run("Duplicate...", "title=[MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif
copy - Series009 - C=2-mask]");
setAutoThreshold("Otsu dark");
//run("Threshold...");
//setThreshold(46, 255);
run("Convert to Mask");
run("Create Selection");
run("Create Mask");
saveAs("ZIP", "/Users/colleensilky/Desktop/Fiji Results/Results1/Mask
control 02 ROI.zip");
selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
Series009 - C=2-mask");
roiManager("Add");
selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
Series009 - C=2");
setAutoThreshold("Otsu dark");
//run("Threshold...");
run("From ROI Manager");
run("Analyze Particles...", "pixel show=Overlay exclude clear add");
roiManager("Measure");
saveAs("Results", "/Users/colleensilky/Desktop/Fiji Results/Results1/Results
control 1 SYT1.csv");
saveAs("Tiff", "/Users/colleensilky/Desktop/Fiji
Results/Results1/MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
Series009 - C=2.tif");
run("Close All");



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch processing of 4 color Z stack images

Aryeh Weiss
Hi Colleen,

Here are a few tips to help you get started:

Code snippet to prompt for filename:


// prompt for the input file and open the  image
inputPath =File.openDialog("input file");
print("image path: ", inputPath);
inputFIleName = File.getName(inputPath);
print(" name: ", inputFileName);
open(inputPath);
inputTitle = getTitle();    // save the image title in a variable

// remove any overlay if the image was saved with an overlay
run("Remove Overlay");

// it is often useful to have the dimensions of your images
getDimensions(width, height, channels, slices, frames);
print(width, height, channels, slices, frames);


The selectWindow lines can be removed. Before you operate on an image,
it is good practice to select that image.
For example, to make sure you are working on the input image, do:

selectImage(inputTitle);

If you duplicate the image, you might use the original image title
modified, like this:

run("Duplicate...", "title=["+inputTitle+"_dup]");

so that the new image will have the original name with "_dup" attached.
Notice you can use string variables in the argument.

Another tip is that your input image may have a long and awkward name,
so you may choose to rename it

selectImage(inputTitle);
rename("my_favorite_name");

Use Help>Macro Functions... to find all of the macro functions, and Help>Macros... to find lots of useful examples.

Hope this helps,
--aryeh

On 07/04/2019 15:59, cas229 wrote:

> Hello- I'm looking for help on macro coding. I have done the macro recorder
> and this works as needed but I would like to figure out a way to do batch
> processing of multiple images. I only want to analyze 2 of the color
> channels in the z stack. Could someone help guide me on the correct coding
> terms to get multiple images processed without having to retype the file
> names each time? I've read the batch processing guidelines on imageJ but am
> still confused. I'm getting stuck on how to handle different window names
> and different files (example: "SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif
> copy - Series009 - C=1" is one channel and
> "SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 - C=0" is the
> other of interest, but those names would be different for each file and each
> z stack image: Each series is a z stack-
> SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif- Series009 ... then there is
> Series010, Series011 and so on...)
>
> Any help making this macro more streamlined and less complication is VERY
> much appreciated.
>
> Thank you!
>
> Colleen
>
>
>
> open("/Users/colleensilky/Desktop/PhD Files/TBI-organoid IHC
> repeat/SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy");
> close();
> selectWindow("SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 -
> C=1");
> close();
> selectWindow("SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 -
> C=0");
> run("Z Project...", "projection=[Max Intensity]");
> run("Median...", "radius=1");
> run("Subtract Background...", "rolling=10");
> run("Duplicate...", "title=[MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif
> copy - Series009 - Mask]");
> setAutoThreshold("Otsu dark");
> //run("Threshold...");
> //setThreshold(68, 255);
> setOption("BlackBackground", true);
> run("Convert to Mask");
> run("Create Selection");
> run("Create Mask");
> saveAs("ZIP", "/Users/colleensilky/Desktop/Fiji Results/Results1/Mask
> control 01 ROI.zip");
> selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
> Series009 - Mask");
> roiManager("Add");
> selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
> Series009 - C=0");
> setAutoThreshold("Otsu dark");
> //run("Threshold...");
> run("From ROI Manager");
> run("Analyze Particles...", "pixel show=Overlay exclude clear add");
> roiManager("Measure");
> saveAs("Results", "/Users/colleensilky/Desktop/Fiji Results/Results1/Results
> control 1 Homer.csv");
> saveAs("Tiff", "/Users/colleensilky/Desktop/Fiji
> Results/Results1/MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
> Series009 - C=0.tif");
> selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
> Series009 - Mask");
> selectWindow("SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 -
> C=0");
> selectWindow("SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy - Series009 -
> C=2");
> run("Z Project...", "projection=[Max Intensity]");
> run("Median...", "radius=1");
> run("Subtract Background...", "rolling=10");
> run("Duplicate...", "title=[MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif
> copy - Series009 - C=2-mask]");
> setAutoThreshold("Otsu dark");
> //run("Threshold...");
> //setThreshold(46, 255);
> run("Convert to Mask");
> run("Create Selection");
> run("Create Mask");
> saveAs("ZIP", "/Users/colleensilky/Desktop/Fiji Results/Results1/Mask
> control 02 ROI.zip");
> selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
> Series009 - C=2-mask");
> roiManager("Add");
> selectWindow("MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
> Series009 - C=2");
> setAutoThreshold("Otsu dark");
> //run("Threshold...");
> run("From ROI Manager");
> run("Analyze Particles...", "pixel show=Overlay exclude clear add");
> roiManager("Measure");
> saveAs("Results", "/Users/colleensilky/Desktop/Fiji Results/Results1/Results
> control 1 SYT1.csv");
> saveAs("Tiff", "/Users/colleensilky/Desktop/Fiji
> Results/Results1/MAX_SYT-Hom-MAP2-150DIV-Org8-1-Ctrl-170918.lif copy -
> Series009 - C=2.tif");
> run("Close All");
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html