-
Notifications
You must be signed in to change notification settings - Fork 0
/
Eva_foci_counting_wholedir_20x_moments_thresh.txt
81 lines (66 loc) · 2.59 KB
/
Eva_foci_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
//Assumes the image is a tif with DAPI in channel1, H2AX in channel2
// It looks for nuclei then counts respective spots for each nucleus.
//All results get stored in a concatenating results file.
//Plus the mask images are stored (all 2 original images converted to masks)
// so you can see what it did.
// altered so find maxima works on raw data,not thresholded.
// var tolerance = 30; removed this and set manually in find maxima.
run("Set Measurements...", "area integrated limit display redirect=None decimal=0");
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...", "title=nuc duplicate channels=2"); //Change this to the DAPI channel slice*******
wait(1000);
setAutoThreshold("Moments dark");
run("Threshold");
run("Watershed");
run("Analyze Particles...", "size=48-2500 circularity=0.04-1.00 exclude add");
run("Blue");
run("16-bit");
//nuclei now added to ROI manager
//next extract h2ax channel
selectWindow(originalImage);
run("Duplicate...", "title=h2ax duplicate channels=1");
wait(1000);
//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=100 output=[Count]");
// run("Find Maxima...", "noise="+tolerance+" output=[Point Selection]");
run("Add Selection...");
}
saveAs("Results", dir2+File.separator+originalImage+"_h2ax.xls"); //This is saving as it goes along in case it crashes
selectWindow(originalImage+"_h2ax");
rename("h2ax2");
run("Enhance Contrast", "saturated=0.35");
selectWindow(originalImage);
wait(1000);
close();
run("Merge Channels...", "c1=h2ax2 c2=nuc create");
rename("masks");
saveAs("TIFF", dir2+File.separator+originalImage+"_ThresholdMasks.tif");
close();
}
setBatchMode(false);
}
showMessage(" Well, I think we gave them a damn good thrashing there, what what??");
// macro