use of io.scif.FormatException in project imagej-omero by imagej.
the class DefaultOMEROSession method getPixelsType.
private PixelsType getPixelsType(final String pixelType) throws ServerError, FormatException {
final List<IObject> list = session.getPixelsService().getAllEnumerations(PixelsType.class.getName());
final Iterator<IObject> iter = list.iterator();
while (iter.hasNext()) {
final PixelsType type = (PixelsType) iter.next();
final String value = type.getValue().getValue();
if (value.equals(pixelType))
return type;
}
throw new FormatException("Invalid pixel type: " + pixelType);
}
use of io.scif.FormatException in project imagej-omero by imagej.
the class DefaultOMEROSession method createImage.
// -- Helper methods --
private ImageData createImage(final OMEROFormat.Metadata meta) throws ServerError, FormatException {
// create a new Image
final ImageMetadata imageMeta = meta.get(0);
final int xLen = axisLength(imageMeta, Axes.X);
final int yLen = axisLength(imageMeta, Axes.Y);
final int zLen = axisLength(imageMeta, Axes.Z);
final int tLen = axisLength(imageMeta, Axes.TIME);
final int cLen = axisLength(imageMeta, Axes.CHANNEL);
final int sizeX = xLen == 0 ? 1 : xLen;
final int sizeY = yLen == 0 ? 1 : yLen;
final int sizeZ = zLen == 0 ? 1 : zLen;
final int sizeT = tLen == 0 ? 1 : tLen;
final int sizeC = cLen == 0 ? 1 : cLen;
final List<Integer> channelList = new ArrayList<Integer>(sizeC);
for (int c = 0; c < sizeC; c++) {
// TODO: Populate actual emission wavelengths?
channelList.add(c);
}
final int pixelType = imageMeta.getPixelType();
final PixelsType pixelsType = getPixelsType(pixelType);
final String name = meta.getName();
final String description = meta.getName();
final RLong id = session.getPixelsService().createImage(sizeX, sizeY, sizeZ, sizeT, channelList, pixelsType, name, description);
if (id == null)
throw new FormatException("Cannot create image");
// retrieve the newly created Image
final List<Image> results = session.getContainerService().getImages(Image.class.getName(), Arrays.asList(id.getValue()), null);
return new ImageData(results.get(0));
}
Aggregations