-
Notifications
You must be signed in to change notification settings - Fork 5
/
autonomous_pixel_detection.ijm
59 lines (45 loc) · 1.55 KB
/
autonomous_pixel_detection.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
// choose folders for batch process
mainDir = getDirectory("Choose a main directory ");
mainList = getFileList(mainDir);
output = getDirectory("Choose were to save it");
setBatchMode(true);
// loop through every file
for (i=0; i<mainList.length; i++) {
path = mainDir + mainList[i];
open(path);
if (bitDepth() != 8){
run("8-bit");
}
length = lengthOf(mainList[i])-4;
final_filename = substring(mainList[i],0,length);
run("Remove Slice Labels");
// settings for 1024x1024 confocal images
run("Set Scale...", "distance=1 known=1.4 pixel=1 unit=µm global");
// settings for 512x512 confocal images
//run("Set Scale...", "distance=0.3303 known=1 pixel=1 unit=µm");
// separate GFP from DAPI channel
run("Stack to Images");
selectWindow( final_filename+"-0002");
run("Enhance Contrast...", "saturated=1.0");
// select GFP channel
selectWindow( final_filename+"-0001");
// Hessian ridge detection to segment axons out
run("FeatureJ Hessian", "largest absolute smoothing=0.5");
//thresholding image Isodata 0,5
selectWindow( final_filename+"-0001 largest Hessian eigenvalues");
run("8-bit");
setAutoThreshold("IsoData");
run("Threshold...");
setThreshold(0, 25);
run("Convert to Mask");
run("Make Binary");
// increase contrast in original gfp image
selectWindow( final_filename+"-0001");
run("Enhance Contrast...", "saturated=0.3");
// combine DAPI + GFP + segmented image into one stack
run("Images to Stack", "name=Stack title=[] use");
selectWindow("Stack");
saveAs("Tiff", output+"\\"+final_filename +"_stack_with_segmented_axons.tif");
close();
}
setBatchMode(false);