-
Notifications
You must be signed in to change notification settings - Fork 0
/
cell_area_measurement.ijm
47 lines (42 loc) · 1.51 KB
/
cell_area_measurement.ijm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// ask user to select a folder
dir = getDirectory("Select A folder");
// get the list of files (& folders) in it
fileList = getFileList(dir);
// prepare a folder to output the images
output_dir = dir + File.separator + "output" + File.separator ;
File.makeDirectory(output_dir);
//activate batch mode
setBatchMode(true);
// LOOP to process the list of files
for (i = 0; i < lengthOf(fileList); i++) {
// define the "path"
// by concatenation of dir and the i element of the array fileList
current_imagePath = dir+fileList[i];
// check that the currentFile is not a directory
if (!File.isDirectory(current_imagePath)){
open(current_imagePath);
currentImage_name = getTitle();
selectWindow(currentImage_name);
// select which channel you want to process by specifying the name
if (endsWith(currentImage_name, "ch00.tif")){
// convert greyscale image to binary
setOption("BlackBackground", true);
run("Convert to Mask");
// remove noise by setting outliers
run("Remove Outliers...", "radius=2 threshold=50 which=Bright");
setAutoThreshold("Default dark no-reset");
// run("Threshold...");
// setThreshold(255, 255);
run("Convert to Mask");
// set the measurement to calculate the area of white
run("Set Measurements...", "area limit redirect=None decimal=3");
// measure the area
run("Measure");
saveAs("tiff", output_dir+currentImage_name);
run("Close All");
}
}
}
setBatchMode(false);
//save the results if access is permitted
saveAs("Results", output_dir);