-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMPI-macro.ijm
39 lines (37 loc) · 1.09 KB
/
MPI-macro.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
// Root fluorescent mean pixel intensity (MPI)
// threshold image to identify roots
// create mask
// quantify MPI of original image
// used to remove roi from prior runs
// will trigger an error if there is not an ROI in the manager before running (can add arbitrary roi to fix)
roiManager("Deselect");
roiManager("Delete");
// assign unique image id to each open image
setBatchMode(true);
imgArray = newArray(nImages);
for (i=0; i<nImages; i++) {
selectImage(i+1);
imgArray[i] = getImageID();
}
Array.print(imgArray);
prevNumResults = nResults;
// threshold, mask, and measure
for (i=0; i< imgArray.length; i++) {
selectImage(imgArray[i]);
filename = getTitle();
run("Duplicate...", " ");
run("Gaussian Blur...", "sigma=2");
setAutoThreshold("Otsu dark");
getThreshold(lower,upper);
setThreshold(lower,upper);
run("Convert to Mask");
run("Create Selection");
roiManager("Add");
roiManager("Select", i);
roiManager("Rename", filename);
selectImage(imgArray[i]);
roiManager("Select", i);
run("Measure");
setResult("File", prevNumResults+i, filename);
}
String.copyResults();