Posted by
ctrueden on
Apr 03, 2007; 9:33pm
URL: http://imagej.273.s1.nabble.com/programmatically-opening-a-stack-from-a-list-of-filenames-tp3699826p3699834.html
Hi Ben,
> 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
Another option is to do this with the Bio-Formats Importer plugin.
Check the "Stitch files with similar names" box, then choose
016-095708_000001.tif. Hit OK, and the next dialog box will be a "file
pattern" indicating which files you want. In your case, you'll see
something like: "016-095708_0000<01-55>.tif" where the "55" is the
maximum numerical value in that block. You can change it to "11" and
hit OK, and you'll get 01-11. A similar procedure will work for your
other TIFF series.
The Bio-Formats filename numbering autodetection is really quite
smart. If you find a case where it fails, let me know and I can look
into it. But even if it does fail, you can type your own pattern in
manually to the file pattern dialog, to override any faulty guesses it
makes. If you put leading zeroes in the pattern, it assumes fixed with
numbering (so, <01-55> is fixed width), while no leading zeroes (e.g.,
<1-55>) indicates variable width.
-Curtis
On 4/2/07, Ben Tupper <
[hidden email]> wrote:
> 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
>