use of omero.gateway.model.ImageData in project imagej-omero by imagej.
the class DefaultOMEROService method uploadTable.
@Override
public long uploadTable(final OMEROCredentials credentials, final String name, final Table<?, ?> imageJTable, final long imageID) throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
final TableData omeroTable = convertOMEROTable(imageJTable);
long id = -1;
try (final OMEROSession session = new DefaultOMEROSession(credentials)) {
// Get image
final BrowseFacility browseFacility = session.getGateway().getFacility(BrowseFacility.class);
final ImageData image = browseFacility.getImage(session.getSecurityContext(), imageID);
// attach table to image
final TablesFacility tablesFacility = session.getGateway().getFacility(TablesFacility.class);
final TableData stored = tablesFacility.addTable(session.getSecurityContext(), image, name, omeroTable);
id = stored.getOriginalFileId();
}
return id;
}
use of omero.gateway.model.ImageData in project imagej-omero by imagej.
the class DefaultOMEROSession method createPixels.
@Override
public RawPixelsStorePrx createPixels(final OMEROFormat.Metadata meta) throws ServerError, FormatException {
// create a new Image which will house the written pixels
final ImageData newImage = createImage(meta);
final long imageID = newImage.getId();
meta.setImageID(imageID);
// configure the raw pixels store
final RawPixelsStorePrx store = session.createRawPixelsStore();
final long pixelsID = newImage.getDefaultPixels().getId();
store.setPixelsId(pixelsID, false);
meta.setPixelsID(pixelsID);
return store;
}
use of omero.gateway.model.ImageData in project imagej-omero by imagej.
the class ModuleAdapter method createOutputLinks.
/**
* Attempts to attach the outputs to the appropriate items.
*/
private void createOutputLinks(final HashMap<String, Object> inputMap, final HashMap<String, TableData> tables) throws ExecutionException, ServerError, DSOutOfServiceException, DSAccessException {
final ExperimenterData user = createUser();
final BrowseFacility browse = gateway.getFacility(BrowseFacility.class);
final DataManagerFacility dm = gateway.getFacility(DataManagerFacility.class);
final SecurityContext ctx = new SecurityContext(user.getGroupId());
final List<ImageData> outImages = getOutputImages(user.getId(), browse, ctx);
final List<ImageData> inputImages = getInputImages(inputMap, browse, ctx);
if (!outImages.isEmpty()) {
attachImagesToDatasets(inputImages, outImages, dm, browse, ctx);
}
if (!tables.isEmpty()) {
if (inputImages.isEmpty())
throw new IllegalArgumentException("Input image(s) required to upload table to OMERO");
attachTablesToImages(inputImages, tables, ctx, dm);
}
}
use of omero.gateway.model.ImageData in project imagej-omero by imagej.
the class ModuleAdapter method attachImagesToDatasets.
/**
* Attaches the given output images to the datasets of the given input images.
*/
private void attachImagesToDatasets(final List<ImageData> inputImages, final List<ImageData> outputImages, final DataManagerFacility dm, final BrowseFacility browse, SecurityContext ctx) throws DSOutOfServiceException, DSAccessException {
final HashMap<Long, DatasetData> datasets = new HashMap<>();
// Get all datasets related to the input images
// FIXME: ImageData has a getDatasets() method, but it is null since the
// underlying ImageI is unloaded.
final Collection<DatasetData> allDatasets = browse.getDatasets(ctx);
for (DatasetData d : allDatasets) {
Collection<ImageData> allImages = browse.getImagesForDatasets(ctx, Collections.singleton(d.getId()));
for (ImageData image : allImages) {
for (ImageData input : inputImages) {
if (input.getId() == image.getId())
datasets.put(d.getId(), d);
}
}
}
// attach all output images to these datasets
if (!datasets.isEmpty()) {
for (Long id : datasets.keySet()) dm.addImagesToDataset(ctx, outputImages, datasets.get(id));
}
}
use of omero.gateway.model.ImageData 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