-
Notifications
You must be signed in to change notification settings - Fork 0
/
IJSpotDetection3D.ijm
63 lines (53 loc) · 1.7 KB
/
IJSpotDetection3D.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
// Author: Sébastien Tosi (IRB Barcelona)
// Version: 1.1
// Date: 21/04/2017
// Path to input image and result table
inputDir = "/media/baecker/DONNEES/mri/2019/neubias/data";
outputDir = "/media/baecker/DONNEES/mri/2019/neubias/out";
// Functional parameters
ij_radius = 2.5;
ij_threshold = -2;
arg = getArgument();
parts = split(arg, ",");
setBatchMode(true);
for(i=0; i<parts.length; i++) {
nameAndValue = split(parts[i], "=");
if (indexOf(nameAndValue[0], "input")>-1) inputDir=nameAndValue[1];
if (indexOf(nameAndValue[0], "output")>-1) outputDir=nameAndValue[1];
if (indexOf(nameAndValue[0], "radius")>-1) ij_radius=nameAndValue[1];
if (indexOf(nameAndValue[0], "threshold")>-1) ij_threshold=nameAndValue[1];
}
images = getFileList(inputDir);
for(i=0; i<images.length; i++) {
image = images[i];
if (endsWith(image, ".tif")) {
// Open image
open(inputDir + "/" + image);
run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel");
// Processing
run("Set Measurements...", " center stack redirect=None decimal=2");
run("FeatureJ Laplacian", "compute smoothing="+d2s(ij_radius,2));
rename("Flt");
run("Minimum (3D)");
rename("Min");
imageCalculator("Subtract create stack", "Flt","Min");
setThreshold(0, 0);
run("Convert to Mask", "method=Default background=Dark");
rename("Msk");
selectImage("Flt");
setThreshold(-9999, ij_threshold);
run("Convert to Mask", "method=Default background=Dark");
imageCalculator("And stack", "Flt","Msk");
run("Analyze Particles...", "display clear stack");
// Export results
save(outputDir + "/" + image);
// Cleanup
run("Close All");
if(isOpen("Results"))
{
selectWindow("Results");
run("Close");
}
}
}
run("Quit");