Re: Cropping several parts of a set of images from multiple folders

Posted by Ninja Chris on
URL: http://imagej.273.s1.nabble.com/Cropping-several-parts-of-a-set-of-images-from-multiple-folders-tp3689264p3689269.html

Hi Oli,

I'm trying to automate the export of ROIs in a stack to new subfolders. I've been adapting the BatchProcess Function too and have got this far:

sdir = getDirectory("choose source directory ");
n = roiManager("count");
for (i=0; i<n; i++) {
     roiManager("select", i);
     bee = "bee_"+i+"_";
     ddir = sdir+bee;
     File.makeDirectory(ddir);
     run("Duplicate...", "title = bee duplicate range=1-3000");
     run("Image Sequence... ", "format=TIFF name=["+bee+"] start=0 digits=4 save=["+ddir+"]");
close();
  }

If you open your stack, select a few ROIs and then run this macro it will ask you what the parent folder is then generate a folder for each ROI (they're called "bee" because I'm processing videos of bees). It will also duplicate each ROI and save it as a separate stack. Unfortunately I can't get it to save the relevant ROI stacks in the right folder so it just dumps them in the parent at the moment. If I get it working properly I'll post back.
Hope this helps,

Chris