use of ome.xml.model.Image 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.Image in project bioformats by openmicroscopy.
the class FileWriteSPW method cleanup.
/**
* Close the file writer.
*/
public void cleanup() {
// No of planes expected for each image = 1 if not FLIM
int validPlanes = 1;
if (delays != null) {
validPlanes = sizet;
}
OMEXMLMetadataRoot root = (OMEXMLMetadataRoot) omexml.getRoot();
Plate plate = root.getPlate(0);
StructuredAnnotations anns = root.getStructuredAnnotations();
ArrayList<Image> invalidImages = new ArrayList<>();
// if not record those images as being invalid
for (int i = 0; i < expectedImages.length; i++) {
if (expectedImages[i] < validPlanes) {
Image im = root.getImage(i);
invalidImages.add(im);
// remove modulo Annotation if FLIM
if (delays != null) {
XMLAnnotation ann = (XMLAnnotation) im.getLinkedAnnotation(0);
anns.removeXMLAnnotation(ann);
}
}
}
// Now remove all limked wellSnmples and then invalid images
for (int i = 0; i < invalidImages.size(); i++) {
Image im = invalidImages.get(i);
List<WellSample> list = im.copyLinkedWellSampleList();
if (!list.isEmpty()) {
WellSample wellSample = im.getLinkedWellSample(0);
Well well = wellSample.getWell();
well.removeWellSample(wellSample);
}
root.removeImage(im);
}
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
System.err.println("Failed to close file writer.");
}
}
}
use of ome.xml.model.Image in project bioformats by openmicroscopy.
the class Upgrade201106Test method validateUpgrade.
@Test
public void validateUpgrade() throws ServiceException {
assertEquals(1, ome.sizeOfImageList());
Image image = ome.getImage(0);
assertNotNull(image.getAcquisitionDate());
assertEquals(1, ome.sizeOfROIList());
ROI roi = ome.getROI(0);
Union union = roi.getUnion();
assertEquals(1, union.sizeOfShapeList());
Shape shape = union.getShape(0);
assertTrue(shape instanceof Label);
assertNotNull(shape.getText());
}
use of ome.xml.model.Image in project bioformats by openmicroscopy.
the class Schema2011_06_TO_2012_06_Test method testDate.
@Test
public void testDate() {
Assert.assertNotNull(ome);
Assert.assertEquals(1, ome.sizeOfImageList());
Image image = ome.getImage(0);
Assert.assertNotNull(image);
Assert.assertEquals(IMAGE_DATE, image.getAcquisitionDate());
}
use of ome.xml.model.Image 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