SOLVED: "Simple" multi-stacks to individual images

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

SOLVED: "Simple" multi-stacks to individual images

pognonec
This post was updated on .
Hi List,

First, I am not familiar with ImageJ macro writing, while not being completely ignorant.

We have lots of .ome.tif stacks (4GB each). These stacks were generated (by MicroManager) from scanning multi-well plates in a single channel, a single z, a single t. These stacks are in a single folder.
We "just" want to split (stack to image) all of them into numerated individual images (from 1, the first image of the first stack, to x, the last one of the last stack).
That sound quite simple, but  I have not been able to write a macro doing just that...
I have looked in previous posts, but what I found had to do with splitting channels, and did not help in this case.

Any help or hint would be appreciated!

Thanks,
Philippe
Reply | Threaded
Open this post in threaded view
|

Re: "Simple" multi-stacks to individual images

ctrueden
Hi Philippe,

> We "just" want to split (stack to image) all of them into numerated
> individual images (from 1, the first image of the first stack, to x,
> the last one of the last stack).

Why not use the Bio-Formats command line tools? Specifically, the bfconvert
command:

https://www.openmicroscopy.org/site/support/bio-formats5.1/users/comlinetools/conversion.html

From the documentation:

> Images can also be written to multiple files by specifying a pattern
> string in the output file. For example, to write one series,
> timepoint, channel, and Z section per file:
>
> bfconvert /path/to/input output_series_%s_Z%z_C%c_T%t.tiff
>
> %s is the series index, %z is the Z section index, %c is the channel
> index, and %t is the timepoint index (all indices begin at 0).

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - http://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Fri, Aug 12, 2016 at 5:13 AM, pognonec <[hidden email]> wrote:

> Hi List,
>
> First, I am not familiar with ImageJ macro writing, while not being
> completely ignorant.
>
> We have *lots* of .ome.tif stacks (4GB each). These stacks were generated
> (by MicroManager) from scanning multi-well plates in a single channel, a
> single z, a single t. These stacks are in a single folder.
> We "just" want to split (stack to image) all of them into numerated
> individual images (from 1, the first image of the first stack, to x, the
> last one of the last stack).
> That sound quite simple, but  I have not been able to write a macro doing
> just that...
> I have looked in previous posts, but what I found had to do with splitting
> channels, and did not help in this case.
>
> Any help or hint would be appreciated!
>
> Thanks,
> Philippe
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.
> com/Simple-multi-stacks-to-individual-images-tp5017009.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: "Simple" multi-stacks to individual images

Christine Labno-2
Hi Philippe,

Curtis has a good suggestion with BioFormats.  If you really want a basic macro for ImageJ (no plugins) I just created one last week that takes advantage of the built in save as Image Sequence option.  It should do what you want.

To run, just open the macro and hit run, it will ask you which folder you want to process and then where you want to save the output.  

---------------------Begin code here-----------------------------

// Macro to batch process a stack into individual tif files

dir = getDirectory("Choose a Directory to PROCESS");      
   list = getFileList(dir);                                                                                              
dir2 = getDirectory("Choose a Directory to SAVE");  

 setBatchMode(true);              
    for (f=0; f<list.length; f++) {
        path = dir+list[f];                                                          
        showProgress(f, list.length);    
        if (!endsWith(path,"/")) open(path);  
        if (nImages>=1) {                                          
        if (endsWith(path,"f")) {

   start = getTime();                            

 t=getTitle();
    print("now processing: " + t);                                                                          
 run("Image Sequence... ", "format=TIFF save=dir2 + .tif");                                      
 run("Close");                                  
                                                             

       }                                
      }                                                      
    }
   
 print((getTime()-start)/1000 + " seconds");      

------------------------end------------------------------------
 
Good luck!
Christine

--------------------------------------------
Christine Labno, Ph.D.
Asst. Technical Director
Light Microscopy Core
University of Chicago
Office of Shared Research Facilities
KCBD 1250 900 E. 57th St.
(773) 834-9040 (phone)

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Curtis Rueden [[hidden email]]
Sent: Friday, August 12, 2016 12:28 PM
To: [hidden email]
Subject: Re: "Simple" multi-stacks to individual images

Hi Philippe,

> We "just" want to split (stack to image) all of them into numerated
> individual images (from 1, the first image of the first stack, to x,
> the last one of the last stack).

Why not use the Bio-Formats command line tools? Specifically, the bfconvert
command:

https://www.openmicroscopy.org/site/support/bio-formats5.1/users/comlinetools/conversion.html

From the documentation:

> Images can also be written to multiple files by specifying a pattern
> string in the output file. For example, to write one series,
> timepoint, channel, and Z section per file:
>
> bfconvert /path/to/input output_series_%s_Z%z_C%c_T%t.tiff
>
> %s is the series index, %z is the Z section index, %c is the channel
> index, and %t is the timepoint index (all indices begin at 0).

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - http://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Fri, Aug 12, 2016 at 5:13 AM, pognonec <[hidden email]> wrote:

> Hi List,
>
> First, I am not familiar with ImageJ macro writing, while not being
> completely ignorant.
>
> We have *lots* of .ome.tif stacks (4GB each). These stacks were generated
> (by MicroManager) from scanning multi-well plates in a single channel, a
> single z, a single t. These stacks are in a single folder.
> We "just" want to split (stack to image) all of them into numerated
> individual images (from 1, the first image of the first stack, to x, the
> last one of the last stack).
> That sound quite simple, but  I have not been able to write a macro doing
> just that...
> I have looked in previous posts, but what I found had to do with splitting
> channels, and did not help in this case.
>
> Any help or hint would be appreciated!
>
> Thanks,
> Philippe
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.
> com/Simple-multi-stacks-to-individual-images-tp5017009.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: "Simple" multi-stacks to individual images

pognonec
Thanks Christine and Curtis.

I first went for Christine Macro, that does the job great! It is exactly what I was looking for, except that I get the following error message after a few stacks have been processed (I cannot reasonably increase Imagej memory setting much more):

<Out of memory>
<All available memory (13679MB) has been>
<used. To make more available, use the>
<Edit>Options>Memory & Threads command.>

I know I may be a bit of a pain, but is there a way to use "Virtual stack" or something similar in this script, to avoid memory problem?

Thanks again for your help!
Reply | Threaded
Open this post in threaded view
|

Re: "Simple" multi-stacks to individual images

Christine Labno-2
Glad it's working!

Virtual stack is possible.  Simply replace open(path); in line 8 with run("TIFF Virtual Stack...", "open=path");  You can keep the if (!endsWith(path,"/")) statement at the beginning.  

Best,
Christine
--------------------------------------------
Christine Labno, Ph.D.
Asst. Technical Director
Light Microscopy Core
University of Chicago
Office of Shared Research Facilities
KCBD 1250 900 E. 57th St.
(773) 834-9040 (phone)


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

SOLVED: "Simple" multi-stacks to individual images

pognonec
Christine,
It is now working perfectly.
Thank you so much!

Curtis, after bftools install, I could not get the bfconvert.bat to stay open. I guess something is missing on my system.

Philippe.