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