-
Notifications
You must be signed in to change notification settings - Fork 0
/
Synapse_punctae_fromDirList.ijm
74 lines (60 loc) · 2.89 KB
/
Synapse_punctae_fromDirList.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//change dir to folder location with raw unstacked czi files
dir = "/path/to/images";
//change destination to folder where results should be saved
destination = "/path/to/ResultFiles/";
//get list of files in image folder and only select czi files
list = newArray(0);
files = getFileList(dir);
for(i=0;i<files.length;i++){
if(endsWith(files[i],".czi")){
list=Array.concat(list,files[i]);
}
}
setBatchMode(true);
//for loop to process every image file one-by-one
for (k = 0; k < list.length; k++)
{
filename = list[k];
print(filename);
open(filename);
file=getTitle();
dotIndex = indexOf(file, " - ");
file = substring(file, 0, dotIndex);
//this part is analysing the red channel=0 and can be adapted to your prefered protocol
//In this example the red channel is from post-synaptic marker Homer-1
selectWindow(file + " - C=0"); //Red-Homer
run("Z Project...", "projection=[Max Intensity]"); //Max intensity of z-stacks
run("Enhance Contrast...", "saturated=0.35"); //enhance contrast to improve threshold
setAutoThreshold("Moments dark"); //sets threshold and ...
run("Convert to Mask"); //... creates new image with only 0 and 1 intensity values
run("Analyze Particles...", "size=1-Infinity show=Nothing display"); //count ALL particles. Inclusion criteria for particles will be set later in R
selectWindow("Results"); //select Results table window and ...
saveAs("Results", destination + filename + "_HomerResults.csv"); //... saves it with new extension
run("Close"); //closes the results table (!)
close(); //closes the image
//this part is analysing channel=1 and can be adapted to your prefered protocol
//In this example the red channel is from pre-synaptic marker Synapsin-1
selectWindow(file + " - C=1"); //Green-SynapsinI
run("Z Project...", "projection=[Max Intensity]"); //Max intensity of z-stacks
run("Enhance Contrast...", "saturated=0.35"); //enhance contrast to improve threshold
setAutoThreshold("Moments dark"); //sets threshold and ...
run("Convert to Mask"); //... creates new image with only 0 and 1 intensity values
run("Analyze Particles...", "size=1-Infinity show=Nothing display"); //count ALL particles. Inclusion criteria for particles will be set later in R
selectWindow("Results"); //select Results table window and ...
saveAs("Results", destination + filename + "_SynapsinResults.csv"); //... saves it with new extension
run("Close"); //closes the results table (!)
close(); //closes the image
//this part is analysing channel=2 and can be adapted to your prefered protocol
selectWindow(file + " - C=2"); //DAPI
run("Z Project...", "projection=[Max Intensity]");
run("Enhance Contrast...", "saturated=0.35");
setAutoThreshold("Triangle dark");
run("Convert to Mask");
run("Analyze Particles...", "size=1-Infinity show=Nothing display");
selectWindow("Results");
saveAs("Results", destination + filename + "_NucleiResults.csv");
run("Close");
close();
}
print("Finished");
setBatchMode(false);