use of ome.xml.model.Well in project bioformats by openmicroscopy.
the class InOutCurrentTest method testValidWellSamples.
@Test(dependsOnMethods = { "testValidPlateNode" })
public void testValidWellSamples() {
Plate plate = ome.getPlate(0);
Integer wellSampleIndex = 0;
for (int row = 0; row < plate.getRows().getValue(); row++) {
for (int col = 0; col < plate.getColumns().getValue(); col++) {
Well well = plate.getWell(row * plate.getColumns().getValue() + col);
assertEquals(1, well.sizeOfWellSampleList());
WellSample sample = well.getWellSample(0);
assertNotNull(sample);
assertEquals(String.format("WellSample:%d_%d", row, col), sample.getID());
assertEquals(wellSampleIndex, sample.getIndex().getValue());
Image image = sample.getLinkedImage();
assertNotNull(image);
assertEquals(IMAGE_ID, image.getID());
wellSampleIndex++;
}
}
}
use of ome.xml.model.Well in project bioformats by openmicroscopy.
the class InOutCurrentTest method testValidPlateNode.
@Test(dependsOnMethods = { "testValidOMENode" })
public void testValidPlateNode() {
Plate plate = ome.getPlate(0);
assertNotNull(plate);
assertEquals(PLATE_ID, plate.getID());
assertEquals(plate.getRows(), WELL_ROWS);
assertEquals(plate.getColumns(), WELL_COLS);
assertEquals(plate.getRowNamingConvention(), WELL_ROW);
assertEquals(plate.getColumnNamingConvention(), WELL_COL);
assertEquals(plate.sizeOfWellList(), WELL_ROWS.getValue() * WELL_COLS.getValue());
for (Integer row = 0; row < WELL_ROWS.getValue(); row++) {
for (Integer col = 0; col < WELL_COLS.getValue(); col++) {
Well well = plate.getWell(row * WELL_COLS.getValue() + col);
assertNotNull(well);
assertEquals(String.format("Well:%d_%d", row, col), well.getID());
assertEquals(well.getRow(), row);
assertEquals(well.getColumn(), col);
}
}
}
use of ome.xml.model.Well in project bioformats by openmicroscopy.
the class ObjectBasedOMEModelMock method makePlate.
private Plate makePlate() {
Plate plate = new Plate();
plate.setID(InOutCurrentTest.PLATE_ID);
plate.setRows(InOutCurrentTest.WELL_ROWS);
plate.setColumns(InOutCurrentTest.WELL_COLS);
plate.setRowNamingConvention(InOutCurrentTest.WELL_ROW);
plate.setColumnNamingConvention(InOutCurrentTest.WELL_COL);
TimestampAnnotation plateAnnotation = new TimestampAnnotation();
plateAnnotation.setID(InOutCurrentTest.PLATE_ANNOTATION_ID);
plateAnnotation.setValue(new Timestamp(InOutCurrentTest.PLATE_ANNOTATION_VALUE));
plateAnnotation.setNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE);
plate.linkAnnotation(plateAnnotation);
annotations.addTimestampAnnotation(plateAnnotation);
int wellSampleIndex = 0;
for (int row = 0; row < InOutCurrentTest.WELL_ROWS.getValue(); row++) {
for (int col = 0; col < InOutCurrentTest.WELL_COLS.getValue(); col++) {
Well well = new Well();
well.setID(String.format("Well:%d_%d", row, col));
well.setRow(new NonNegativeInteger(row));
well.setColumn(new NonNegativeInteger(col));
if (row == 0 && col == 0) {
LongAnnotation annotation = new LongAnnotation();
annotation.setID(InOutCurrentTest.WELL_ANNOTATION_ID);
annotation.setValue(InOutCurrentTest.WELL_ANNOTATION_VALUE);
annotation.setNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE);
well.linkAnnotation(annotation);
annotations.addLongAnnotation(annotation);
}
WellSample sample = new WellSample();
sample.setID(String.format("WellSample:%d_%d", row, col));
sample.setIndex(new NonNegativeInteger(wellSampleIndex));
sample.linkImage(ome.getImage(0));
well.addWellSample(sample);
plate.addWell(well);
wellSampleIndex++;
}
}
return plate;
}
use of ome.xml.model.Well 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.Well in project bioformats by openmicroscopy.
the class SPWModelMock method makePlate.
private Plate makePlate() {
Plate plate = new Plate();
plate.setName(PLATE_NAME);
plate.setID(PLATE_ID);
plate.setRows(WELL_ROWS);
plate.setColumns(WELL_COLS);
plate.setRowNamingConvention(WELL_ROW);
plate.setColumnNamingConvention(WELL_COL);
int wellSampleIndex = 0;
for (int row = 0; row < WELL_ROWS.getValue(); row++) {
for (int col = 0; col < WELL_COLS.getValue(); col++) {
Well well = new Well();
well.setID(String.format("Well:%d_%d", row, col));
well.setRow(new NonNegativeInteger(row));
well.setColumn(new NonNegativeInteger(col));
WellSample sample = new WellSample();
sample.setID(String.format("WellSample:%d_%d", row, col));
sample.setIndex(new NonNegativeInteger(wellSampleIndex));
sample.linkImage(ome.getImage(wellSampleIndex));
well.addWellSample(sample);
plate.addWell(well);
wellSampleIndex++;
}
}
return plate;
}
Aggregations