Login  Register

Re: API way to do deinterleave?

Posted by Wayne Rasband-2 on Sep 14, 2018; 4:01pm
URL: http://imagej.273.s1.nabble.com/API-way-to-do-deinterleave-tp5021169p5021182.html

> On Sep 12, 2018, at 8:26 AM, Aryeh Weiss <[hidden email]> wrote:
>
> I need to deinterleave a stack, and this is how I currently do it.
>
> IJ.run(imp ,"Properties...", "channels=1 slices=1 frames="+str(timePoints)+" unit=pixel pixel_width=1.0000 pixel_height=1.0000 voxel_depth=1.0000")
>
> and this works fine. However, when IJ.run() commands open up window, I need to get a handle on those windows, and this requires knowing the names or id's of the windows that were opened. This is ok, but awkward, especially when more than one image windows is generated. Also, it means that the images are displayed, which is not always needed or desirable.
>
> In this case, I deinterleave nine fields,so it is awkward. So I close all image windows before deinterleaving, and then grab the entire image list and create a list of ImagPlus objects.
>
> Is there a stack deinterleave method (similar to reduce() and some other stack methods), that can be called and will return a list of the deinterleaved images.

The Deinterleave plugin in Fiji (Image>Stacks>Deinterleave) does not have an API for splitting a stack into sub-stacks but ImageJ's built in ChannelSplitter plugin (Image>Color>Split Channels) does. Here is a JavaScript example that splits a 36 slice stack into nine sub-stacks:

  imp = IJ.createImage("Untitled", "8-bit noise", 256, 256, 36);
  imp2 = HyperStackConverter.toHyperStack(imp,9,4,1,”default”,"Grayscale");
  subStacks = ChannelSplitter.split(imp2);
  for (i=0; i<subStacks.length; i++)
     print(subStacks[i]);

-wayne


> I can duplicate, reduce(), remove an image and repeat, but I am hoping that I do not have to reinvent it.
>
> tnx in advance
> --aryeh

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