This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
forked from GogollaLab/tracing_quantification_and_analysis
-
Notifications
You must be signed in to change notification settings - Fork 1
/
counting_RV.ijm
95 lines (73 loc) · 2.55 KB
/
counting_RV.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Choose image, roiset, and where to save it
filepath=File.openDialog("Select a File");
output = getDirectory("Choose were to save it");
file=File.openAsString(filepath);
open(filepath);
filename = File.getName(filepath);
section ="";
bregma="";
// Define Section number and Distance from Bregma
Dialog.create("Define Section ")
Dialog.addString("section number", section);
Dialog.addString("Distance from Bregma", bregma);
Dialog.show();
section = Dialog.getString();
bregma = Dialog.getString();
type= "no";
title ="";
roi ="";
run("Set Measurements...", "area centroid display nan redirect=None decimal=3");
// wait for user, adjust ROIs manually
title_1 = "WaitForUserDemo";
msg = "Adjust ROIs ";
waitForUser(title_1, msg);
run("Stack to Images");
selectWindow("Classified image");
setAutoThreshold("Default dark");
run("Threshold...");
setThreshold(0, 0);
run("Convert to Mask");
// find out how many ROIs there are, get the name from each roi; analyze only as many as there are
n = roiManager("count");
for (i=0; i<n; i++) {
roiManager("select", i);
roi_name = call("ij.plugin.frame.RoiManager.getName", i);
// get roi_area and add to results
getStatistics(area, mean);
// run particle analyzer to count cells
run("Analyze Particles...", "size=70-1000 circularity=0.30-1.0 display summarize slice");
}
// save excel file with the data for every single cell
selectWindow("Results");
saveAs("Results", output+"\\" +bregma + "_" +section + "_" +roi+"_single_cells.xls");
// save summary table; read, fill the results window, save this window
selectWindow("Summary");
text = getInfo("window.contents");
lines = split(text, "\n");
labels = split(lines[0], "\t");
run("Clear Results");
for (k=1; k<lines.length; k++) {
items=split(lines[k], "\t");
setResult("Label", k-1, items[0]);
for (j=1; j<labels.length; j++)
setResult(labels[j], k-1, items[j]);
}
// change the results table. Replace Total Area value with the true total ROI area and replace cryptic image name with ROI name
n = roiManager("count");
for (i=0; i<n; i++) {
roiManager("select", i);
roi_name = call("ij.plugin.frame.RoiManager.getName", i);
getStatistics(area, mean);
setResult("Total Area", i, area);
setResult("Label", i, roi_name);
}
updateResults();
selectWindow("Results");
saveAs("Results", output+"\\" +bregma + "_" +section + "_" +roi+"_summary.xls");
selectWindow("Results");
run("Close");
selectWindow("ROI Manager");
run("Close");
selectWindow("Summary");
run("Close");
run("Close All");