How to read series name in multiseries file using SCIFIO

How can I read the series names in metadata of a multiseries file opened by SCIFIO (via Bio-Formats)?

What I’d like to get is the names Position1, Position2 etc. from a Metamorph .nd file, as they are displayed in a Bio-Formats Series Options dialog:

Is this possible using SCIFIO?

I can get the ImageMetadata like this:

Format format = formatService.getFormat(ndFile.getAbsolutePath());
Metadata metadata = format.createParser().parse(ndFile);
int nSeries = metadata.getImageCount();
ImageMetadata imageMetadata = metadata.get(0);

… but I didn’t find the series names anywhere in the metadata.

(If not SCIFIO, I’d also be interested in an example of retrieving the series name using Bio-Formats directly.)

1 Like

With pure Bio-Formats (thanks to the great example gist by @ctrueden), I figured how to get the names printed:

#@ File input

import loci.formats.ImageReader
import loci.formats.MetadataTools

reader = new ImageReader()
omeMeta = MetadataTools.createOMEXMLMetadata()
nSeries = reader.getSeriesCount()

nSeries.times {
  println omeMeta.getImageName(it)

Still interested in a solution using #scifio though…


Here is a gist showing how to read OME metadata using SCIFIO:

And here is a version of your code using the approach from the gist:

#@ File input
#@ SCIFIO scifio

import io.scif.ome.OMEMetadata

// Read _only_ the metadata from a file without opening pixels.
globalMeta = scifio.initializer().parseMetadata(input.getAbsolutePath())

// Convert globalMeta above to omeMeta
omeMeta = new OMEMetadata(scifio.context())
scifio.translator().translate(globalMeta, omeMeta, true)

omeRoot = omeMeta.getRoot()
omeRoot.getImageCount().times {
  println omeRoot.getImageName(it)
1 Like

Thanks, Curtis, for this example.

Unfortunately, the SCIFIO version of the code gives me the file path (the same for each series), not the series names as they’re displayed in the Bio-Formats Import dialog, i.e.:


… from my code example is returning something different than:


… from the SCIFIO version :astonished:


I was testing with the .nd file from this folder, for example, where I expect to get:

Stage1 "Row0_Col0"
Stage2 "Row1_Col0"
Stage3 "Row0_Col1"
Stage4 "Row1_Col1"

Hi @imagejan, the text displayed in the Bio-Formats Series Options is not the actual series name stored in the metadata but is instead created from a number of different pieces of metadata

The code which generates those labels is here:

Alright, thanks for bringing this to my attention.

Nevertheless, I’m able to successfully get the desired output in this case (Stage1 "Row0_Col0") using exclusively Bio-Formats API, but struggle to get the same using SCIFIO…

Sorry @imagejan for the delay in reply. I guess this is a limitation of SCIFIO that we should address. You could file an issue in the SCIFIO repository or maybe in the scifio-bf-compat repository. Sorry to say that it may sit for awhile, though.

1 Like


1 Like