-
Notifications
You must be signed in to change notification settings - Fork 5
/
autonomous_neuron_detection.ijm
55 lines (47 loc) · 1.52 KB
/
autonomous_neuron_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
// 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");
// separate GFP from DAPI channel
run("Stack to Images");
selectWindow( final_filename+"-0001"); // DAPI
run("Blue");
// select GFP channel
selectWindow( final_filename+"-0002"); // GFP
// image processing
run("Subtract Background...", "rolling=8");
run("Set Scale...", "distance=0.7752 known=1 pixel=1 unit=µm global");
// machine learning segementation
selectWindow( final_filename+"-0002");
run("Trainable Weka Segmentation");
wait(2000);
selectWindow("Trainable Weka Segmentation v3.2.5");
call("trainableSegmentation.Weka_Segmentation.loadClassifier", "select path");
call("trainableSegmentation.Weka_Segmentation.getResult");
// binarize image
selectWindow("Classified image");
run("Threshold...");
setThreshold(1, 255);
run("Convert to Mask");
run("Make Binary");
run("Watershed");
selectWindow("Trainable Weka Segmentation v3.2.5");
close();
// 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_cells.tif");
close();
}
setBatchMode(false);