Exemple #1
0
def rating_userA(request, userA, groupA):
    """
    Returns new OMERO Rating
    """
    rating = LongAnnotationI()
    ctx = {'omero.group': native_str(groupA.id.val)}
    rating.longValue = rlong(4)
    rating.ns = rstring(omero.constants.metadata.NSINSIGHTRATING)
    rating = get_update_service(userA).saveAndReturnObject(rating, ctx)
    return rating
Exemple #2
0
def fileset_with_images_and_annotations(request, gatewaywrapper):
    gatewaywrapper.loginAsAuthor()
    update_service = gatewaywrapper.gateway.getUpdateService()
    fileset = create_fileset()
    comment_annotation = CommentAnnotationI()
    comment_annotation.ns = rstring("comment_annotation")
    comment_annotation.textValue = rstring("textValue")
    long_annotation = LongAnnotationI()
    long_annotation.ns = rstring("long_annotation")
    long_annotation.longValue = rlong(1L)
    fileset.linkAnnotation(comment_annotation)
    fileset.linkAnnotation(long_annotation)
    fileset = update_service.saveAndReturnObject(fileset)
    return gatewaywrapper.gateway.getObject("Fileset", fileset.id.val)
Exemple #3
0
def fileset_with_images_and_annotations(request, gatewaywrapper):
    gatewaywrapper.loginAsAuthor()
    update_service = gatewaywrapper.gateway.getUpdateService()
    fileset = create_fileset()
    comment_annotation = CommentAnnotationI()
    comment_annotation.ns = rstring('comment_annotation')
    comment_annotation.textValue = rstring('textValue')
    long_annotation = LongAnnotationI()
    long_annotation.ns = rstring('long_annotation')
    long_annotation.longValue = rlong(1L)
    fileset.linkAnnotation(comment_annotation)
    fileset.linkAnnotation(long_annotation)
    fileset = update_service.saveAndReturnObject(fileset)
    return gatewaywrapper.gateway.getObject('Fileset', fileset.id.val)
Exemple #4
0
def link_tags(conn, datasetname, image_tag_links, image_ratings):

    for i in range(1, 51):
        username = "******" % i
        print(username)
        exp = conn.getAdminService().lookupExperimenter(username)
        exp_id = exp.id.val

        dataset = conn.getObject("Dataset",
                                 attributes={'name': datasetname},
                                 opts={'owner': exp_id})
        if dataset is None:
            print("Dataset not found")
            continue
        links = []
        for image in dataset.listChildren():
            name = image.name
            if name in image_tag_links:
                for tag_id in image_tag_links[name]:
                    link = ImageAnnotationLinkI()
                    link.parent = ImageI(image.id, False)
                    link.child = TagAnnotationI(tag_id, False)
                    link.details.owner = ExperimenterI(exp_id, False)
                    links.append(link)
            if name in image_ratings:
                link = ImageAnnotationLinkI()
                link.parent = ImageI(image.id, False)
                r = LongAnnotationI()
                r.ns = rstring(RATING_NS)
                r.longValue = rlong(image_ratings[name])
                link.child = r
                link.details.owner = ExperimenterI(exp_id, False)
                links.append(link)

        print('links', len(links))
        group_id = dataset.getDetails().getGroup().id
        conn.SERVICE_OPTS.setOmeroGroup(group_id)
        try:
            conn.getUpdateService().saveArray(links, conn.SERVICE_OPTS)
        except ValidationException:
            print("Failed to link for %s" % username)