-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfoci_and_coloc_counting_wholedir_20x_moments_thresh.txt
107 lines (89 loc) · 3.45 KB
/
foci_and_coloc_counting_wholedir_20x_moments_thresh.txt
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
100
101
102
103
104
//Assumes the image is a MIP'ed tif with PML in channel1, H2AX in channel2
//(although these can be the other way round and it doesn't matter too much except for labelling in results)
//and DAPI in channel3. It looks for pure overlap and counts respective spots.
//All results get stored in a concatenating results file.
//Plus the mask images are stored (all 3 original images converted to masks plus the coloc maskin the 4th channel)
// so you can see what it did.
var tolerance = 30;
run("Set Measurements...", "area integrated limit display redirect=None decimal=3");
dir1 = getDirectory("Choose folder with tif files ");
list = getFileList(dir1);
setBatchMode(true);
// create folders for the tifs
dir1parent = File.getParent(dir1);
dir1name = File.getName(dir1);
dir2 = dir1parent+File.separator+dir1name+"_masks";
if (File.exists(dir2)==false) {
File.makeDirectory(dir2); // new directory for mask images
}
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
print("processing ... "+i+1+"/"+list.length+"\n "+list[i]);
filename = dir1 + list[i];
if (endsWith(filename, "tif")) {
path=dir1+list[i];
run("Bio-Formats Importer", "open="+filename+" autoscale color_mode=Default view=Hyperstack stack_order=XYCZT");
originalImage = getTitle();
roiManager("Reset");
selectWindow(originalImage);
run("Duplicate...", "duplicate channels=1"); //Change this to the DAPI channel slice*******
// run("8-bit");
setAutoThreshold("Moments dark");
run("Threshold");
run("Watershed");
// run("Entropy Threshold");
run("Analyze Particles...", "size=120-2500 circularity=0.04-1.00 exclude add");
rename("nuc");
//nuclei now added to ROI manager
//next find pml bodies
selectWindow(originalImage);
run("Duplicate...", "title=PML duplicate channels=3");
// run("8-bit");
setAutoThreshold("Triangle dark");
run("Threshold");
// rename("PML");
//next find h2ax foci
selectWindow(originalImage);
run("Duplicate...", "title=h2ax duplicate channels=2");
wait(1000);
// run("8-bit");
setAutoThreshold("MaxEntropy dark");
run("Threshold");
// rename("h2ax");
//Next find colocalised PML-H2AX foci
imageCalculator("Multiply create", "h2ax","PML");
selectWindow("Result of h2ax");
rename(originalImage+":coloc");
run("Grays");
for(j=0; j<roiManager("count"); j++) {
roiManager("select", j);
run("Find Maxima...", "noise="+tolerance+" output=[Count]");
// run("Find Maxima...", "noise="+tolerance+" output=[Point Selection]");
run("Add Selection...");
}
// saveAs("Results", dir2+File.separator+originalImage+"_nuc_coloc.xls");
//next find H2AX foci per nuc
selectWindow("h2ax");
rename(originalImage+":h2ax");
for(j=0; j<roiManager("count"); j++) {
roiManager("select", j);
run("Find Maxima...", "noise="+tolerance+" output=[Count]");
// run("Find Maxima...", "noise="+tolerance+" output=[Point Selection]");
run("Add Selection...");
}
saveAs("Results", dir2+File.separator+originalImage+"_nuc_coloc_and_h2ax.xls"); //This is savign as it goes along in case it crashes
selectWindow(originalImage+"h2ax");
rename("h2ax");
selectWindow(originalImage+"coloc");
rename("coloc");
selectWindow(originalImage);
close();
run("Merge Channels...", "c1=PML c2=h2ax c3=nuc c4=coloc create");
rename("masks");
saveAs("TIFF", dir2+File.separator+originalImage+"_colocmasks.tif");
close();
}
setBatchMode(false);
}
showMessage(" Well, I think we gave them a damn good thrashing there, what what??");
// macro