-
Notifications
You must be signed in to change notification settings - Fork 1
/
HeartJ_FL_WGA+DAPI+CD31_v8.ijm
177 lines (176 loc) · 5.48 KB
/
HeartJ_FL_WGA+DAPI+CD31_v8.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// HeartJ_FL_WGA+DAPI+CD31_v8.ijm
// Written by Patrick Droste, LaBooratory of Nephropathology, Institute of Pathology and Division of Nephrology and Clinical Immunology, RWTH Aachen University Hospital, Aachen, Germany
// Last updated on 2023 April
//
//This macro measures the size of cardiomyocytes (Group 1) in different parameters on slides stained with WGA+CD31+DAPI. The results are reported in an Excel spreadsheet on the desktop, which contains the individual results as well as an average value. In addition, the size of the nuclei of the cardiomyocytes (Group 2) and the size of capillaries (Group 3) are measured. Furthermore, the number of capillaries bordering each cardiomyocyte is measured.
//
//Required plugins: MorphoLibJ_-1.4.0, Read and Write Excel
//
//Requirements for images: WGA (Channel: Green), Nuclei (DAPI) (Channel: blue), Capillaries (CD31) (Channel: red)
//
//
macro "HeartJ_FL_WGA+DAPI+CD31_v8 [q]" {
a = getTitle();
run("Clear Results");
//
//
//Define as "scale" how many pixels are a micrometer (1µm = "scale" Pixel).
scale = 12.9
//
//Define size thresholds in micrometer
minCardio = 60
maxCardio = 4000
minNuc = 6
maxNuc = 100
minCap = 1.5
maxCap = 100
//
//
run("Set Scale...", "distance=scale known=1 unit=µm global");
run("Duplicate...", "title=Merge");
selectWindow(a);
run("Split Channels");
//Cardiomyocytes segmentation
selectWindow(a+" (green)");
run("Morphological Segmentation");
waitForUser("Define the tolerance value","Find the appropriate tolerance for this image. Enter a tolerance (usually between 10 to 20), click on Run. If the tolerance fits, click OK. If the tolerance does not fit, enter a new tolerance and repeat the process.");
call("inra.ijpb.plugins.MorphologicalSegmentation.setDisplayFormat", "Watershed lines");
wait(4000)
call("inra.ijpb.plugins.MorphologicalSegmentation.createResultImage");
run("Options...", "iterations=1 count=1 black");
rename("Cardiomyocytes Segmentation");
selectWindow("Morphological Segmentation");
run("Close");
selectWindow("Log");
run("Close");
//Manually correction of segmentation
selectWindow("Cardiomyocytes Segmentation");
run("Create Selection");
roiManager("Add");
selectWindow("Merge");
roiManager("Show All");
run("Line Width...", "line=4");
run("Colors...", "foreground=black background=black selection=red");
waitForUser("Correction of segmentation","Correct the segmentation by drawing missing lines and clicking Add in the ROI Manager.");
selectWindow("Cardiomyocytes Segmentation");
//Cardiomyocyte measurement
run("Set Measurements...", "area feret's redirect=None decimal=3");
run("Line Width...", "line=2");
roiManager("Select all");
roiManager("Draw");
roiManager("Delete");
run("Dilate");
run("Invert");
run("Dilate");
run("Dilate");
setThreshold(0, 100);
rename("Cardiomyocytes");
run("Analyze Particles...", "size=minCardio-maxCardio circularity=0.00-1.00 summarize exclude include add");
x = roiManager("count");
for(i=0; i<x; i++) {
roiManager("Select", i);
RoiManager.setGroup(1);
roiManager("Set Color", "magenta");
}
selectWindow(a+" (green)");
close();
selectWindow("Cardiomyocytes");
close();
// Nuclei
selectWindow(a+" (blue)");
rename("Cardiomyocytes nuclei");
RoiManager.selectGroup(1);
roiManager("Combine");
run("Clear Outside");
setAutoThreshold("Huang dark");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Dilate");
run("Dilate");
run("Fill Holes");
run("Erode");
run("Erode");
run("Erode");
run("Analyze Particles...", "size=minNuc-maxNuc exclude summarize add");
c = roiManager("count");
for(i=x; i<c; i++) {
roiManager("Select", i);
RoiManager.setGroup(2);
roiManager("Set Color", "white");
}
selectWindow("Cardiomyocytes nuclei");
run("Close");
//Capillaries
selectWindow(a+" (red)");
rename("Capillaries");
RoiManager.selectGroup(1);
roiManager("Combine");
run("Clear");
run("Maximum...", "radius=6");
setAutoThreshold("IsoData dark no-reset");
setOption("BlackBackground", true);
run("Convert to Mask");
for (i=0; i<10; i++) {
i+1;
run("Dilate");
}
run("Fill Holes");
run("Invert");
for (i=0; i<12; i++) {
i+1;
run("Dilate");
}
run("Invert");
run("Analyze Particles...", "size=minCap-maxCap exclude summarize add");
z = roiManager("count");
for(i=c; i<z; i++) {
roiManager("Select", i);
RoiManager.setGroup(3);
roiManager("Set Color", "yellow");
}
//Summarize
Table.rename("Summary", "Results");
Table.deleteColumn("%Area");
Table.renameColumn("Count", "Amount");
Table.renameColumn("Slice", "Structure");
selectWindow("Merge");
rename(a);
run("Read and Write Excel");
run("Clear Results");
roiManager("select all");
roiManager("multi-measure measure_all");
run("Read and Write Excel");
selectWindow("Results");
run("Close");
//Capillary-Cardiomyocyte relationship
selectWindow("Capillaries");
rename("Capillary-Cardiomyocyte relationship");
selectWindow("Capillary-Cardiomyocyte relationship");
RoiManager.selectGroup(3);
roiManager("Combine");
run("Clear Outside");
run("Select None");
for (i=0; i<(2*scale); i++) {
i+1;
run("Dilate");
}
RoiManager.selectGroup(1);
roiManager("Combine");
run("Clear Outside");
run("Set Measurements...", " redirect=None decimal=3");
for (i=0 ; i<x; i++) {
roiManager("select", i);
run("Analyze Particles...", "size=1-Infinity summarize ");
}
Table.rename("Summary", "Results");
selectWindow("Results");
Table.deleteColumn("%Area");
Table.deleteColumn("Average Size");
Table.deleteColumn("Total Area");
Table.deleteColumn("Slice");
Table.renameColumn("Count", "Capillary contacts");
run("Read and Write Excel");
close("Results");
selectWindow(a);
roiManager("show all without labels");
}