@BeforeClass public void setUp() { pixelsOnly = new DeltavisionReader(); pixelsOnly.getMetadataOptions().setMetadataLevel(MetadataLevel.MINIMUM); all = new DeltavisionReader(); all.getMetadataOptions().setMetadataLevel(MetadataLevel.ALL); }
MetadataStore store = makeFilterMetadata(); String imageSequence = getImageSequence(sequence); String pixel = getPixelString(filePixelType); m.pixelType = getPixelType(filePixelType); getSizeX() * getSizeY() * FormatTools.getBytesPerPixel(getPixelType()); int realPlaneCount = (int) ((in.length() - HEADER_LENGTH - extSize) / planeSize); if (realPlaneCount < getImageCount() && !truncatedFileFlag) { LOGGER.debug("Truncated file"); m.imageCount = realPlaneCount; else if (getDimensionOrder().indexOf('Z') < getDimensionOrder().indexOf('T')) if (getImageCount() > (sizeZ * sizeC * sizeT)) { m.imageCount = imageCount; sizeC = rawSizeC == 0 ? 1 : rawSizeC; sizeT = rawSizeT == 0 ? 1 : rawSizeT; sizeZ = getImageCount() / (sizeC * sizeT); setOffsetInfo(sequence, getSizeZ(), getSizeC(), getSizeT()); extHdrFields = new DVExtHdrFields[getSizeZ()][getSizeC()][getSizeT()]; ndFilters = new Double[getSizeC()]; boolean hasZeroX = false;
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); int[] coords = getZCTCoords(no); long offset = getPlaneByteOffset(coords[0], coords[1], coords[2]); if (offset < in.length()) { in.seek(offset); readPlane(in, x, getSizeY() - h - y, w, h, buf); // reverse the order of the rows // planes are stored with the origin in the lower-left corner byte[] tmp = new byte[w * FormatTools.getBytesPerPixel(getPixelType())]; for (int row=0; row<h/2; row++) { int src = row * tmp.length; int dest = (h - row - 1) * tmp.length; System.arraycopy(buf, src, tmp, 0, tmp.length); System.arraycopy(buf, dest, buf, src, tmp.length); System.arraycopy(tmp, 0, buf, dest, tmp.length); } } return buf; }
@Test(dependsOnMethods={"testSetId"}) public void testDimensions() { assertEquals(all.getSeriesCount(), pixelsOnly.getSeriesCount()); assertEquals(all.getSizeX(), pixelsOnly.getSizeX()); assertEquals(all.getSizeY(), pixelsOnly.getSizeY()); assertEquals(all.getSizeZ(), pixelsOnly.getSizeZ()); assertEquals(all.getSizeC(), pixelsOnly.getSizeC()); assertEquals(all.getSizeT(), pixelsOnly.getSizeT()); assertEquals(all.getPixelType(), pixelsOnly.getPixelType()); }
protected void initExtraMetadata() throws FormatException, IOException { MetadataStore store = makeFilterMetadata(); addGlobalMeta("Sub-image starting point (X)", subImageStartX); addGlobalMeta("Sub-image starting point (Y)", subImageStartY); addGlobalMeta("Sub-image starting point (Z)", subImageStartZ); addGlobalMeta("Pixel sampling size (X)", pixelSamplingX); addGlobalMeta("Pixel sampling size (Y)", pixelSamplingY); addGlobalMeta("Pixel sampling size (Z)", pixelSamplingZ); addGlobalMeta("X element length (in um)", pixX); addGlobalMeta("Y element length (in um)", pixY); addGlobalMeta("Z element length (in um)", pixZ); addGlobalMeta("X axis angle", xAxisAngle); addGlobalMeta("Y axis angle", yAxisAngle); addGlobalMeta("Z axis angle", zAxisAngle); addGlobalMeta("Column axis sequence", xAxisSeq); addGlobalMeta("Row axis sequence", yAxisSeq); addGlobalMeta("Section axis sequence", zAxisSeq); addGlobalMeta("Image Type", imageType); addGlobalMeta("Lens ID Number", lensID); addGlobalMeta("X axis tilt angle", xTiltAngle); addGlobalMeta("Y axis tilt angle", yTiltAngle); addGlobalMeta("Z axis tilt angle", zTiltAngle); addGlobalMeta("Wavelength " + (i + 1) + " (in nm)", waves[i]); addGlobalMeta("X origin (in um)", xOrigin);
addGlobalMeta(prefix + " " + key, value); String objectiveID = "Objective:" + value; store.setObjectiveID(objectiveID, 0, 0); for (int series=0; series<getSeriesCount(); series++) { store.setObjectiveSettingsID(objectiveID, series); Length sizeX = FormatTools.getPhysicalSizeX(size); if (sizeX != null) { for (int series=0; series<getSeriesCount(); series++) { store.setPixelsPhysicalSizeX(sizeX, series); Length sizeY = FormatTools.getPhysicalSizeY(size); if (sizeY != null) { for (int series=0; series<getSeriesCount(); series++) { store.setPixelsPhysicalSizeY(sizeY, series); Length sizeZ = FormatTools.getPhysicalSizeZ(size); if (sizeZ != null) { for (int series=0; series<getSeriesCount(); series++) { store.setPixelsPhysicalSizeZ(sizeZ, series); String detectorID = MetadataTools.createLSID("Detector", 0, 0); store.setDetectorID(detectorID, 0, 0); for (int series=0; series<getSeriesCount(); series++) { for (int c=0; c<getSizeC(); c++) { store.setDetectorSettingsBinning( MetadataTools.getBinning(value), series, c);
@Test(dependsOnMethods={"testSetId"}) public void testPlaneData() throws FormatException, IOException { for (int i = 0; i < pixelsOnly.getSeriesCount(); i++) { pixelsOnly.setSeries(i); all.setSeries(i); assertEquals(all.getImageCount(), pixelsOnly.getImageCount()); for (int j = 0; j < pixelsOnly.getImageCount(); j++) { byte[] pixelsOnlyPlane = pixelsOnly.openBytes(j); String sha1PixelsOnlyPlane = sha1(pixelsOnlyPlane); byte[] allPlane = all.openBytes(j); String sha1AllPlane = sha1(allPlane); if (!sha1PixelsOnlyPlane.equals(sha1AllPlane)) { fail(String.format( "MISMATCH: Series:%d Image:%d PixelsOnly:%s All:%s", i, j, sha1PixelsOnlyPlane, sha1AllPlane)); } } } }
private IFormatReader getReader(String file, boolean omexml) throws FormatException, IOException { IFormatReader pnl = new DeltavisionReader(); if (checkSuffix(file, "tif")) { pnl = new MetamorphReader(); } if (omexml) { IMetadata metadata; try { metadata = service.createOMEXMLMetadata(); } catch (ServiceException exc) { throw new FormatException("Could not create OME-XML store.", exc); } pnl.setMetadataStore(metadata); } pnl.setId(file); return pnl; }
for (int series=0; series<getSeriesCount(); series++) { store.setObjectiveSettingsID(objectiveID, series);
protected void initExtraMetadata() throws FormatException, IOException { MetadataStore store = makeFilterMetadata(); addGlobalMeta("Sub-image starting point (X)", subImageStartX); addGlobalMeta("Sub-image starting point (Y)", subImageStartY); addGlobalMeta("Sub-image starting point (Z)", subImageStartZ); addGlobalMeta("Pixel sampling size (X)", pixelSamplingX); addGlobalMeta("Pixel sampling size (Y)", pixelSamplingY); addGlobalMeta("Pixel sampling size (Z)", pixelSamplingZ); addGlobalMeta("X element length (in um)", pixX); addGlobalMeta("Y element length (in um)", pixY); addGlobalMeta("Z element length (in um)", pixZ); addGlobalMeta("X axis angle", xAxisAngle); addGlobalMeta("Y axis angle", yAxisAngle); addGlobalMeta("Z axis angle", zAxisAngle); addGlobalMeta("Column axis sequence", xAxisSeq); addGlobalMeta("Row axis sequence", yAxisSeq); addGlobalMeta("Section axis sequence", zAxisSeq); addGlobalMeta("Image Type", imageType); addGlobalMeta("Lens ID Number", lensID); addGlobalMeta("X axis tilt angle", xTiltAngle); addGlobalMeta("Y axis tilt angle", yTiltAngle); addGlobalMeta("Z axis tilt angle", zTiltAngle); addGlobalMeta("Wavelength " + (i + 1) + " (in nm)", waves[i]); addGlobalMeta("X origin (in um)", xOrigin);
addGlobalMeta(prefix + " " + key, value); String objectiveID = "Objective:" + value; store.setObjectiveID(objectiveID, 0, 0); for (int series=0; series<getSeriesCount(); series++) { store.setObjectiveSettingsID(objectiveID, series); Length sizeX = FormatTools.getPhysicalSizeX(size); if (sizeX != null) { for (int series=0; series<getSeriesCount(); series++) { store.setPixelsPhysicalSizeX(sizeX, series); Length sizeY = FormatTools.getPhysicalSizeY(size); if (sizeY != null) { for (int series=0; series<getSeriesCount(); series++) { store.setPixelsPhysicalSizeY(sizeY, series); Length sizeZ = FormatTools.getPhysicalSizeZ(size); if (sizeZ != null) { for (int series=0; series<getSeriesCount(); series++) { store.setPixelsPhysicalSizeZ(sizeZ, series); String detectorID = MetadataTools.createLSID("Detector", 0, 0); store.setDetectorID(detectorID, 0, 0); for (int series=0; series<getSeriesCount(); series++) { for (int c=0; c<getSizeC(); c++) { store.setDetectorSettingsBinning( MetadataTools.getBinning(value), series, c);
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); int[] coords = getZCTCoords(no); long offset = getPlaneByteOffset(coords[0], coords[1], coords[2]); if (offset < in.length()) { in.seek(offset); readPlane(in, x, getSizeY() - h - y, w, h, buf); // reverse the order of the rows // planes are stored with the origin in the lower-left corner byte[] tmp = new byte[w * FormatTools.getBytesPerPixel(getPixelType())]; for (int row=0; row<h/2; row++) { int src = row * tmp.length; int dest = (h - row - 1) * tmp.length; System.arraycopy(buf, src, tmp, 0, tmp.length); System.arraycopy(buf, dest, buf, src, tmp.length); System.arraycopy(tmp, 0, buf, dest, tmp.length); } } return buf; }
private IFormatReader getReader(String file, boolean omexml) throws FormatException, IOException { IFormatReader pnl = new DeltavisionReader(); if (checkSuffix(file, "tif")) { pnl = new MetamorphReader(); } if (omexml) { IMetadata metadata; try { metadata = service.createOMEXMLMetadata(); } catch (ServiceException exc) { throw new FormatException("Could not create OME-XML store.", exc); } pnl.setMetadataStore(metadata); } pnl.setId(file); return pnl; }
for (int series=0; series<getSeriesCount(); series++) { store.setObjectiveSettingsID(objectiveID, series);
MetadataStore store = makeFilterMetadata(); String imageSequence = getImageSequence(sequence); String pixel = getPixelString(filePixelType); m.pixelType = getPixelType(filePixelType); getSizeX() * getSizeY() * FormatTools.getBytesPerPixel(getPixelType()); int realPlaneCount = (int) ((in.length() - HEADER_LENGTH - extSize) / planeSize); if (realPlaneCount < getImageCount() && !truncatedFileFlag) { LOGGER.debug("Truncated file"); m.imageCount = realPlaneCount; else if (getDimensionOrder().indexOf('Z') < getDimensionOrder().indexOf('T')) if (getImageCount() > (sizeZ * sizeC * sizeT)) { m.imageCount = imageCount; sizeC = rawSizeC == 0 ? 1 : rawSizeC; sizeT = rawSizeT == 0 ? 1 : rawSizeT; sizeZ = getImageCount() / (sizeC * sizeT); setOffsetInfo(sequence, getSizeZ(), getSizeC(), getSizeT()); extHdrFields = new DVExtHdrFields[getSizeZ()][getSizeC()][getSizeT()]; ndFilters = new Double[getSizeC()]; boolean hasZeroX = false;