-
Notifications
You must be signed in to change notification settings - Fork 1
/
BacteriaInWidefield
54 lines (48 loc) · 1.75 KB
/
BacteriaInWidefield
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
// Files and outputs are found
FileDirectory = getDirectory("image")
name = getTitle();
dotIndex = indexOf(name, ".");
title = substring(name, 0, dotIndex);
dir = getDirectory("image") + "Output/";
Path1 = dir + title + "_outlines"
Path2 = dir + title + "_mask"
Path3 = dir + title + "_results"
// The following are used in various combinations to get best results for threshold of brightfield images
run("Remove Outliers...", "radius=50 threshold=50 which=Dark");
run("Subtract Background...", "rolling=25 light");
run("Smooth"); // This is always pefromed
run("Find Edges");
run("Enhance Contrast", "saturated= 0.35");
// Depending on the quality of the threshold, noise is removed with different methods
setOption("BlackBackground", false);
run("Make Binary"); // This is always pefromed
run("Invert");
run("Despeckle");
run("Erode");
run("Watershed");
// The following are used in various combinations to get best results for threshold of sytox images
run("Auto Threshold", "method=Default dark");
run("Convert to Mask");
run("Invert");
run("Smooth");
run("Auto Threshold", "method=Otsu white");
run("Despeckle");
run("Watershed");
run("Find Edges");
setOption("BlackBackground", true);
run("Make Binary");
run("Close-");
run("Despeckle");
run("Erode");
// The number of bacteria (particles) is found by removing large and small particles
run("Analyze Particles...", "size=2-300 show=Masks display clear");
// Overlapping particles are separated, this is especially important when density is high
run("Watershed");
// The particle size threshold is applied again
run("Analyze Particles...", "size=2-300 show=[Bare Outlines] display clear");
//Results are saved
saveAs("Tiff", Path3);
selectWindow(name);
saveAs("Tiff", Path2);
selectWindow("Results");
saveAs("text", Path3);