-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeasure_Intensities.ijm
More file actions
executable file
·99 lines (78 loc) · 2.88 KB
/
Measure_Intensities.ijm
File metadata and controls
executable file
·99 lines (78 loc) · 2.88 KB
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
93
94
95
96
97
98
99
macro "Measure Intensities" {
stackTitle = getTitle();
// Save current settings and then changes the Measurements settings
saveSettings();
run("Set Measurements...", "area mean integrated display redirect=None decimal=1");
// Dialog for measurements option
Dialog.create("Measure Intensities Options");
Dialog.addCheckbox("Reset Spatial Scale", false);
Dialog.addCheckbox("Subtract Automatic Background", true);
Dialog.show();
ResetScale = Dialog.getCheckbox();
SubtractBgnd = Dialog.getCheckbox();
// Resets the spatial scale (all distance will be in pixels)
if (ResetScale == true) {
run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel");
}
// sets the bin size for histogram measurements
if (bitDepth() == 8 || bitDepth() == 24) {
BIN = 256;
}
else if (bitDepth() == 16 || bitDepth() == 32) {
BIN = 65536;
}
// get the ROI number in the ROI manager
ROINUMBER = roiManager("count");
title1 = "" + stackTitle + " results";
title2 = "[" + title1 + "]";
f = title2;
if (isOpen(title1))
print(f, "\\Clear");
else
run("New... ", "name=" + title2 + " type=Table");
Headings = "\\Headings:n\tStack\tSlice#\tSlice\tROI#\tROI\tROI type#\tROI type\tArea/Length\tRaw Mean\tRaw IDt\tStd Dev\tBgrnd\tCorr Mean\tCorr ID";
print(f, Headings);
// loops on ROIs in the ROI manager
for (i = 0; i < ROINUMBER; i++) {
roiManager("select", i);
imTitle = getInfo("slice.label");
imNumber = getSliceNumber();
roiTitle = getInfo("selection.name");
RoiSplit = split(roiTitle, "-");
if (RoiSplit.length > 3) {
Roi.setProperty("TracingType", RoiSplit[3]);
Roi.setProperty("TypeName", RoiSplit[4]);
}
roiType = Roi.getProperty("TracingType");
roiTypeName = Roi.getProperty("TypeName");
roiNumber = i + 1;
getStatistics(roiArea, roiMean, roiMin, roiMax, roiStd, roiHistogram);
roiID = roiArea * roiMean;
if (is("line") == true) {
roiArea = getValue("Length");
}
// Build the Results table line
ResultsLine = ""+ d2s(i + 1, 0) + "\t" + stackTitle + "\t" + imNumber + "\t" + imTitle + "\t" + roiNumber + "\t" + roiTitle + "\t" + roiType + "\t" + roiTypeName + "\t" + roiArea + "\t" + roiMean + "\t" + roiID + "\t" + roiStd;
// gets the histogram mode (intensity value shared by the most pixels in the histogram) as the backgound intensity value
if (SubtractBgnd == true) {
run("Select None");
getHistogram(VAL, COUNTS, BIN);
MAXCOUNT = COUNTS[1];
HISTMODE = 1;
for (j = 2; j < COUNTS.length - 1; j++) {
if (COUNTS[j] > MAXCOUNT) {
MAXCOUNT = COUNTS[j];
HISTMODE = j;
}
}
// Logs the Background intensity and the corrected mean intensity values in the Results table
Bgnd = HISTMODE;
corrMean = roiMean - HISTMODE;
corrID = roiArea * corrMean;
ResultsLine += "\t" + Bgnd + "\t" + corrMean + "\t" + corrID;
}
print(f, ResultsLine);
}
// Restores the previous settings
restoreSettings();
}