if(roiManager("count")!=0){
	roiManager("reset");
}
run("Clear Results");

requires("1.32f");
  title = getTitle;
  width = getWidth;
  height = getHeight;
  depth = nSlices;
  getPixelSize(unit, pw, ph, pd);
  path = getDirectory("image");
  getThreshold(t1, t2); 


//Analizo en una ROI "comprimida" 3cm por cada lado
makeRectangle(30/pw, 30/ph, width-60/pw, height-60/ph);
run("Copy");

newImage("Untitled", "16-bit Black", width-60/pw, height-60/ph, 1);
selectWindow("Untitled");
run("Paste");


run("Set Scale...", "distance=1 known=pw pixel=1 unit=mm");
run("Invert LUT");
setAutoThreshold("Default dark");
run("Convert to Mask");
//run("Fill Holes");


run("Analyze Particles...", "size=100-200 circularity=0.00-1.00 show=Nothing clear record add");

  for (i=0; i<nResults-1; i++)
  {
      x = getResult('XStart', i);
      y = getResult('YStart', i);
      doWand(x,y);
      roiManager("add");
  }

//cierro la imagen de analisis
close();


//y muevo todas las ROIs una distancia conocida

ROIs = roiManager("count");
if (ROIs==0)
      exit("The ROI Manager is empty");
for (i=0; i<ROIs; i++)
{
      roiManager('select', i);
      getSelectionBounds(x, y, w, h);
      setSelectionLocation(x+30/pw, y+30/ph);
      roiManager('update');
}

