-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBatchGetLHSections.txt
More file actions
69 lines (62 loc) · 1.84 KB
/
Copy pathBatchGetLHSections.txt
File metadata and controls
69 lines (62 loc) · 1.84 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
// "BatchGetLHSections"
//
// This macro batch processes all the PIC files in a folder
// It first merges 01-02 channels and then generated 4 slices through LH.
// (Slightly) Adapted by Sebastian from code at
// http://rsb.info.nih.gov/ij/macros/BatchProcessFolders.txt
// jefferis@gmail.com
requires("1.33s");
dir = getDirectory("Choose a stacks directory");
//outputDir = getDirectory("Choose output directory");
outputDir="";
setBatchMode(true);
count = 0;
countFiles(dir);
print("Total files: "+count);
n = 0;
processFiles(dir, outputDir);
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,outputDir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
processFiles(""+dir+list[i], outputDir);
else {
showProgress(n++, count);
processFile(dir,outputDir,list[i]);
}
}
}
function processFile(dir,outputDir,file01) {
if ((endsWith(file01, ".nrrd") || endsWith(file01,".NRRD")) && indexOf(file01,"_01") > 0 ) {
path01 = dir + file01;
file02 = substring(file01,0,indexOf(file01,"_01"))+"_02"+substring(file01,(indexOf(file01,"_01")+3),lengthOf(file01));
path02 = dir+file02;
open(path01);
title01=getTitle();
print(title01);
open(path02);
title02=getTitle();
print(title02);
mergeComm="red=["+title01+"] green=["+title02+"] blue=*None* gray=*None*";
print(mergeComm);
run("Merge Channels...", mergeComm);
for( i=0 ; i<4 ; i++ ) {
roiManager("Open", "/Users/jefferis/Desktop/PictureDimorphicClones/RoiSet.zip");
roiManager("Select", i);
run("Copy");
run("Internal Clipboard");
saveAs("Tiff", dir+substring(file01,0,lengthOf(file01)-5) + "_" + i + ".tif");
close();
}
close();
}
}