Posted by
Ben.BigHair on
Apr 02, 2007; 7:45pm
URL: http://imagej.273.s1.nabble.com/programmatically-opening-a-stack-from-a-list-of-filenames-tp3699826p3699828.html
Albert Cardona wrote:
> Ben,
>
> What you have listed is generally correct (beware though your code has at least
> one parenthesis missing at addSlice).
>
> The easier way: extend ij.plugin.FolderOpener and override the sortFileList to
> open the image file sequence like you need.
>
> Even easier: assuming the sortFileList will work as is, just pass macro values
> and execute the plugin.
>
> You can see what options to pass if you open the Macro recorder and call the
> File / Import / Image Sequence command.
>
> IJ.run("Image Sequence...", "open=/my/folder/anyfile.tif number=752
> starting=1 increment=1 scale=100 file=experiment1");
>
> If you set the folder only, through
> Macro.setOptions("open=/my/folder/anyfile.tif");
> then only the GenericDialog will open asking for input.
> If any of the fields in the GenericDialog is not completed from an option from
> the macro engine, then the dialog will show as well.
>
> Albert
>
Hi Albert,
Thanks for the information. I'm glad I have it basically correct. I'm
also happy to see the FolderOpener class which I hadn't noticed before.
Unfortunately, I need to open some but not all of the images within a
folder. For example, I would like to open the first 11 in one stack and
the second 3 in the second stack. I have a metadata file from which I
can derive each listing of filenames so I need not search the folder.
016-095708_000001.tif
016-095708_000002.tif
016-095708_000003.tif
016-095708_000004.tif
016-095708_000005.tif
016-095708_000006.tif
016-095708_000007.tif
016-095708_000008.tif
016-095708_000009.tif
016-095708_000010.tif
016-095708_000011.tif
016-095708_cal_000001.tif
016-095708_cal_000002.tif
016-095708_cal_000003.tif
I guess I could play tricks with the "Image Sequence..." command using
some string matching. That might be a whole lot easier.
My wishful thinking is to have an ImageStack constructor that looks
something like...
ImageStack(java.lang.String[] files)
from which I could get an instance of ImagePlus to show,
or
ImagePlus(java.lang.String[] files)
which would be very handy for sloths like me. I see that, as you point
out, I could extend ij.plugin.FolderOpener and override the run method
where the list is created (and sorted). My Java programming skills might
be too wobbly for me to tackle that just yet.
Thanks again,
Ben