Search in sources :

Example 1 with RLong

use of omero.RLong 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)

Example 2 with RLong

use of omero.RLong in project imagej-omero by imagej.

the class ModuleAdapter method getInputImages.

/**
 * Loops over the input items, and checks for Datasets, and if so gets the
 * corresponding omero ImageData.
 */
private List<ImageData> getInputImages(final HashMap<String, Object> inputMap, final BrowseFacility browse, final SecurityContext ctx) throws ServerError, DSOutOfServiceException, DSAccessException {
    if (imageInput != null) {
        final RLong id = (RLong) client.getInput(IMAGE_NAME);
        return Collections.singletonList(browse.getImage(ctx, id.getValue()));
    }
    final List<ImageData> images = new ArrayList<>();
    for (String key : inputMap.keySet()) {
        if (inputMap.get(key) instanceof Dataset) {
            final RLong id = (RLong) client.getInput(key);
            images.add(browse.getImage(ctx, id.getValue()));
        }
    }
    return images;
}
Also used : ImageData(omero.gateway.model.ImageData) Dataset(net.imagej.Dataset) ArrayList(java.util.ArrayList) RLong(omero.RLong)

Example 3 with RLong

use of omero.RLong in project imagej-omero by imagej.

the class ModuleAdapter method getOutputImages.

/**
 * Loops over all the orphaned images, and grabs the ones which have IDs that
 * match the omero client outputs.
 */
private List<ImageData> getOutputImages(final long userId, final BrowseFacility browse, final SecurityContext ctx) throws ServerError {
    final Collection<ImageData> orphans = browse.getOrphanedImages(ctx, userId);
    final HashMap<Long, ImageData> mappedOrphans = new HashMap<>();
    for (ImageData i : orphans) mappedOrphans.put(i.getId(), i);
    final List<ImageData> images = new ArrayList<>();
    for (String key : client.getOutputKeys()) {
        final omero.RType type = client.getOutput(key);
        if (type instanceof RLong) {
            if (mappedOrphans.containsKey(((RLong) type).getValue()))
                images.add(mappedOrphans.get(((RLong) type).getValue()));
        }
    }
    return images;
}
Also used : HashMap(java.util.HashMap) ImageData(omero.gateway.model.ImageData) RLong(omero.RLong) ArrayList(java.util.ArrayList) RLong(omero.RLong)

Aggregations

ArrayList (java.util.ArrayList)3 RLong (omero.RLong)3 ImageData (omero.gateway.model.ImageData)3 FormatException (io.scif.FormatException)1 ImageMetadata (io.scif.ImageMetadata)1 HashMap (java.util.HashMap)1 Dataset (net.imagej.Dataset)1 Image (omero.model.Image)1 PixelsType (omero.model.PixelsType)1