File: HyperStackMaker.txt

package info (click to toggle)
imagej 1.46a-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,248 kB
  • sloc: java: 89,778; sh: 311; xml: 51; makefile: 6
file content (98 lines) | stat: -rw-r--r-- 3,175 bytes parent folder | download | duplicates (2)
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
// This macro implements the Image>HyperStacks>New HyperStack command.

  defaults = "8-bit Color 300 200 3 10 5 1";
  if (is("applet"))
      prefs = split(defaults);
  else
      prefs = split(call("ij.Prefs.get", "hyperstack.new", defaults));
  if(prefs.length<8) prefs = split(defaults);
  type = prefs[0];
  mode = prefs[1];
  width = parseInt(prefs[2]);
  height = parseInt(prefs[3]);
  c = parseInt(prefs[4]);
  z = parseInt(prefs[5]);
  t = parseInt(prefs[6]);
  label = parseInt(prefs[7]);
  title = "HyperStack";
  Dialog.create("HyperStack");
  Dialog.addString("Title:", title);
  Dialog.addChoice("Type:", newArray("8-bit", "16-bit", "32-bit", "RGB"), type);
  Dialog.addChoice("Display Mode:", newArray("Composite", "Color", "Grayscale"), mode);
  Dialog.addNumber("Width:", width);
  Dialog.addNumber("Height:", height);
  Dialog.addNumber("Channels (c):", c);
  Dialog.addNumber("Slices (z):", z);
  Dialog.addNumber("Frames (t):", t);
  Dialog.addCheckbox("Label Images", label);
  Dialog.show;
  title = Dialog.getString();
  type = Dialog.getChoice();
  mode = Dialog.getChoice();
  width = Dialog.getNumber;
  height = Dialog.getNumber;
  c = Dialog.getNumber;
  z = Dialog.getNumber;
  t = Dialog.getNumber;
  label = Dialog.getCheckbox;
  batch = is("Batch Mode");
  if (!batch) setBatchMode(true);
  if (label)
     type2 = type + " ramp";
  else
     type2 = type + " black";
  newImage(title, type2, width, height, c*z*t);
  run("Properties...", "channels="+c+" slices="+z+" frames="+t);
  showStatus("");
  channel=1; slice=1; frame=1;
  setFont("SansSerif", 24);
  if (label) {
     yloc = 30;
     for (i=1; i<=nSlices; i++) {
         showProgress(i, nSlices);
         setSlice(i);
         setColor(0, 0, 0);
         fillRect(0, 0, width, yloc);
         fillRect(0, yloc+15, width, height-(yloc+15));
         setColor(255, 255, 255);
         drawString("c="+pad(channel)+", z="+pad(slice)+", t="+pad(frame), 5, yloc);
         //setMetadata("slice", "c="+pad(channel)+", z="+pad(slice)+", t="+pad(frame));
         if (i<=c) {
             setFont("SansSerif", 12, "antialiased");
             msg = "Press shift-z (Image>HyperStacks>Channels)\n"+
                         "to open the \"Channels\" window, which will\n"+
                         "allow you switch to composite color mode\n"+
                         "and to enable/disable channels.\n";
            drawString(msg, 25, 80);
             setFont("SansSerif", 24);
         }
         channel++;
         if (channel>c) {
             channel = 1;
             slice++;
             if (slice>z) {
                 slice = 1;
                 frame++;
                 if (frame>t) frame = 1;
             }
         }
     }
  }
  setSlice(1);
  if (c>1 && bitDepth!=24)
     run("Make Composite", "display="+mode);
  setOption("OpenAsHyperStack", true);
  if (!batch) setBatchMode(false);
  prefs = type+" "+mode+" "+width+" "+height+" "+c+" "+z+" "+t+" "+label;
  if (!is("applet"))
      call("ij.Prefs.set", "hyperstack.new", prefs);
  exit;


  function pad(n) {
      str = toString(n);
      while (lengthOf(str)<3)
          str = "0" + str;
      return str;
  }