Bioformats with Imglib2

Dear all,

what’s the correct way / is there a way to use bioformats readers directly with imglib2?
E.g. use a bioformats reader in ImgOpener?

Do I have to use scifio / scifio-bioformats wrapper, or is there a way to use bioformats readers directly and get somehow an Img<> object?

So I’m thinking of like

    // Bioformats reader
    ImageReader ir = new ImageReader();

    // Warpper
    BioFormatsFormat.Reader reader = new BioFormatsFormat.Reader();
    BioFormatsFormat.Metadata metadata = new BioFormatsFormat.Metadata();

    // metadata includes the reader - but unfortunately not the real metadata
    // so it will not work, because metadata.get(0) will return null
    ImgOpener imgOpener = new ImgOpener();
    List<SCIFIOImgPlus<?>> img = imgOpener.openImgs(reader); // fails

Or is there another way?

What I want to achieve is to apply ImageJ-Ops to images read via bioformat readers like NDPIReader.

Thanks for help!


Use SCIFIO. It calls Bio-Formats automatically via the BioFormatsFormat.

Did you try simply:

ImgOpener imgOpener = new ImgOpener();
List<SCIFIOImgPlus<?>> imgs = imgOpener.openImgs(path);

Or even more simply:

import io.scif.img.IO;
List<SCIFIOImgPlus<?>> imgs =;

Does it work? If not, what goes wrong? We can dig in to that.

Hi Curtis,

thanks for your fast reply.

ImgOpener imgOpener = new ImgOpener();
List<SCIFIOImgPlus<?>> imgs = imgOpener.openImgs(path);

works nicely. But I’d like to use/test my own image reader (e.g. one which uses NDPI natives as backend). The current implementation is as an (bioformats) ImageReader. What would be the best way to access (tile/cell-based) data using my own reader mechanisms?


Hi @mstritt, is this a standalone reader you have developed or is it a modified version of one of the existing readers?

Hi @dgault,
well, it extends FormatReader and makes use of JNA to call native functions from lib.
But my question is more in general - I just would like to know how I can do those things in principal.

If your custom reader (and its dependencies) are on the classpath, SCIFIO/Bio-Formats should automatically pick it up, no?

thanks @imagejan for that hint. This will help me to solve the issue.
It did not work straight forward - here some remarks:

If I understood correctly, all Plugin(type=Format.class, …) annotated classes will be considered.
For bioformats, the BioFormatsFormat class takes care which initialized all bioformats readers.
However, at first it reads all readers from the ‘readers.txt’ file and only under certain conditions it searches for other IFormatReader classes.


1 Like

The default behaviour for ImageReader is that it creates a ClassList based on the reader.txt file and uses that to populate a list of readers.

  • If you are rebuilding a modified Bio-Formats you can simply add to readers.txt
  • If your new reader is in an external jar you can also add it to readers.txt (see Slidebook example below)[type=external] # sld
  • If you do not want to update readers.txt then you can create a ClassList and pass it to the ImageReader constructor

yes, but I cannot use the ClassList constructor of ImageReader when using SCIFIO… ?
The mechanism of

List<SCIFIOImgPlus<?>> imgs =;

in combination with BioFormatsFormat
takes control of that. It would be nice to have e.g. a static field somewhere to add additional IFormatReaders.

1 Like

Yeah, Im afraid at the moment thats not going to be an option when using through SCIFIO. Extending the reader discoverability further outside of readers.txt is something which may be looked at in the long term but would be a significant enough undertaking.

but that’s fine. For testing I can use the readers without scifio, and then for production include it in the readers.txt.