Search in sources :

Example 1 with Channel

use of ome.xml.model.Channel 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 2 with Channel

use of ome.xml.model.Channel 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 3 with Channel

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

the class SPWModelMock method makeImage.

private Image makeImage(int index) {
    // <Instrument/> for later linking, etc.
    Instrument instrument = ome.getInstrument(0);
    // Create <Image/>
    Image image = new Image();
    image.setID("Image:" + index);
    CommentAnnotation commentAnnotation = new CommentAnnotation();
    commentAnnotation.setID("Annotation:" + index);
    commentAnnotation.setNamespace(GENERAL_ANNOTATION_NAMESPACE);
    commentAnnotation.setValue("Image:" + index + " annotation.");
    annotations.addCommentAnnotation(commentAnnotation);
    image.linkAnnotation(commentAnnotation);
    // Create <Pixels/>
    Pixels pixels = new Pixels();
    pixels.setID("Pixels:" + index);
    pixels.setSizeX(new PositiveInteger(SIZE_X));
    pixels.setSizeY(new PositiveInteger(SIZE_Y));
    pixels.setSizeZ(new PositiveInteger(SIZE_Z));
    pixels.setSizeC(new PositiveInteger(SIZE_C));
    pixels.setSizeT(new PositiveInteger(SIZE_T));
    pixels.setDimensionOrder(DIMENSION_ORDER);
    pixels.setType(PIXEL_TYPE);
    // Create <BinData/>
    for (int i = 0; i < SIZE_Z * SIZE_C * SIZE_T; i++) {
        BinData binData = new BinData();
        binData.setBigEndian(false);
        binData.setCompression(Compression.NONE);
        binData.setLength(new NonNegativeLong((long) (SIZE_X * SIZE_Y * BYTES_PER_PIXEL)));
        pixels.addBinData(binData);
    }
    // Create <Channel/> under <Pixels/>
    for (int i = 0; i < SIZE_C; i++) {
        Channel channel = new Channel();
        channel.setID("Channel:" + i);
        // Create <LightSourceSettings/> and link to <Channel/>
        LightSourceSettings settings = new LightSourceSettings();
        settings.setID(LIGHTSOURCE_LASER_ID);
        channel.setLightSourceSettings(settings);
        // Create <LightPath/> and link to <Channel/>
        LightPath lightPath = new LightPath();
        lightPath.linkEmissionFilter(instrument.getFilter(0));
        lightPath.linkExcitationFilter(instrument.getFilter(1));
        channel.setLightPath(lightPath);
        pixels.addChannel(channel);
    }
    // Put <Pixels/> under <Image/>
    image.setPixels(pixels);
    // Link <Instrument/> to <Image/>
    image.linkInstrument(instrument);
    // Create <ObjectiveSettings/> and link to <Image/>
    ObjectiveSettings settings = new ObjectiveSettings();
    settings.setID(OBJECTIVE_ID);
    image.setObjectiveSettings(settings);
    return image;
}
Also used : PositiveInteger(ome.xml.model.primitives.PositiveInteger) LightSourceSettings(ome.xml.model.LightSourceSettings) NonNegativeLong(ome.xml.model.primitives.NonNegativeLong) LightPath(ome.xml.model.LightPath) CommentAnnotation(ome.xml.model.CommentAnnotation) BinData(ome.xml.model.BinData) Channel(ome.xml.model.Channel) ObjectiveSettings(ome.xml.model.ObjectiveSettings) Instrument(ome.xml.model.Instrument) Image(ome.xml.model.Image) Pixels(ome.xml.model.Pixels)

Example 4 with Channel

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

the class BaseModelMock method makeImage.

private Image makeImage(int index) {
    // Create <Image/>
    Image image = new Image();
    image.setID("Image:" + index);
    // Create <Pixels/>
    Pixels pixels = new Pixels();
    pixels.setID("Pixels:" + index);
    pixels.setSizeX(new PositiveInteger(SIZE_X));
    pixels.setSizeY(new PositiveInteger(SIZE_Y));
    pixels.setSizeZ(new PositiveInteger(SIZE_Z));
    pixels.setSizeC(new PositiveInteger(SIZE_C));
    pixels.setSizeT(new PositiveInteger(SIZE_T));
    pixels.setDimensionOrder(DIMENSION_ORDER);
    pixels.setType(PIXEL_TYPE);
    // Create <BinData/>
    for (int i = 0; i < SIZE_Z * SIZE_C * SIZE_T; i++) {
        BinData binData = new BinData();
        binData.setBigEndian(false);
        binData.setCompression(Compression.NONE);
        binData.setLength(new NonNegativeLong((long) (SIZE_X * SIZE_Y * BYTES_PER_PIXEL)));
        pixels.addBinData(binData);
    }
    // Create <Channel/> under <Pixels/>
    for (int i = 0; i < SIZE_C; i++) {
        Channel channel = new Channel();
        channel.setID("Channel:" + i);
        pixels.addChannel(channel);
    }
    // Put <Pixels/> under <Image/>
    image.setPixels(pixels);
    return image;
}
Also used : PositiveInteger(ome.xml.model.primitives.PositiveInteger) NonNegativeLong(ome.xml.model.primitives.NonNegativeLong) BinData(ome.xml.model.BinData) Channel(ome.xml.model.Channel) Image(ome.xml.model.Image) Pixels(ome.xml.model.Pixels)

Example 5 with Channel

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

the class OMEXMLServiceImpl method removeChannels.

/**
 * @see OMEXMLService#removeChannels(OMEXMLMetadata, int, int)
 */
@Override
public void removeChannels(OMEXMLMetadata omexmlMeta, int image, int sizeC) {
    omexmlMeta.resolveReferences();
    OMEXMLMetadataRoot root = (OMEXMLMetadataRoot) omexmlMeta.getRoot();
    Pixels img = root.getImage(image).getPixels();
    List<Channel> channels = img.copyChannelList();
    for (int c = 0; c < channels.size(); c++) {
        Channel channel = channels.get(c);
        if (channel.getID() == null || c >= sizeC) {
            img.removeChannel(channel);
        }
    }
    omexmlMeta.setRoot(root);
}
Also used : OMEXMLMetadataRoot(ome.xml.meta.OMEXMLMetadataRoot) Channel(ome.xml.model.Channel) Pixels(ome.xml.model.Pixels)

Aggregations

Channel (ome.xml.model.Channel)11 Pixels (ome.xml.model.Pixels)10 Image (ome.xml.model.Image)8 PositiveInteger (ome.xml.model.primitives.PositiveInteger)4 Test (org.testng.annotations.Test)4 Instrument (ome.xml.model.Instrument)3 LightSourceSettings (ome.xml.model.LightSourceSettings)3 XMLAnnotation (ome.xml.model.XMLAnnotation)3 ArrayList (java.util.ArrayList)2 OMEXMLMetadataRoot (ome.xml.meta.OMEXMLMetadataRoot)2 Annotation (ome.xml.model.Annotation)2 BinData (ome.xml.model.BinData)2 BooleanAnnotation (ome.xml.model.BooleanAnnotation)2 CommentAnnotation (ome.xml.model.CommentAnnotation)2 ListAnnotation (ome.xml.model.ListAnnotation)2 NonNegativeLong (ome.xml.model.primitives.NonNegativeLong)2 BeforeClass (org.testng.annotations.BeforeClass)2 File (java.io.File)1 Enumeration (java.util.Enumeration)1 HashSet (java.util.HashSet)1