Search in sources :

Example 11 with Pixels

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

Example 12 with Pixels

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

the class PumpWithLightSourceSettingsTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    Instrument instrument = new Instrument();
    instrument.setID("Instrument:0");
    // Add a Laser with an Arc pump
    Laser laser = new Laser();
    laser.setID("Laser:0");
    Arc pump = new Arc();
    pump.setID("Arc:0");
    laser.linkPump(pump);
    instrument.addLightSource(laser);
    instrument.addLightSource(pump);
    ome.addInstrument(instrument);
    // Add an Image/Pixels with a LightSourceSettings reference to the Pump
    // on one of its channels.
    Image image = new Image();
    image.setID("Image:0");
    Pixels pixels = new Pixels();
    pixels.setID("Pixels:0");
    Channel channel = new Channel();
    channel.setID("Channel:0");
    LightSourceSettings settings = new LightSourceSettings();
    settings.setID("Arc:0");
    channel.setLightSourceSettings(settings);
    pixels.addChannel(channel);
    image.setPixels(pixels);
    ome.addImage(image);
}
Also used : LightSourceSettings(ome.xml.model.LightSourceSettings) Arc(ome.xml.model.Arc) Laser(ome.xml.model.Laser) Channel(ome.xml.model.Channel) Instrument(ome.xml.model.Instrument) Image(ome.xml.model.Image) Pixels(ome.xml.model.Pixels) BeforeClass(org.testng.annotations.BeforeClass)

Example 13 with Pixels

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

the class GenericExcitationMapTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    Instrument instrument = new Instrument();
    instrument.setID("Instrument:0");
    // Add a GenericExcitationSource with an Map
    GenericExcitationSource geSource = new GenericExcitationSource();
    geSource.setID("LightSource:0");
    List<MapPair> dataMap = new ArrayList<MapPair>();
    dataMap.add(new MapPair("a", "1"));
    dataMap.add(new MapPair("d", "2"));
    dataMap.add(new MapPair("c", "3"));
    dataMap.add(new MapPair("b", "4"));
    dataMap.add(new MapPair("e", "5"));
    dataMap.add(new MapPair("c", "6"));
    assertEquals(6, dataMap.size());
    geSource.setMap(dataMap);
    instrument.addLightSource(geSource);
    ome.addInstrument(instrument);
    // Add an Image/Pixels with a LightSourceSettings reference to the
    // GenericExcitationSource on one of its channels.
    Image image = new Image();
    image.setID("Image:0");
    Pixels pixels = new Pixels();
    pixels.setID("Pixels:0");
    Channel channel = new Channel();
    channel.setID("Channel:0");
    LightSourceSettings settings = new LightSourceSettings();
    settings.setID("LightSource:0");
    channel.setLightSourceSettings(settings);
    pixels.addChannel(channel);
    image.setPixels(pixels);
    ome.addImage(image);
}
Also used : MapPair(ome.xml.model.MapPair) LightSourceSettings(ome.xml.model.LightSourceSettings) GenericExcitationSource(ome.xml.model.GenericExcitationSource) Channel(ome.xml.model.Channel) Instrument(ome.xml.model.Instrument) ArrayList(java.util.ArrayList) Image(ome.xml.model.Image) Pixels(ome.xml.model.Pixels) BeforeClass(org.testng.annotations.BeforeClass)

Example 14 with Pixels

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

the class InOutCurrentTest method testValidPixelsNode.

@Test(dependsOnMethods = { "testValidImageNode" })
public void testValidPixelsNode() {
    Pixels pixels = ome.getImage(0).getPixels();
    assertEquals(SIZE_X, pixels.getSizeX().getValue());
    assertEquals(SIZE_Y, pixels.getSizeY().getValue());
    assertEquals(SIZE_Z, pixels.getSizeZ().getValue());
    assertEquals(SIZE_C, pixels.getSizeC().getValue());
    assertEquals(SIZE_T, pixels.getSizeT().getValue());
    assertEquals(DIMENSION_ORDER, pixels.getDimensionOrder());
    assertEquals(PIXEL_TYPE, pixels.getType());
    assertEquals(1, pixels.sizeOfTiffDataList());
}
Also used : Pixels(ome.xml.model.Pixels) Test(org.testng.annotations.Test)

Example 15 with Pixels

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

the class InOutCurrentTest method testValidChannelNode.

@Test(dependsOnMethods = { "testValidPixelsNode" })
public void testValidChannelNode() {
    Pixels pixels = ome.getImage(0).getPixels();
    assertEquals(3, pixels.sizeOfChannelList());
    for (Channel channel : pixels.copyChannelList()) {
        assertNotNull(channel.getID());
    }
}
Also used : Channel(ome.xml.model.Channel) Pixels(ome.xml.model.Pixels) Test(org.testng.annotations.Test)

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