Search in sources :

Example 1 with Well

use of ome.xml.model.Well in project bioformats by openmicroscopy.

the class InOutCurrentTest method testValidWellSamples.

@Test(dependsOnMethods = { "testValidPlateNode" })
public void testValidWellSamples() {
    Plate plate = ome.getPlate(0);
    Integer wellSampleIndex = 0;
    for (int row = 0; row < plate.getRows().getValue(); row++) {
        for (int col = 0; col < plate.getColumns().getValue(); col++) {
            Well well = plate.getWell(row * plate.getColumns().getValue() + col);
            assertEquals(1, well.sizeOfWellSampleList());
            WellSample sample = well.getWellSample(0);
            assertNotNull(sample);
            assertEquals(String.format("WellSample:%d_%d", row, col), sample.getID());
            assertEquals(wellSampleIndex, sample.getIndex().getValue());
            Image image = sample.getLinkedImage();
            assertNotNull(image);
            assertEquals(IMAGE_ID, image.getID());
            wellSampleIndex++;
        }
    }
}
Also used : PositiveInteger(ome.xml.model.primitives.PositiveInteger) Well(ome.xml.model.Well) WellSample(ome.xml.model.WellSample) Image(ome.xml.model.Image) Plate(ome.xml.model.Plate) Test(org.testng.annotations.Test)

Example 2 with Well

use of ome.xml.model.Well in project bioformats by openmicroscopy.

the class InOutCurrentTest method testValidPlateNode.

@Test(dependsOnMethods = { "testValidOMENode" })
public void testValidPlateNode() {
    Plate plate = ome.getPlate(0);
    assertNotNull(plate);
    assertEquals(PLATE_ID, plate.getID());
    assertEquals(plate.getRows(), WELL_ROWS);
    assertEquals(plate.getColumns(), WELL_COLS);
    assertEquals(plate.getRowNamingConvention(), WELL_ROW);
    assertEquals(plate.getColumnNamingConvention(), WELL_COL);
    assertEquals(plate.sizeOfWellList(), WELL_ROWS.getValue() * WELL_COLS.getValue());
    for (Integer row = 0; row < WELL_ROWS.getValue(); row++) {
        for (Integer col = 0; col < WELL_COLS.getValue(); col++) {
            Well well = plate.getWell(row * WELL_COLS.getValue() + col);
            assertNotNull(well);
            assertEquals(String.format("Well:%d_%d", row, col), well.getID());
            assertEquals(well.getRow(), row);
            assertEquals(well.getColumn(), col);
        }
    }
}
Also used : PositiveInteger(ome.xml.model.primitives.PositiveInteger) Well(ome.xml.model.Well) Plate(ome.xml.model.Plate) Test(org.testng.annotations.Test)

Example 3 with Well

use of ome.xml.model.Well in project bioformats by openmicroscopy.

the class ObjectBasedOMEModelMock method makePlate.

private Plate makePlate() {
    Plate plate = new Plate();
    plate.setID(InOutCurrentTest.PLATE_ID);
    plate.setRows(InOutCurrentTest.WELL_ROWS);
    plate.setColumns(InOutCurrentTest.WELL_COLS);
    plate.setRowNamingConvention(InOutCurrentTest.WELL_ROW);
    plate.setColumnNamingConvention(InOutCurrentTest.WELL_COL);
    TimestampAnnotation plateAnnotation = new TimestampAnnotation();
    plateAnnotation.setID(InOutCurrentTest.PLATE_ANNOTATION_ID);
    plateAnnotation.setValue(new Timestamp(InOutCurrentTest.PLATE_ANNOTATION_VALUE));
    plateAnnotation.setNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE);
    plate.linkAnnotation(plateAnnotation);
    annotations.addTimestampAnnotation(plateAnnotation);
    int wellSampleIndex = 0;
    for (int row = 0; row < InOutCurrentTest.WELL_ROWS.getValue(); row++) {
        for (int col = 0; col < InOutCurrentTest.WELL_COLS.getValue(); col++) {
            Well well = new Well();
            well.setID(String.format("Well:%d_%d", row, col));
            well.setRow(new NonNegativeInteger(row));
            well.setColumn(new NonNegativeInteger(col));
            if (row == 0 && col == 0) {
                LongAnnotation annotation = new LongAnnotation();
                annotation.setID(InOutCurrentTest.WELL_ANNOTATION_ID);
                annotation.setValue(InOutCurrentTest.WELL_ANNOTATION_VALUE);
                annotation.setNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE);
                well.linkAnnotation(annotation);
                annotations.addLongAnnotation(annotation);
            }
            WellSample sample = new WellSample();
            sample.setID(String.format("WellSample:%d_%d", row, col));
            sample.setIndex(new NonNegativeInteger(wellSampleIndex));
            sample.linkImage(ome.getImage(0));
            well.addWellSample(sample);
            plate.addWell(well);
            wellSampleIndex++;
        }
    }
    return plate;
}
Also used : TimestampAnnotation(ome.xml.model.TimestampAnnotation) NonNegativeInteger(ome.xml.model.primitives.NonNegativeInteger) Well(ome.xml.model.Well) LongAnnotation(ome.xml.model.LongAnnotation) WellSample(ome.xml.model.WellSample) Timestamp(ome.xml.model.primitives.Timestamp) Plate(ome.xml.model.Plate)

Example 4 with Well

use of ome.xml.model.Well in project bioformats by openmicroscopy.

the class FileWriteSPW method cleanup.

/**
 * Close the file writer.
 */
public void cleanup() {
    // No of planes expected for each image = 1 if not FLIM
    int validPlanes = 1;
    if (delays != null) {
        validPlanes = sizet;
    }
    OMEXMLMetadataRoot root = (OMEXMLMetadataRoot) omexml.getRoot();
    Plate plate = root.getPlate(0);
    StructuredAnnotations anns = root.getStructuredAnnotations();
    ArrayList<Image> invalidImages = new ArrayList<>();
    // if not record those images as being invalid
    for (int i = 0; i < expectedImages.length; i++) {
        if (expectedImages[i] < validPlanes) {
            Image im = root.getImage(i);
            invalidImages.add(im);
            // remove modulo Annotation if FLIM
            if (delays != null) {
                XMLAnnotation ann = (XMLAnnotation) im.getLinkedAnnotation(0);
                anns.removeXMLAnnotation(ann);
            }
        }
    }
    // Now remove all limked wellSnmples and then invalid images
    for (int i = 0; i < invalidImages.size(); i++) {
        Image im = invalidImages.get(i);
        List<WellSample> list = im.copyLinkedWellSampleList();
        if (!list.isEmpty()) {
            WellSample wellSample = im.getLinkedWellSample(0);
            Well well = wellSample.getWell();
            well.removeWellSample(wellSample);
        }
        root.removeImage(im);
    }
    if (writer != null) {
        try {
            writer.close();
        } catch (IOException e) {
            System.err.println("Failed to close file writer.");
        }
    }
}
Also used : OMEXMLMetadataRoot(ome.xml.meta.OMEXMLMetadataRoot) Well(ome.xml.model.Well) ArrayList(java.util.ArrayList) StructuredAnnotations(ome.xml.model.StructuredAnnotations) XMLAnnotation(ome.xml.model.XMLAnnotation) WellSample(ome.xml.model.WellSample) IOException(java.io.IOException) Image(ome.xml.model.Image) Plate(ome.xml.model.Plate)

Example 5 with Well

use of ome.xml.model.Well in project bioformats by openmicroscopy.

the class SPWModelMock method makePlate.

private Plate makePlate() {
    Plate plate = new Plate();
    plate.setName(PLATE_NAME);
    plate.setID(PLATE_ID);
    plate.setRows(WELL_ROWS);
    plate.setColumns(WELL_COLS);
    plate.setRowNamingConvention(WELL_ROW);
    plate.setColumnNamingConvention(WELL_COL);
    int wellSampleIndex = 0;
    for (int row = 0; row < WELL_ROWS.getValue(); row++) {
        for (int col = 0; col < WELL_COLS.getValue(); col++) {
            Well well = new Well();
            well.setID(String.format("Well:%d_%d", row, col));
            well.setRow(new NonNegativeInteger(row));
            well.setColumn(new NonNegativeInteger(col));
            WellSample sample = new WellSample();
            sample.setID(String.format("WellSample:%d_%d", row, col));
            sample.setIndex(new NonNegativeInteger(wellSampleIndex));
            sample.linkImage(ome.getImage(wellSampleIndex));
            well.addWellSample(sample);
            plate.addWell(well);
            wellSampleIndex++;
        }
    }
    return plate;
}
Also used : NonNegativeInteger(ome.xml.model.primitives.NonNegativeInteger) Well(ome.xml.model.Well) WellSample(ome.xml.model.WellSample) Plate(ome.xml.model.Plate)

Aggregations

Plate (ome.xml.model.Plate)6 Well (ome.xml.model.Well)6 WellSample (ome.xml.model.WellSample)4 Test (org.testng.annotations.Test)3 Image (ome.xml.model.Image)2 NonNegativeInteger (ome.xml.model.primitives.NonNegativeInteger)2 PositiveInteger (ome.xml.model.primitives.PositiveInteger)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 OMEXMLMetadataRoot (ome.xml.meta.OMEXMLMetadataRoot)1 LongAnnotation (ome.xml.model.LongAnnotation)1 OME (ome.xml.model.OME)1 StructuredAnnotations (ome.xml.model.StructuredAnnotations)1 TimestampAnnotation (ome.xml.model.TimestampAnnotation)1 XMLAnnotation (ome.xml.model.XMLAnnotation)1 Timestamp (ome.xml.model.primitives.Timestamp)1