Search in sources :

Example 6 with Image

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

the class XMLAnnotationTest method testValidXMLAnnotation.

@Test
public void testValidXMLAnnotation() throws EnumerationException {
    assertNotNull(ome);
    assertEquals(1, ome.sizeOfImageList());
    Image image = ome.getImage(0);
    Pixels pixels = image.getPixels();
    assertNotNull(pixels);
    assertEquals(3, pixels.sizeOfChannelList());
    Channel channel = pixels.getChannel(0);
    assertEquals(1, channel.sizeOfLinkedAnnotationList());
    Annotation annotation = channel.getLinkedAnnotation(0);
    assertEquals(XMLAnnotation.class, annotation.getClass());
    String annotationValue = ((XMLAnnotation) annotation).getValue();
    // normalize line endings if the test is run on Windows
    annotationValue = annotationValue.replaceAll("\r\n", "\n");
    assertEquals("<TestData>\n                    <key>foo</key>\n\t\t\t\t\t<value>bar</value>\n                </TestData>", annotationValue);
}
Also used : Channel(ome.xml.model.Channel) XMLAnnotation(ome.xml.model.XMLAnnotation) Image(ome.xml.model.Image) Pixels(ome.xml.model.Pixels) XMLAnnotation(ome.xml.model.XMLAnnotation) Annotation(ome.xml.model.Annotation) Test(org.testng.annotations.Test)

Example 7 with Image

use of ome.xml.model.Image 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 8 with Image

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

the class Upgrade201106Test method validateUpgrade.

@Test
public void validateUpgrade() throws ServiceException {
    assertEquals(1, ome.sizeOfImageList());
    Image image = ome.getImage(0);
    assertNotNull(image.getAcquisitionDate());
    assertEquals(1, ome.sizeOfROIList());
    ROI roi = ome.getROI(0);
    Union union = roi.getUnion();
    assertEquals(1, union.sizeOfShapeList());
    Shape shape = union.getShape(0);
    assertTrue(shape instanceof Label);
    assertNotNull(shape.getText());
}
Also used : Shape(ome.xml.model.Shape) Label(ome.xml.model.Label) Image(ome.xml.model.Image) ROI(ome.xml.model.ROI) Union(ome.xml.model.Union) Test(org.testng.annotations.Test)

Example 9 with Image

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

the class Schema2011_06_TO_2012_06_Test method testDate.

@Test
public void testDate() {
    Assert.assertNotNull(ome);
    Assert.assertEquals(1, ome.sizeOfImageList());
    Image image = ome.getImage(0);
    Assert.assertNotNull(image);
    Assert.assertEquals(IMAGE_DATE, image.getAcquisitionDate());
}
Also used : Image(ome.xml.model.Image) Test(org.testng.annotations.Test)

Example 10 with Image

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

the class ImagingEnvironmentMapTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    // Add an Image/Pixels
    Image image = new Image();
    image.setID("Image:0");
    Pixels pixels = new Pixels();
    pixels.setID("Pixels:0");
    image.setPixels(pixels);
    // Add an ImagingEnvironment with an Map
    ImagingEnvironment imagingEnvironment = new ImagingEnvironment();
    List<MapPair> map = new ArrayList<MapPair>();
    map.add(new MapPair("a", "1"));
    map.add(new MapPair("d", "2"));
    map.add(new MapPair("c", "3"));
    map.add(new MapPair("b", "4"));
    map.add(new MapPair("e", "5"));
    map.add(new MapPair("c", "6"));
    assertEquals(6, map.size());
    imagingEnvironment.setMap(map);
    image.setImagingEnvironment(imagingEnvironment);
    ome.addImage(image);
}
Also used : MapPair(ome.xml.model.MapPair) ArrayList(java.util.ArrayList) ImagingEnvironment(ome.xml.model.ImagingEnvironment) Image(ome.xml.model.Image) Pixels(ome.xml.model.Pixels) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

Image (ome.xml.model.Image)29 Pixels (ome.xml.model.Pixels)15 OMEXMLMetadataRoot (ome.xml.meta.OMEXMLMetadataRoot)11 Test (org.testng.annotations.Test)10 Channel (ome.xml.model.Channel)8 PositiveInteger (ome.xml.model.primitives.PositiveInteger)8 ServiceException (loci.common.services.ServiceException)7 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 FormatException (loci.formats.FormatException)5 Instrument (ome.xml.model.Instrument)5 DependencyException (loci.common.services.DependencyException)4 XMLAnnotation (ome.xml.model.XMLAnnotation)4 BeforeClass (org.testng.annotations.BeforeClass)4 Node (org.w3c.dom.Node)4 NodeList (org.w3c.dom.NodeList)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)3 TransformerException (javax.xml.transform.TransformerException)3 Location (loci.common.Location)3