Login  Register

Re: Running scripts with an open Virtual Hyperstack

Posted by Rasband, Wayne (NIH/NIMH) [E] on Mar 25, 2015; 10:07pm
URL: http://imagej.273.s1.nabble.com/Running-scripts-with-an-open-Virtual-Hyperstack-tp5012163p5012177.html

> On Mar 25, 2015, at 9:51 AM, Greg <[hidden email]> wrote:
>
> Hi,
>
> today I witnessed a rather odd behavior of Fiji when trying to run my jython
> scripts on a opened virtual hyperstack. So basically it took ages to run my
> script so I stripped it down to the point, where I realized that you just
> have to try to run an empty (!) script from the script editor to see all
> your RAM eaten up. I tested that for jython and javascript.

You should be able to avoid these problems by saving the hyperstack in TIFF format and opening it using IJ.openVirtual(). As an example, the following JavaScript code, which opens a 3500x3500x3x10 hyperstack, switches between slices in 1/3 second and does not use an excessive amount of RAM.

  IJ.doCommand("Monitor Memory...");
  imp = IJ.openVirtual("");
  imp.show();
  IJ.run(imp, "Set... ", "zoom=100 x=0 y=0");
  times = new Array();
  slices = imp.getNSlices();
  for (i=2; i<=slices; i++) {
     t0 = System.currentTimeMillis();
     imp.setZ(i);
     times[i-1] = System.currentTimeMillis()-t0;
     print(i+"/"+slices+" "+times[i-1]);
  }
  sum = 0;
  for (i in times)
     sum += times[i];
  print("Average time: "+(sum/slices)/1000);

Use the following code to create the 10 slice test hyperstack. Each slice is 70MB (3500*3500*3*2).

  imp = IJ.createImage("HyperStack", "16-bit color-mode label", 3500, 3500, 3, 10, 1);
  IJ.saveAs(imp, "Tiff", "”);

TIFF files created by ImageJ larger than 4GB do not conform to the TIFF standard so other applications have to open them as raw files.

-wayne

> opened a 7gb ome.tiff with Bio Formats Importer in virtual hyperstack mode
> opened the script editor via file -> new -> script
> choosed python/java script as language
> pressed run on the empty(!) script
>
> What I see:
>
> When monitoring the RAM, I see it gets filled rather quickly by Fiji up to
> the size of 9.5Gb. For bigger input files more RAM gets 'used' accordingly.
> So for files exceeding my physical amount of Memory Fiji becomes
> unresponsive rather quickly. I experienced the same behavior for nd2 files.
>
> Is there a way to cirmumvent this ? I guess Fiji tries to load the whole
> image stack despite having chosen 'virtual stack' in the first place ?
>
> Best,
> Greg
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Running-scripts-with-an-open-Virtual-Hyperstack-tp5012163.html
> Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html