Search in sources :

Example 1 with PixelsType

use of omero.model.PixelsType 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);
}
Also used : IObject(omero.model.IObject) PixelsType(omero.model.PixelsType) FormatException(io.scif.FormatException)

Example 2 with PixelsType

use of omero.model.PixelsType 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));
}
Also used : ImageMetadata(io.scif.ImageMetadata) ImageData(omero.gateway.model.ImageData) ArrayList(java.util.ArrayList) PixelsType(omero.model.PixelsType) RLong(omero.RLong) Image(omero.model.Image) FormatException(io.scif.FormatException)

Aggregations

FormatException (io.scif.FormatException)2 PixelsType (omero.model.PixelsType)2 ImageMetadata (io.scif.ImageMetadata)1 ArrayList (java.util.ArrayList)1 RLong (omero.RLong)1 ImageData (omero.gateway.model.ImageData)1 IObject (omero.model.IObject)1 Image (omero.model.Image)1