-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateBandsQuadrants.ijm
146 lines (128 loc) · 3.96 KB
/
CreateBandsQuadrants.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*Title: Create "sholl" analysis bands from central roi
* Version: V0.1
*
* Short description: A set of bands and quadrants is created from a starting roi
*
* Input:
* ** image file
* ** number of bands and band width
* ** draw or open first (center) roi
*
* Output:
* ** bands/quadrantes roi set
*
* Prerequisites: Run on ImageJ/Fiji v1.53c
*
* This macro should NOT be redistributed without author's permission.
* Explicit acknowledgement to the ALM facility should be done in case of published articles (approved in C.E. 7/17/2017):
*
* "The authors acknowledge the support of i3S Scientific Platform Advanced Light Microscopy,
* member of the national infrastructure PPBI-Portuguese Platform of BioImaging (supported by POCI-01-0145-FEDER-022122)."
*
* Date: March/2021
* Author: Mafalda Sousa, [email protected]
* Advanced Ligth Microscopy, I3S
* PPBI-Portuguese Platform of BioImaging
*/
roiManager("reset");
//check if there's images opened
list = getList("image.titles");
if (list.length == 0) {
Dialog.create("Warning");
Dialog.addMessage("No Image opened!");
Dialog.show();
exit;
}
while (roiManager("count")<1) {
waitForUser("Define the first roi and add it to Manager. Press Ok to continue");
}
roiManager("select", 0);
roiManager("rename", "central roi");
// define the number of rings and bandwidth
Dialog.create("Schwann cells migration")
Dialog.addNumber("Number of bands", 5);
Dialog.addNumber("Band width [px]",15);
Dialog.show();
rings = Dialog.getNumber();
band_width = Dialog.getNumber();
getPixelSize(unit, pixelWidth, pixelHeight);
run("Set Scale...", "distance=0 known=0 unit=pixel");
//warning for to big/much bands
Y = getHeight();
X = getWidth();
if((rings * band_width)>X/2 || (rings * band_width)>Y/2){
Dialog.create("Warning");
Dialog.addMessage("You must define smaller/less bands!");
Dialog.show();
exit;
}
//Add the rings to Roi manager
//setBatchMode("hide");
r = newArray(rings);
t = 0;
for (i = 0; i < rings; i=i+1) {
roiManager("select", t);
run("Enlarge...", "enlarge="+ band_width);
roiManager("add");
roiManager("select", roiManager("count")-1);
t = roiManager("index");
if (i==0)
roiManager("Select", newArray(0,1));
else
roiManager("Select", newArray(t,t-2));
roiManager("XOR");
roiManager("Add");
roiManager("select", roiManager("count")-1);
roiManager("rename", "ring_" + i+1);
r[i] = roiManager("index");
}
number_rois = roiManager("count");
roiManager("select", 0);
raio = getValue("Major");
diameter = round(rings * band_width + raio);
//print(diameter);
roiManager("select", 0);
xm = getValue("X");
ym = getValue("Y");
run("Specify...", "width=" + diameter +" height=" + diameter + " x="+ xm+" y=" +ym);
roiManager("add");
roiManager("select", roiManager("count")-1);
roiManager("rename", "Q4");
x1 = xm - diameter;
y1= ym;
run("Specify...", "width=" + diameter +" height=" + diameter + " x="+ x1+" y=" +y1);
roiManager("add");
roiManager("select", roiManager("count")-1);
roiManager("rename", "Q3");
x2 = xm - diameter;
y2= ym - diameter;
run("Specify...", "width=" + diameter +" height=" + diameter + " x="+ x2+" y=" +y2);
roiManager("add");
roiManager("select", roiManager("count")-1);
roiManager("rename", "Q2");
x3 = xm;
y3= ym - diameter;
run("Specify...", "width=" + diameter +" height=" + diameter + " x="+ x3+" y=" +y3);
roiManager("add");
roiManager("select", roiManager("count")-1);
roiManager("rename", "Q1");
//Define rings inside each quadrant
count_rois = roiManager("count");
for (q = 4; q>0; q--){
ind_Q = count_rois - q;
for (r = 0; r < rings*2; r=r+2 ){
ind_R = count_rois-(rings * 2)-3+r;
roiManager("select", newArray(ind_R,ind_Q));
roiManager("AND");
roiManager("Add");
roiManager("select", roiManager("count")-1);
roiManager("rename", "Q"+ q + "_ring" + r/2);
}
}
for (i = number_rois -1; i > 0 ; i--) {
roiManager("select", i);
roiManager("delete");
}
setBatchMode("exit and display");
roiManager("show all");
//roiManager("save", "bands_quadrantes_set.zip");