-
Notifications
You must be signed in to change notification settings - Fork 2
/
RLF_Macro.ijm
92 lines (79 loc) · 1.96 KB
/
RLF_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
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
//This script automatically runs the analysis for the Radiation versus Light Field QA Test
//Would like to improve the accuracy of the distance calculation
//Threshold position accuracy could be improved
run("Close All");
print("\\Clear");
roiManager("reset");
run("Open...");
setLocation(0,0);
img_name = getInfo("image.filename");
print(img_name);
w = getWidth();
nt = 30;
sig = 6;
//Quick emperical threshold sets
if (w == 1024)
{
mm_px = 0.5597/2;
//sig = 6;
}
else
{
mm_px = 0.5597;
//sig = 3;
}
run("Duplicate...", "title=findEdge.dcm");
run("Duplicate...", "title=findBBs.dcm");
selectWindow("findBBs.dcm");
//Find the BB's in the image
run("Find Maxima...", "noise="+nt+" output=[Single Points]");
//run("Create Mask");
run("Gaussian Blur...", "sigma="+sig); //attempt to eliminate the delta shaped BB's
setThreshold(1, 4);
//run("Invert");
//setAutoThreshold("Triangle");
run("Create Mask");
run("Analyze Particles...", "size=1-infinity circularity=0.95-1.00 show=Masks exclude add");
//Find the field edge in the image
selectWindow("findEdge.dcm");
setAutoThreshold("Default");
run("Create Mask");
run("Distance Map");
//run("Exact Euclidean Distance Transform (3D)");
//index into distance map to find distances to each BB
cnt = roiManager("count");
for (i = 0; i < cnt; i++)
{
roiManager("select",i);
List.setMeasurements;
//get the centroid position
x = List.getValue("X");
y = List.getValue("Y");
dist = getPixel(x,y)*mm_px;
reg_idx = i + 1;
if (dist > 20 && dist < 30)
{
if (dist < 24.0 || dist > 26.0)
{
print("P" + reg_idx + " Distance = " + dist + " mm <> *FAIL*");
}
else
{
print("P" + reg_idx + " Distance = " + dist + " mm <> PASS");
}
}
}
//Clean up windows
run("Close");
selectWindow("findBBs.dcm");
run("Close");
selectWindow("findBBs.dcm Maxima");
run("Close");
selectWindow("findEdge.dcm");
run("Close");
selectWindow("Mask of mask");
run("Close");
selectWindow("mask");
setLocation(600,0);
selectWindow("Log");
setLocation(0,450);