dir = getDirectory("Choose a Directory to PROCESS");
list = getFileList(dir);
dir2 = getDirectory("Choose a Directory for SAVING the Total Cell Image");
dir3 = getDirectory("Choose a Directory for SAVING the GFP Cell Image");
setBatchMode(true);
for (f=0; f<list.length; f++) {
path = dir+list[f];
print(path);
showProgress(f, list.length);
if (!endsWith(path,"/")) open(path);
if (nImages>=1) {
if (endsWith(path,"f")) {
t=getTitle();
s=lastIndexOf(t, '.');
ts=substring(t, 0,s);
ts2= t +'total.tif';
ts3= t +'gfp.tif';
//open("FOLDER NAMEf"); {
run("Split Channels");
selectWindow(t+"(blue)");
//run("Brightness/Contrast...");
setMinAndMax(0, 50);
//run("Close");
//run("Enhance Contrast...", "saturated=2 normalize");
//run("Find Edges");
run("Set Measurements...", "area standard area_fraction limit redirect=None decimal=1");
name(getTitle()
selectWindow(name)
setAutoThreshold("Default dark");
//run("Threshold...");
setThreshold(0, 193);
//run("Measure");
data - newArray(""+getResult("area_standard")+"", ""+getResult("area_fraction")+"");
}
selectWindow(t + " (blue)");
rename(ts2);
saveAs("Tiff", dir2 + ts2 + ".tif");
run("Close");
selectWindow(t + " (green)");
rename(ts3);
saveAs("Tiff", dir3 + ts3 + ".tif");
run("Close");
selectWindow("Results");
dotIndex = "s";
if (dotIndex!=-1);
path = substring(path, 0, dotIndex); // remove extension
save(path+"-results.txt");
close()
run("Close All");
}
}
}
Date: Wed, 26 Nov 2014 12:25:33 -0800
From:
[hidden email]To:
[hidden email]Subject: Re: Batch splitting of stacks and saving
Hello Christina,
This code should do what you want, holding the name of the file under the variable t and then using ImageJ's habit of naming split images "original name (blue)", etc. to select the image to process. Just set up the two folders for saving the blue and the green images before you run the macro so that you can select them when the macro asks for them. It will only ask for the folders once before batch processing all.
May I suggest that between yoursetThreshold command and your Measure command you insert some code to tell the macro what you want to measure and whether or not you want the measurements limited to the thresholded area (record under Analyze --> Set Measurements).
Kind Regards,
Christine
---------------------begin code-----------------
dir = getDirectory("Choose a Directory to PROCESS");
list = getFileList(dir);
dir2 = getDirectory("Choose a Directory for SAVING the BLUE Image");
dir3 = getDirectory("Choose a Directory for SAVING the GREEN Image");
setBatchMode(true);
for (f=0; f<list.length; f++) {
path = dir+list[f];
print(path);
showProgress(f, list.length);
if (!endsWith(path,"/")) open(path);
if (nImages>=1) {
if (endsWith(path,"f")) {
t=getTitle();
s=lastIndexOf(t, '.');
ts=substring(t, 0,s);
ts2= t +'blue image.tif';
ts3= t +'green image.tif';
//open("FOLDER NAMEf");
run("Split Channels");
selectWindow(t + " (blue)");
//run("Brightness/Contrast...");
setMinAndMax(0, 50);
//run("Close");
run("Enhance Contrast...", "saturated=2 normalize");
run("Find Edges");
setAutoThreshold("Default dark");
//run("Threshold...");
setThreshold(0, 193);
run("Measure");
rename(ts2);
saveAs("Tiff", dir2 + ts2 + ".tif");
run("Close");
selectWindow(t + " (green)");
rename(ts3);
saveAs("Tiff", dir3 + ts3 + ".tif");
run("Close");
run("Close All");
}
}
}
---------------------end code----------------
--------------------------------------------
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 cmparkes [
[hidden email]]
Sent: Wednesday, November 26, 2014 9:21 AM
To:
[hidden email]
Subject: Re: Batch splitting of stacks and saving
Hello I am having a similar problem.
I have Images which I want to split into the three colour channels. I have
worked out the commands that I would like to be performed on the green and
blue images once they have been split, but when it comes to putting it into
a batch command process I don't know how to change my code so that it will
apply to all of the images in the directory I want to use and select the
blue image to do the following steps with.
This is what I would like to happen to the BLUE images:
open("FOLDER NAMEf");
run("Split Channels");
selectWindow[THIS IS WHERE I THINK I NEED TO PUT THE FILE NAME OF THE SPLIT
WINDOW???]
//run("Brightness/Contrast...");
setMinAndMax(0, 50);
run("Close");
run("Enhance Contrast...", "saturated=2 normalize");
run("Find Edges");
setAutoThreshold("Default dark");
//run("Threshold...");
setThreshold(0, 193);
run("Measure");
I would then like the Green and Blue images to be saved to separate
directorys and discard the red image.
I am not a programmer so any help would be greatly appreciated.
Thanks,
Christina
--
View this message in context:
http://imagej.1557.x6.nabble.com/Batch-splitting-of-stacks-and-saving-tp4578247p5010643.htmlSent 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
To unsubscribe from Batch splitting of stacks and saving,
click here.
NAML