-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOocytor_individualizeOocytes.ijm
More file actions
76 lines (68 loc) · 2.24 KB
/
Oocytor_individualizeOocytes.ijm
File metadata and controls
76 lines (68 loc) · 2.24 KB
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
// Macro that read a stack containing several oocytes, find them and save individual stack for each oocyte
// author: Gaëlle Letort, Terret/Verlhac team, CIRB, Collège de France
outputInd = 50; // to number the new oocytes
outputName = "fmn"; // name of the oocytes
read = 1; // read .nd files (0) or look for .tif files (1)
run("Bio-Formats Macro Extensions");
run("Close All");
dir = getDirectory("Choose folder to process");
// where to output movies
outputDir = dir + "Out"+ File.separator();
if (!File.isDirectory(outputDir)) {
File.makeDirectory(outputDir);
}
filelist = getFileList(dir);
// Read a .nd file and import each serie
for(i = 0; i < filelist.length; i++) {
if (read==0 & endsWith(filelist[i], ".nd") ) {
file = dir + filelist[i];
outputInd = findOocytesNd(file, outputInd);
}
if (read==1 & endsWith(filelist[i], ".tif") ) {
file = dir + filelist[i];
outputInd = findOocytesTif(file, outputInd);
}
}
function findOocytesNd(filename, ind){
Ext.setId(filename);
seriesCount = 0;
Ext.getSeriesCount(seriesCount); // get number of series
print(seriesCount);
for (s = 0; s < seriesCount; s++) {
Ext.setSeries(s);
run("Bio-Formats Importer", "open=[&filename] autoscale color_mode=Default view=Hyperstack stack_order=XYCZT");
ind = doOneImage(ind);
}
return ind;
}
function findOocytesTif(filename, ind){
open(filename);
return doOneImage(ind);
}
function doOneImage(ind) {
run("8-bit");
// Find each oocyte by threshold of standard deviation projection
run("Z Project...", "projection=[Standard Deviation]");
setAutoThreshold("Mean dark");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Fill Holes");
// erode and dilate to separate neighbors
for ( i = 0; i < 80; i++ ) { run("Erode"); }
for ( i = 0; i < 75; i++ ) { run("Dilate"); }
run("Analyze Particles...", "display exclude clear add");
close();
for ( i=0; i < roiManager("Count"); i++) {
roiManager("Select", i);
//run("Enlarge...", "enlarge=140"); // 20x
run("Enlarge...", "enlarge=170"); // 40x
run("Duplicate...", "duplicate");
run("Select None");
saveAs("Tiff", outputDir+outputName+"_"+(ind)+".tif");
ind = ind + 1;
run("Select None");
close();
}
close();
return ind;
}