-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_MetaMorph_dual_stacks.ijm
More file actions
88 lines (49 loc) · 1.95 KB
/
split_MetaMorph_dual_stacks.ijm
File metadata and controls
88 lines (49 loc) · 1.95 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
76
77
78
79
80
81
82
83
84
85
86
87
88
//===============================================
// Lin Yangchen
// NUS Centre for Bioimaging Sciences
// 29 June 2023
//===============================================
//takes a folder containing one or more subfolders of tif and nd files
//there should be only one level of subfolders
//a subfolder can contain multiple nd datasets
//folder and file names should not contain spaces or special characters
//splits left channel from right and merges them into hyperstack
//currently works only on images of 2400 x 1200 pixels
//left side becomes channel 1, right side channel 2
//currently does not assign LUTs according to metadata; please set LUTs yourself
//leaves original files untouched
//===============================================
input = getDirectory("choose folder");
//replace backslashes with forward slashes (if using Windows)
input = replace(input, "\\", "/");
setBatchMode(true); //do not display images during execution
subdirs = getFileList(input);
for (j = 0; j < subdirs.length; j++)
{
output = input + subdirs[j];
filelist = getFileList(output);
count = 0;
for (i = 0; i < filelist.length; i++)
{
if (endsWith(filelist[i], ".TIF") || endsWith(filelist[i], ".tif"))
{
count = count + 1;
print("processing image " + count + " in /" + subdirs[j] + " subfolder");
open(output + filelist[i]);
name = File.nameWithoutExtension;
rename("duplicate1");
run("Duplicate...", "title=duplicate2 duplicate");
makeRectangle(0, 0, 1200, 1200); //crop left half
run("Crop");
selectWindow("duplicate1");
makeRectangle(1200, 0, 1200, 1200); //crop right half
run("Crop");
//merge channels
run("Merge Channels...", "c1=duplicate2 c2=duplicate1 create");
saveAs("Tiff", output + "merged_" + filelist[i]);
run("Close All");
run("Collect Garbage");
}
} //end of file loop
} //end of subdirectory loop
print("job done");