Macro occasionally outputs unwanted decimals

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Macro occasionally outputs unwanted decimals

Gabriel Acevedo
Hello,
 I am trying to run several macros to split large stacks of DICOM data which
have been converted into a tif file. I have them set up as simple for loops.
However, very often, the either macro will run and output a decimal number
instead of the desired integer, which in turns screws up the rest of the
code. Any ideas on what I am doing wrong? It's not a constant problem.
Usually after several attempts and restarting ImageJ, etc I can get it to
run. Below is the text of one of the macros.


thanks

Gabriel

requires("1.34m")
var zslices=1;
var phases=1;
var k=1;
var j=1;

dir=getDirectory("image");  
title = "Substack";
 
  Dialog.create("New Image");
  Dialog.addString("Stub:", title);
 
  Dialog.addNumber("zslices:", 14);
  Dialog.addNumber("Phases:", 6);
  Dialog.show();
  stub = Dialog.getString();
  zslices = Dialog.getNumber();
  phases = Dialog.getNumber();
 

for (k=1;k<=phases;k++) {
   str="";
   print("k="+k);
       for (j=1; j<zslices; j++) {
         str = str + j+(k-1)*zslices+ ",";
       }    
  str = str + k*(zslices); //add last element without a comma at end
  print("check3,str="+str);

  print("string"+k+"="+str);
  run("Substack Maker","slices="+str);

  saveAs("tiff", dir+stub+k+".tif");
  close();
}