-
Notifications
You must be signed in to change notification settings - Fork 241
/
zvi2HyperStack.txt
89 lines (82 loc) · 1.76 KB
/
zvi2HyperStack.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
// zvi2HyperStack.txt
// Written by Sebastien Huart
// Last updated on 2008 May 6
// Reads in a ZVI file using Bio-Formats, synthesizes the LUT using
// emission wavelength metadata, and displays the result as a hyperstack.
//arbitrary boundary wavelength for each channel...
var luts=newArray(470,540,615);
//wavelength->LUT name
function asLut(wl)
{
retstr="";
if (wl<luts[0])
{
retstr="Blue";
}
else if ((wl>=luts[0]) && (wl<luts[1]))
{
retstr="Green";
}
else if (wl>=luts[1])
{
retstr="Red";
}
else
{
retstr="Grays";
}
return retstr;
}
function zviToHS(path)
{
run("Bio-Formats Macro Extensions");
Ext.setId(path);
print("path set to:"+path);
showStatus("reading metadata");
MAXNWL=10;
nwl=0;
Ext.getSizeC(nwl);
emwl=newArray(nwl);
print("sizeC:"+nwl);
wlidx=0;
for(i=0;i<MAXNWL;i++)
{
field="Emission Wavelength "+i;
val="";
Ext.getMetadataValue(field,val);
if (val != 0)
{
emwl[wlidx]=val;
wlidx++;
}
}
dimOrder="";
Ext.getDimensionOrder(dimOrder);
Ext.getSizeT(numT);
print("sizeT:"+numT);
Ext.getSizeZ(numZ);
print("sizeZ:"+numZ);
options="open=["+path+"] view=[Standard ImageJ] stack_order="+dimOrder+" autoscale";
showStatus("opening file");
run("Bio-Formats Importer",options);
order=toLowerCase(dimOrder);
if(order=="xyczt")
order=order+"(default)";
run("Stack to Hyperstack...", "order="+order+" channels="+nwl+" slices="+numZ+" frames="+numT+" display=Color");
id=getImageID();
for(i=1;i<=nwl;i++)
{
progress=i/nwl;
Stack.setChannel(i);
LUT=asLut(emwl[i-1]);
print("Channel "+i+":"+LUT);
run(LUT);
}
Ext.close();
return id;
}
macro "zviOpen [F1]"
{
path=File.openDialog("Choose ZVI file")
zviToHS(path);
}