// HyperVolume Maker // // This macro creates a labeled 4D or 5D stack useful for // testing 4D and 5D viewers and reconstructors such as: // // Built in HyperStack browser added in v1.39e (check "Open in HyperStack Browser") // Image5D - http://rsb.info.nih.gov/ij/plugins/image5d.html // HyperVolume Browser - http://rsb.info.nih.gov/ij/plugins/hypervolume-browser.html // LOCI 4D Browser - http://www.loci.wisc.edu/4d/#browser // TransformJ - http://www.imagescience.org/meijering/software/transformj/ // Hypervolume Shuffler - http://rsb.info.nih.gov/ij/plugins/hypervolume-shuffler.html Dialog.create("HyperVolume"); Dialog.addNumber("Width:", 300); Dialog.addNumber("Height:", 200); Dialog.addNumber("Channels (c):", 3); Dialog.addNumber("Slices (z):",10); Dialog.addNumber("Frames (t):", 5); Dialog.addCheckbox("Open in HyperStack Browser", true); Dialog.show; width = Dialog.getNumber; height = Dialog.getNumber; c = Dialog.getNumber; z = Dialog.getNumber; t = Dialog.getNumber; hypervolume = Dialog.getCheckbox; setBatchMode(true); newImage("HyperVolume", "8-bit", width, height, c*z*t); run("Properties...", "channels="+c+" slices="+z+" frames="+t); showStatus(""); channel=1; slice=1; frame=1; setFont("SansSerif" , 24); setColor(0, 0, 0); for (i=1; i<=nSlices; i++) { showProgress(i, nSlices); setSlice(i); drawString("ch="+pad(channel)+", z="+pad(slice)+", t="+pad(frame), 10, 40); channel++; if (channel>c) { channel = 1; slice++; if (slice>z) { slice = 1; frame++; if (frame>t) frame = 1; } } } setSlice(1); if (hypervolume) { if (getVersion>="1.39e") setOption("OpenAsHyperVolume", true); else showMessage("HyperVolume Opener", "The HyperVolume Browser requires ImageJ "+getVersion+" or later."); } setBatchMode(false); exit; function pad(n) { str = toString(n); while (lengthOf(str)<3) str = "0" + str; return str; } // HS.* functions added in 1.39g if (!HS.isHyperStack) exit("HyperVolume required"); getDimensions(w, h, channels, slices, frames); HS.getPosition(channel, slice, frame); print("Chanels: "+channels); print("Slices: "+slices); print("Frames: "+frames); print("channel="+channel+", slice="+slice+", frame="+frame); for (t=1; t<=frames; t++) { for (z=1; z<=slices; z++) { for (c=1; c<=channels; c++) { HS.setPosition(c, z, t); wait(100); } } } exit; for (i=1; i<=nSlices; i++) { setSlice(i); run("Invert", "slice"); wait(100); }