Skip to content

Instantly share code, notes, and snippets.

@NicoKiaru
Last active May 21, 2024 12:39
Show Gist options
  • Save NicoKiaru/00e700d38aee5bd2d188379315f14fcc to your computer and use it in GitHub Desktop.
Save NicoKiaru/00e700d38aee5bd2d188379315f14fcc to your computer and use it in GitHub Desktop.
A small gists that dumps Timestamps from a File using Bio-Formats
#@File f
IFormatReader r = new ImageReader();
IMetadata meta = MetadataTools.createOMEXMLMetadata();
r.setMetadataStore(meta)
r.setId(f.getAbsolutePath());
meta = (IMetadata) r.getMetadataStore(); // Retrieves the metadata object
int nImages = r.getSeriesCount(); // Number of images within the file
for (int iImage = 0; iImage<nImages; iImage++) {
r.setSeries(iImage);
int nPlanes = meta.getPlaneCount(iImage); // Number of Planes within the image
System.out.println("Image #"+iImage+" ["+meta.getImageName(iImage)+"] nPlanes="+nPlanes);
for (int iPlane = 0; iPlane <nPlanes;iPlane++) {
int[] zct = r.getZCTCoords(iPlane);
System.out.println("Plane C:"+zct[0]+" Z:"+zct[1]+" T:"+zct[2]);
System.out.println("Acquired at "+meta.getPlaneDeltaT(iImage,iPlane).toString());
}
}
import loci.formats.IFormatReader;
import loci.formats.ImageReader;
import loci.formats.meta.IMetadata;
import loci.formats.MetadataTools;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment