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;
}
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);
}
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;
}
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;
}
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);
}
Aggregations