saving stacks to newly created folders

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

saving stacks to newly created folders

Ninja Chris
Hi, I'm trying to throw together some javascript to duplicate ROIs in a stack in ImageJ and save each produced stack to its own folder created in the parent. My code is:

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();
  }

My problem is that the ROIs are duplicated, the folders created but the stack isn't saved to the new subfolders. A previous version created the folders but then requested confirmation of the folder to save the images too. This had the advantage of actually saving the files but lacked the automation I seek. I am working with 3K image stacks and processing them is something I want to initiate and let run in the background.

Can anyone point me to the flaw in my code as I am at something of a loss? Any help most gratefully recieved!

Chris
Reply | Threaded
Open this post in threaded view
|

Re: saving stacks to newly created folders

Michael Schmid
Hi Crhis,

for some reason your mail was posted half a dozen times to the list,  
partly with slight variations of the subject and context. Please try  
to avoid this, it will be considered annoying. You get a confirmation  
mail for each post to the list, so it is hard to blame this mistake  
on your mailer...

Anyhow, you are missing the slash (or backslash on Windows) at the  
end of the folder name. So ImageJ takes it as the name of a normal  
file in the parent directory, and the files are getting stored in the  
parent directory.

Try:
   bee = "bee_"+i + File.separator;

Michael
________________________________________________________________

On 22 Feb 2010, at 15:46, Ninja Chris wrote:

> Hi, I'm trying to throw together some javascript to duplicate ROIs  
> in a stack
> in ImageJ and save each produced stack to its own folder created in  
> the
> parent. My code is:
>
> 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();
>   }
>
> My problem is that the ROIs are duplicated, the folders created but  
> the
> stack isn't saved to the new subfolders. A previous version created  
> the
> folders but then requested confirmation of the folder to save the  
> images
> too. This had the advantage of actually saving the files but lacked  
> the
> automation I seek. I am working with 3K image stacks and processing  
> them is
> something I want to initiate and let run in the background.
>
> Can anyone point me to the flaw in my code as I am at something of  
> a loss?
> Any help most gratefully recieved!
>
> Chris
> --
> View this message in context: http://n2.nabble.com/saving-stacks-to- 
> newly-created-folders-tp4612497p4612497.html
> Sent from the ImageJ mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: saving stacks to newly created folders

Ninja Chris
Hi Michael, sorry about the multiple posting but there's no mention of confirmation emails in the posting instructions so I deleted my posts several times according to the instructions for pending posts and reposted them. It was only when I checked my emails that I found the confirmation emails. I couldn't discriminate which email corresponded with which posted and I assumed the ones I had manually deleted wouldn't get posted. Maybe the instructions should be made clearer and should mention the confirmation emails?

I'm very grateful for your help with that amendment my code now works exactly as I wanted it to. Thank you very much!

Regards,
Chris