-
Notifications
You must be signed in to change notification settings - Fork 0
/
video XOR relative to first.ijm
114 lines (61 loc) · 1.87 KB
/
video XOR relative to first.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
//specify folder
Dialog.create("Specify folder with image stack");
Dialog.addDirectory("Image stack folder", "defaultPath")
Dialog.addString("png stack file names", "pngout");
Dialog.show();
dir = Dialog.getString();
outname = Dialog.getString();
print("directory used:" + dir);
//open file sequence
//File.openSequence(dir);
//getImageInfo();
File.makeDirectory(dir + "\\imgseq");
subdir = dir + "imgseq/";
run("Image Sequence... ", "dir="+subdir+" format=PNG name="+outname);
close();
File.openSequence(dir+ "\\imgseq", "virtual");
//crop
makeRectangle(888, 344, 320, 149);
run("Crop");
//conver to 8-bit in order to run thresehold at 160
run("8-bit");
setThreshold(160, 255, "raw");
//set measurments
run("Set Measurements...", "area display redirect=None decimal=3");
roiManager("reset")
//find particles in stack and add to roi manager
run("Analyze Particles...", "size=500-Infinity display overlay add composite stack");
//get XOR deviation
roiManager("Show None");
roiManager("Select", 0);
// Loop through each slice in the stack and add to end of stack XOR selection
for (i = 1; i < nSlices; ++i) {
roiManager("Select", 0);
roiManager("Select", i);
roiManager("Select", newArray(0,i));
roiManager("XOR");
roiManager("Add");
roiManager("Select", i);
}
run("Clear Results");
numSelections = roiManager("size")
// Loop through each selection and measure and rename
for (i = 0; i < numSelections; i++) {
roiManager("Select", i);
if(i == 0){
roiManager("rename", "Original FIRST")
}
if(i<nSlices){
roiManager("rename", "Original" + i)
roiManager("Set Fill Color", "red");
}
else{
roiManager("rename", "XOR" + i-nSlices+1)
roiManager("Set Fill Color", "yellow");
}
run("Measure");
}
getInfo("selection.name");
//save selections:
roiManager("Save", dir + "RoiSet.zip");
saveAs("Results", dir + "Results.csv");