-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path170915_circle_roi_mask.ijm
85 lines (71 loc) · 1.97 KB
/
170915_circle_roi_mask.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
/*
* Circle ROI masking
* Artur Yakimovich (c) copyright 2017. UCL
*/
function regexReplacePy(inString, pattern){
scritp = "import re"//+
// "p = re.compile("+pattern+""
eval("python", script);
return outString
}
function getAllOpenWindows(returnType){
names = newArray(nImages);
ids = newArray(nImages);
print("number of open Imgages is: " + nImages);
for (i=0; i < ids.length; i++){
selectImage(i+1);
ids[i] = getImageID();
names[i] = getTitle();
print(ids[i] + " = " + names[i]);
}
if(returnType=="ids"){
return ids;
}
else if(returnType=="names"){
return names;
}
}
function getDirAndFileList(ReadPath, filePattern, listType){
//listType = "dir" or "file", file default
list = getFileList(ReadPath);
//clean up the file list
dirList = newArray();
fileList = newArray();
for(i=0; i<=list.length-1; i++){
if (endsWith(list[i], "/"))
dirList = Array.concat(dirList, list[i]);
else if (matches(list[i], filePattern))
fileList = Array.concat(fileList, list[i]);
}
if (listType == "dir"){
return dirList;
}
else if (listType == "file"){
return fileList;
}
else {
return fileList;
}
}
inDir = getDirectory("Select the input folder...");
setBatchMode(true);
files = getDirAndFileList(inDir, ".*.tif", "file");
outDir = inDir + File.separator + "movies_masked";
File.makeDirectory(outDir);
for (iFiles=0; iFiles < files.length; iFiles++){
print (files[iFiles]);
//open an image from the list
open(files[iFiles]);
getRawStatistics(nPixels, mean, min, max, std, histogram);
makeOval(78, -10, 524, 524);
run("Make Inverse");
run("Multiply...", "value=0.000 stack");
run("Add Specified Noise...", "stack standard=10");
run("Add...", "value="+d2s(min-10,0)+" stack");
run("Select None");
//run("Add...", "value=80 slice");
title = getTitle();
print("Saving: "+outDir+File.separator+title);
saveAs("Tiff", outDir+File.separator+title);
}
print ("end");