-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTip_Length_Extraction.ijm
74 lines (71 loc) · 1.82 KB
/
Tip_Length_Extraction.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
dir = getDirectory("Choose a Directory ");
orgdir = dir;
maskedval = "65535";
count = 0;
countFiles(dir);
n = 0;
macrodir = getDirectory("imagej");
runMacro(macrodir+"replace_files.ijm", dir);
processFiles(dir);
print(count+" files processed");
function countFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
countFiles(""+dir+list[i]);
else
count++;
}
}
function processFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/")) {
processFiles(""+dir+list[i]);
// print(list[i]);
}
else {
//showProgress(n++, count);
path = dir+list[i];
processFile(path);
// print(list[i]);
}
}
}
function processFile(path) {
scanpath = newArray();
if (matches(path, ".*new.*")) {
scanpath = Array.concat(scanpath, path);
}
for (i=0; i<scanpath.length;i++) {
tipspath = scanpath[i];
// print(tipspath);
findtipslength(tipspath);
}
}
function findtipslength(tipspath) {
filestring=File.openAsString(tipspath);
dirpath = File.directory;
rows=split(filestring, "\n");
x = newArray();
y = newArray();
//print(rows.length);
for(i=0; i<rows.length; i++){
columns=split(rows[i],"\t");
x = Array.concat(x, columns[0]);
y = Array.concat(y, columns[1]);
}
//Array.print(x);
//Array.print(y);
index = 0;
for (j=0; j<y.length;j++) {
if (y[j] == maskedval ) {
break;
}
index++;
}
savelog = dir +"tips_results.txt";
savelog2 = orgdir + "overall_tips_results.txt";
File.append(x[index-1], savelog);
File.append(x[index-1], savelog2);
}