-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path3DStitch.txt
126 lines (102 loc) · 3.93 KB
/
3DStitch.txt
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
file = getArgument;
dir="";
outputDir="";
// arg = newArray(9);
arg = split(file,",");
print(file);
dir = arg[0];
outdir = arg[1];
Stacks = arg[2];
finalName = arg[3];
xmlpath = arg[4];
xmlstr=File.openAsString(xmlpath);
xmllines=split(xmlstr,"\n");
channelsfound=0;
for(l=0;l<xmllines.length;l++){
if(startsWith(xmllines[l],"<DimensionChannels")) {
firstCloseBracket=indexOf(xmllines[l],">");
secondOpenBracket=indexOf(xmllines[l],"<",1);
channelsfound=substring(xmllines[l],firstCloseBracket+1,secondOpenBracket);
}
}
// A simple while loop for opening up the appropriate number of nrrds
stackSplits = split(Stacks,":");
x=0;
while (x<stackSplits.length){
run("Nrrd ...", "load="+dir+stackSplits[x]);
x++;
}
if (channelsfound==1) {
run("Nrrd ...", "load="+dir+stackSplits[0]);
run("Nrrd ...", "load="+dir+stackSplits[1]);
print("stitching " +stackSplits[0]+ " and " +stackSplits[1]);
run("3D Stitching", "first_stack=["+stackSplits[0]+
"] use_channel_for_first=[Red, Green and Blue] second_stack=["+stackSplits[1]+
"] use_channel_for_second=[Red, Green and Blue] use_windowing peaks=5 create_fused_image fusion_method=[Linear Blending] fusion=1.50 fused_image_name="
+finalName+" number_of_other_channels=1 compute_overlap x=0 y=0 z=0");
setKeyDown("alt");
run("Nrrd ... ", "nrrd="+outdir+finalName+"-stitched_01.nrrd");
setKeyDown("none");
close();
close();
close();
}
if(channelsfound==2) {
finalName02=finalName+"02";
run("Nrrd ...", "load="+dir+stackSplits[0]);
run("Nrrd ...", "load="+dir+stackSplits[1]);
run("Nrrd ...", "load="+dir+stackSplits[2]);
run("Nrrd ...", "load="+dir+stackSplits[3]);
print("stitching " +stackSplits[0]+ " and " +stackSplits[1]);
run("3D Stitching", "first_stack=["+stackSplits[0]+
"] use_channel_for_first=[Red, Green and Blue] second_stack=["+stackSplits[1]+
"] use_channel_for_second=[Red, Green and Blue] use_windowing peaks=5 create_fused_image fusion_method=[Linear Blending] fusion=1.50 fused_image_name="
+finalName+" apply_to_other_channels number_of_other_channels=1 compute_overlap x=0 y=0 z=0 first_image_stack_1=["+stackSplits[2]+
"] second_image_stack_1=["+stackSplits[3]+"] fused_image_name_1="+finalName02);
selectWindow(finalName);
setKeyDown("alt");
run("Nrrd ... ", "nrrd="+outdir+finalName+"-stitched_01.nrrd");
setKeyDown("none");
selectWindow(finalName02);
setKeyDown("alt");
run("Nrrd ... ", "nrrd="+outdir+finalName+"-stitched_02.nrrd");
setKeyDown("none");
close();
close();
close();
close();
}
if(channelsfound==3) {
finalName02=finalName+"02";
finalName03=finalName+"03";
run("Nrrd ...", "load="+dir+stackSplits[0]);
run("Nrrd ...", "load="+dir+stackSplits[1]);
run("Nrrd ...", "load="+dir+stackSplits[2]);
run("Nrrd ...", "load="+dir+stackSplits[3]);
run("Nrrd ...", "load="+dir+stackSplits[4]);
run("Nrrd ...", "load="+dir+stackSplits[5]);
print("stitching " +stackSplits[0]+ " and " +stackSplits[1]);
run("3D Stitching", "first_stack=["+stackSplits[0]+
"] use_channel_for_first=[Red, Green and Blue] second_stack=["+stackSplits[1]+
"] use_channel_for_second=[Red, Green and Blue] use_windowing peaks=5 create_fused_image fusion_method=[Linear Blending] fusion=1.50 fused_image_name="
+finalName+" apply_to_other_channels number_of_other_channels=2 compute_overlap x=0 y=0 z=0 first_image_stack_1=["+stackSplits[2]+
"] second_image_stack_1=["+stackSplits[3]+"] fused_image_name_1="+stackSplits[4]+
"first_image_stack_2=["+stackSplits[5]+"] second_image_stack_2=["+stackSplits[6]+"] fused_image_name_2="+finalName03);
selectWindow(finalName);
setKeyDown("alt");
run("Nrrd ... ", "nrrd="+outdir+finalName+"-stitched_01.nrrd");
setKeyDown("none");
selectWindow(finalName02);
setKeyDown("alt");
run("Nrrd ... ", "nrrd="+outdir+finalName+"-stitched_02.nrrd");
setKeyDown("none");
selectWindow(finalName03);
setKeyDown("alt");
run("Nrrd ... ", "nrrd="+outdir+finalName+"-stitched_03.nrrd");
setKeyDown("none");
close();
close();
close();
close();
close();
}