Login  Register

Using Image Calculator with Virtual Stacks

Posted by jmarks on Jul 01, 2011; 11:02pm
URL: http://imagej.273.s1.nabble.com/Using-Image-Calculator-with-Virtual-Stacks-tp3684024.html

Dear All
I have 2 image stacks that are far too large to fit in memory. I would like to generate and save ratioed images of each pair of slices in the two stacks.
I thought that Virtual Stacks and Process>Batch>Virtual Stack would do the job, but I am getting unexpected results.
Each virtual stack has its own directory.
Using the Batch Process Dialogue, I can identify the directory to contain the 32-bit ratioed images.

Running Image Calculator in the code box provided in the dialogue produces the correct 32 bit result image. I can rename this result image "Result" and append the current Slice number of the virtual stacks to generate a unique filename, e.g. Result.001, Result.002...

However, what ends up being saved by the Batch Process as "Result.*" is not the 32-bit result image, but the current slice of one of the virtual stacks used as input to the Image calculator. Furthermore, specifying the Output folder seems to serve no function, as an explicit SaveAs command requires a fully qualified path.

The simple macro code I have written in the code box is

      run("Image Calculator...", "image1=[B 340 backsub] operation=Divide image2=[B 380 backsub] 32-bit");   // do the division with 32 bit result
      rename ("Result") ;                  
      selectWindow("B 340 backsub") ;   // select one of the virtual stacks
      n = getSliceNumber() ;                 // get the current slice index
      nString = toString(n, 0);                // convert the index to a string
      MyImage = "ratio." + nString ;        // create a string for the output filename with the index as the extension
      selectWindow("Result") ;               // select the result image
       SaveAsString = "Y:\\human brain\\june 28 2011 cold\\B ratio\\" + MyImage ; // create the string with the fully qualitifed path
        saveAs("Tiff", SaveAsString);  // save the result image
       close() ;                              // close the result image


Have I misunderstood how this batch functionality with Virtual Stacks is intended to be used?
Any help would be very much appreciated.
Jeremy Marks
University of Chicago