Search in sources :

Example 1 with Pixels

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

the class OMEXMLServiceImpl method addMetadataOnly.

/**
 * @see OMEXMLService#addMetadataOnly(OMEXMLMetadata, int, boolean)
 */
public void addMetadataOnly(OMEXMLMetadata omexmlMeta, int image, boolean resolve) {
    if (resolve) {
        omexmlMeta.resolveReferences();
    }
    MetadataOnly meta = new MetadataOnly();
    OMEXMLMetadataRoot root = (OMEXMLMetadataRoot) omexmlMeta.getRoot();
    Pixels pix = root.getImage(image).getPixels();
    pix.setMetadataOnly(meta);
}
Also used : MetadataOnly(ome.xml.model.MetadataOnly) OMEXMLMetadataRoot(ome.xml.meta.OMEXMLMetadataRoot) Pixels(ome.xml.model.Pixels)

Example 2 with Pixels

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

the class OMEXMLServiceImpl method removeBinData.

/**
 * @see OMEXMLService#removeBinData(OMEXMLMetadata)
 */
@Override
public void removeBinData(OMEXMLMetadata omexmlMeta) {
    omexmlMeta.resolveReferences();
    OMEXMLMetadataRoot root = (OMEXMLMetadataRoot) omexmlMeta.getRoot();
    List<Image> images = root.copyImageList();
    for (Image img : images) {
        Pixels pix = img.getPixels();
        List<BinData> binData = pix.copyBinDataList();
        for (BinData bin : binData) {
            pix.removeBinData(bin);
        }
        pix.setMetadataOnly(null);
    }
    omexmlMeta.setRoot(root);
}
Also used : OMEXMLMetadataRoot(ome.xml.meta.OMEXMLMetadataRoot) BinData(ome.xml.model.BinData) Image(ome.xml.model.Image) Pixels(ome.xml.model.Pixels)

Example 3 with Pixels

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

the class ObjectBasedOMEModelMock method makeImage.

private Image makeImage() {
    // Create <Image/>
    Image image = new Image();
    image.setID(InOutCurrentTest.IMAGE_ID);
    ListAnnotation listAnnotation = new ListAnnotation();
    listAnnotation.setID(InOutCurrentTest.IMAGE_LIST_ANNOTATION_ID);
    listAnnotation.setNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE);
    annotations.addListAnnotation(listAnnotation);
    BooleanAnnotation annotation = new BooleanAnnotation();
    annotation.setID(InOutCurrentTest.IMAGE_ANNOTATION_ID);
    annotation.setValue(InOutCurrentTest.IMAGE_ANNOTATION_VALUE);
    annotation.setNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE);
    listAnnotation.linkAnnotation(annotation);
    image.linkAnnotation(listAnnotation);
    annotations.addBooleanAnnotation(annotation);
    // Create <Pixels/>
    Pixels pixels = new Pixels();
    pixels.setID(InOutCurrentTest.PIXELS_ID);
    pixels.setSizeX(new PositiveInteger(InOutCurrentTest.SIZE_X));
    pixels.setSizeY(new PositiveInteger(InOutCurrentTest.SIZE_Y));
    pixels.setSizeZ(new PositiveInteger(InOutCurrentTest.SIZE_Z));
    pixels.setSizeC(new PositiveInteger(InOutCurrentTest.SIZE_C));
    pixels.setSizeT(new PositiveInteger(InOutCurrentTest.SIZE_T));
    pixels.setDimensionOrder(InOutCurrentTest.DIMENSION_ORDER);
    pixels.setType(InOutCurrentTest.PIXEL_TYPE);
    // Create <TiffData/>
    TiffData tiffData = new TiffData();
    // Create <UUID/>
    UUID uuid = new UUID();
    uuid.setValue(InOutCurrentTest.TIFF_DATA_UUID);
    tiffData.setUUID(uuid);
    pixels.addTiffData(tiffData);
    // Create <Channel/> under <Pixels/>
    for (int i = 0; i < InOutCurrentTest.SIZE_C; i++) {
        Channel channel = new Channel();
        channel.setID("Channel:" + i);
        if (i == 0) {
            XMLAnnotation channelAnnotation = new XMLAnnotation();
            channelAnnotation.setID(InOutCurrentTest.CHANNEL_ANNOTATION_ID);
            channelAnnotation.setValue(InOutCurrentTest.CHANNEL_ANNOTATION_VALUE);
            channelAnnotation.setNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE);
            channel.linkAnnotation(channelAnnotation);
            annotations.addXMLAnnotation(channelAnnotation);
        }
        pixels.addChannel(channel);
    }
    // Put <Pixels/> under <Image/>
    image.setPixels(pixels);
    return image;
}
Also used : BooleanAnnotation(ome.xml.model.BooleanAnnotation) PositiveInteger(ome.xml.model.primitives.PositiveInteger) TiffData(ome.xml.model.TiffData) Channel(ome.xml.model.Channel) ListAnnotation(ome.xml.model.ListAnnotation) XMLAnnotation(ome.xml.model.XMLAnnotation) Image(ome.xml.model.Image) UUID(ome.xml.model.UUID) Pixels(ome.xml.model.Pixels)

Example 4 with Pixels

use of ome.xml.model.Pixels 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 5 with Pixels

use of ome.xml.model.Pixels 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

Pixels (ome.xml.model.Pixels)19 Image (ome.xml.model.Image)15 Channel (ome.xml.model.Channel)10 OMEXMLMetadataRoot (ome.xml.meta.OMEXMLMetadataRoot)6 PositiveInteger (ome.xml.model.primitives.PositiveInteger)5 Test (org.testng.annotations.Test)5 ArrayList (java.util.ArrayList)4 BeforeClass (org.testng.annotations.BeforeClass)4 BinData (ome.xml.model.BinData)3 Instrument (ome.xml.model.Instrument)3 LightSourceSettings (ome.xml.model.LightSourceSettings)3 MapPair (ome.xml.model.MapPair)3 Location (loci.common.Location)2 ServiceException (loci.common.services.ServiceException)2 FormatException (loci.formats.FormatException)2 XMLAnnotation (ome.xml.model.XMLAnnotation)2 NonNegativeLong (ome.xml.model.primitives.NonNegativeLong)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1