use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.
the class Schema2011_06_File_Upgrade_Test method setUp.
@BeforeClass
public void setUp() throws Exception {
InputStream source = this.getClass().getResourceAsStream(ref.FILE_LOCATION);
byte[] b = new byte[source.available()];
source.read(b);
source.close();
String xml = new String(b);
ServiceFactory sf = new ServiceFactory();
OMEXMLService service = sf.getInstance(OMEXMLService.class);
ome = (OME) service.createOMEXMLRoot(xml);
}
use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.
the class OMETiffWriterUnicodeTest method setUp.
@BeforeClass
public void setUp() throws Exception {
target = File.createTempFile("OMETiffWriterUnicodeTest", ".ome.tiff");
ServiceFactory sf = new ServiceFactory();
OMEXMLService service = sf.getInstance(OMEXMLService.class);
ms = service.createOMEXMLMetadata();
ms.setImageID("Image:1", 0);
ms.setPixelsID("Pixels:1", 0);
ms.setPixelsDimensionOrder(DimensionOrder.XYZCT, 0);
ms.setPixelsSizeX(new PositiveInteger(SIZE_X), 0);
ms.setPixelsSizeY(new PositiveInteger(SIZE_Y), 0);
ms.setPixelsSizeZ(new PositiveInteger(SIZE_Z), 0);
ms.setPixelsSizeC(new PositiveInteger(SIZE_C), 0);
ms.setPixelsSizeT(new PositiveInteger(SIZE_T), 0);
ms.setPixelsPhysicalSizeX(new Length(10, UNITS.MICROMETER), 0);
ms.setPixelsPhysicalSizeX(new Length(10, UNITS.MICROMETER), 0);
ms.setPixelsPhysicalSizeX(new Length(10, UNITS.MICROMETER), 0);
ms.setPixelsType(PixelType.UINT8, 0);
ms.setPixelsBinDataBigEndian(true, 0, 0);
ms.setChannelID("Channel:1", 0, 0);
ms.setChannelSamplesPerPixel(new PositiveInteger(1), 0, 0);
}
use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.
the class MakeLZW method main.
public static void main(String[] args) throws Exception {
ImageReader reader = new ImageReader();
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata omexmlMeta = service.createOMEXMLMetadata();
reader.setMetadataStore(omexmlMeta);
TiffWriter writer = new TiffWriter();
for (int i = 0; i < args.length; i++) {
String inFile = args[i];
String outFile = "lzw-" + inFile;
System.out.print("Converting " + inFile + " to " + outFile);
reader.setId(inFile);
writer.setMetadataRetrieve(omexmlMeta);
writer.setCompression("LZW");
writer.setId(outFile);
int planeCount = reader.getImageCount();
for (int p = 0; p < planeCount; p++) {
System.out.print(".");
byte[] plane = reader.openBytes(p);
writer.saveBytes(p, plane);
}
System.out.println(" [done]");
}
}
use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.
the class MultiFileExportExample method main.
public static void main(String[] args) throws FormatException, IOException {
if (args.length < 2) {
System.out.println("Usage: java MultiFileExportExample <infile> <output file extension>");
System.exit(1);
}
ImageReader reader = new ImageReader();
IMetadata metadata;
try {
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
metadata = service.createOMEXMLMetadata();
} catch (DependencyException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
} catch (ServiceException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
}
reader.setMetadataStore(metadata);
reader.setId(args[0]);
ImageWriter writer = new ImageWriter();
writer.setMetadataRetrieve(metadata);
String baseFile = args[0].substring(0, args[0].lastIndexOf("."));
writer.setId(baseFile + "_s0_z0" + args[1]);
for (int series = 0; series < reader.getSeriesCount(); series++) {
reader.setSeries(series);
writer.setSeries(series);
int planesPerFile = reader.getImageCount() / reader.getSizeZ();
for (int z = 0; z < reader.getSizeZ(); z++) {
String file = baseFile + "_s" + series + "_z" + z + args[1];
writer.changeOutputFile(file);
for (int image = 0; image < planesPerFile; image++) {
int[] zct = FormatTools.getZCTCoords(reader.getDimensionOrder(), 1, reader.getEffectiveSizeC(), reader.getSizeT(), planesPerFile, image);
int index = FormatTools.getIndex(reader, z, zct[1], zct[2]);
writer.saveBytes(image, reader.openBytes(index));
}
}
}
reader.close();
writer.close();
}
use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.
the class PrintLensNA method main.
public static void main(String[] args) throws DependencyException, FormatException, IOException, ServiceException {
// parse command line arguments
if (args.length < 1) {
System.err.println("Usage: java PrintLensNA imageFile");
System.exit(1);
}
String id = args[0];
// configure reader
IFormatReader reader = new ImageReader();
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata meta = service.createOMEXMLMetadata();
reader.setMetadataStore(meta);
System.out.println("Initializing file: " + id);
// parse metadata
reader.setId(id);
// output metadata values
int instrumentCount = meta.getInstrumentCount();
System.out.println("There are " + instrumentCount + " instrument(s) associated with this file");
for (int i = 0; i < instrumentCount; i++) {
int objectiveCount = meta.getObjectiveCount(i);
System.out.println();
System.out.println("Instrument #" + i + " [" + meta.getInstrumentID(i) + "]: " + objectiveCount + " objective(s) found");
for (int o = 0; o < objectiveCount; o++) {
Double lensNA = meta.getObjectiveLensNA(i, o);
System.out.println("\tObjective #" + o + " [" + meta.getObjectiveID(i, o) + "]: LensNA=" + lensNA);
}
}
}
Aggregations