How to open raw hyperstack from plugin?

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

How to open raw hyperstack from plugin?

Josh Doe
I am updating a plugin for a custom format I've written to handle
hyperstacks. My plugin gets called from HandleExtraFileTypes if the magic
number matches my format. I haven't had success yet opening them as normal
hyperstacks or virtual hyperstacks.

I set FileInfo.nImages to slices * channels * frames, and call
ImagePlus.setProperty() on "hyperstack", "slices", "channels", and "frames",
but my files still keep on opening as regular stacks. Is there something
else I'm missing?

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

Re: How to open raw hyperstack from plugin?

Rasband, Wayne (NIH/NIMH) [E]
On Mar 31, 2010, at 7:03 AM, Josh wrote:

> I am updating a plugin for a custom format I've written to handle
> hyperstacks. My plugin gets called from HandleExtraFileTypes if the magic
> number matches my format. I haven't had success yet opening them as
> normal hyperstacks or virtual hyperstacks.
>
> I set FileInfo.nImages to slices * channels * frames, and call
> ImagePlus.setProperty() on "hyperstack", "slices", "channels", and "frames",
> but my files still keep on opening as regular stacks. Is there something
> else I'm missing?

Create an ImagePlus (imp) from the stack, call imp.setDimensions(), create a CompositeImage (if c>1), call imp.setOpenAsHyperStack(true) and call imp.show(). Here is what the code looks like:

   ImagePlus imp = new ImagePlus("Hyperstack", stack);
   imp.setDimensions(c, z, t);
   imp = new CompositeImage(imp, CompositeImage.COMPOSITE);
   imp.setOpenAsHyperStack(true);
   imp.show();

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: How to open raw hyperstack from plugin?

Josh Doe
Thanks Wayne, that works great for regular stacks.

I'd also like to open the hyperstacks as virtual stacks. I see
FileInfoVirtualStack is used for virtual stacks, and looking at the source I
feel like the following should work, but it doesn't.

    StringBuffer sb = new StringBuffer(100);
    sb.append("images=" + fi.nImages + "\n");
    sb.append("channels=" + channels + "\n");
    sb.append("frames=" + frames + "\n");
    sb.append("hyperstack=true\n");
    sb.append("mode=grayscale\n");
    sb.append((char)0);
    fi.description = new String(sb);
    new FileInfoVirtualStack(fi);

This opens my file as a virtual stack, but not as a virtual hyperstack. Am I
missing something?

Thanks,
-Josh

On Thu, Apr 1, 2010 at 12:43 AM, Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]> wrote:

> On Mar 31, 2010, at 7:03 AM, Josh wrote:
>
> > I am updating a plugin for a custom format I've written to handle
> > hyperstacks. My plugin gets called from HandleExtraFileTypes if the magic
> > number matches my format. I haven't had success yet opening them as
> > normal hyperstacks or virtual hyperstacks.
> >
> > I set FileInfo.nImages to slices * channels * frames, and call
> > ImagePlus.setProperty() on "hyperstack", "slices", "channels", and
> "frames",
> > but my files still keep on opening as regular stacks. Is there something
> > else I'm missing?
>
> Create an ImagePlus (imp) from the stack, call imp.setDimensions(), create
> a CompositeImage (if c>1), call imp.setOpenAsHyperStack(true) and call
> imp.show(). Here is what the code looks like:
>
>   ImagePlus imp = new ImagePlus("Hyperstack", stack);
>   imp.setDimensions(c, z, t);
>   imp = new CompositeImage(imp, CompositeImage.COMPOSITE);
>   imp.setOpenAsHyperStack(true);
>   imp.show();
>
> -wayne
>