当前位置: 首页>>代码示例>>Python>>正文


Python BlitzGateway.createFileAnnfromLocalFile方法代码示例

本文整理汇总了Python中omero.gateway.BlitzGateway.createFileAnnfromLocalFile方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway.createFileAnnfromLocalFile方法的具体用法?Python BlitzGateway.createFileAnnfromLocalFile怎么用?Python BlitzGateway.createFileAnnfromLocalFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在omero.gateway.BlitzGateway的用法示例。


在下文中一共展示了BlitzGateway.createFileAnnfromLocalFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Omg

# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import createFileAnnfromLocalFile [as 别名]

#.........这里部分代码省略.........
        import_args = ["import"]
        import_args.extend(["-s", str(self._server)])
        import_args.extend(["-k", str(self._key)])
        if dataset is not None:
            import_args.extend(["-d", str(dataset)])
        if name is not None:
            import_args.extend(["-n", str(name)])
        clio = "cli.out"
        clie = "cli.err"
        import_args.extend(["---errs=" + clie, "---file=" + clio, "--"])
        import_args.append(filename)
        cli.invoke(import_args, strict=True)
        pix_id = int(open(clio, 'r').read().rstrip())
        im_id = self.conn.getQueryService().get("Pixels", pix_id).image.id.val
        os.remove(clio)
        os.remove(clie)
        return im_id

    def describe(self, im_id, description):
        """
        Append to image description.
        """
        img = self.conn.getObject("Image", oid=im_id)
        old_description = img.getDescription() or ""
        img.setDescription(old_description + "\n" + description)
        img.save()

    def attach(self, im_id, attachments):
        """
        Attach a list of files to an image.
        """
        img = self.conn.getObject("Image", oid=im_id)
        for attachment in attachments.split():
            fann = self.conn.createFileAnnfromLocalFile(attachment)
            img.linkAnnotation(fann)
        img.save()

    # TODO: ls_tags() and tag() methods?

    def mkp(self, project_name, description=None):
        """
        Make new OMERO project in current group, returning the new project Id.
        """
        # see: omero/lib/python/omeroweb/webclient/controller/container.py
        proj = omero.model.ProjectI()
        proj.name = omero.rtypes.rstring(str(project_name))
        if description is not None and description != "":
            proj.description = omero.rtypes.rstring(str(description))
        return self._save_and_return_id(proj)

    def mkd(self, dataset_name, project_id=None, description=None):
        """
        Make new OMERO dataset, returning the new dataset Id.
        """
        dset = omero.model.DatasetI()
        dset.name = omero.rtypes.rstring(str(dataset_name))
        if description is not None and description != "":
            dset.description = omero.rtypes.rstring(str(description))
        if project_id is not None:
            l_proj_dset = omero.model.ProjectDatasetLinkI()
            proj = self.conn.getObject("Project", project_id)
            l_proj_dset.setParent(proj._obj)
            l_proj_dset.setChild(dset)
            dset.addProjectDatasetLink(l_proj_dset)
        return self._save_and_return_id(dset)
开发者ID:graemeball,项目名称:omero_scripts,代码行数:69,代码来源:iomero.py

示例2: open

# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import createFileAnnfromLocalFile [as 别名]
project = conn.getObject("Project", projectId)
# NB: only link a client map annotation to a single object
project.linkAnnotation(mapAnn)


# How to create a file annotation and link to a Dataset
# =====================================================
dataset = conn.getObject("Dataset", datasetId)
# Specify a local file e.g. could be result of some analysis
fileToUpload = "README.txt"   # This file should already exist
with open(fileToUpload, 'w') as f:
    f.write('annotation test')
# create the original file and file annotation (uploads the file etc.)
namespace = "imperial.training.demo"
print "\nCreating an OriginalFile and FileAnnotation"
fileAnn = conn.createFileAnnfromLocalFile(
    fileToUpload, mimetype="text/plain", ns=namespace, desc=None)
print "Attaching FileAnnotation to Dataset: ", "File ID:", fileAnn.getId(), \
    ",", fileAnn.getFile().getName(), "Size:", fileAnn.getFile().getSize()
dataset.linkAnnotation(fileAnn)     # link it to dataset.
os.remove(fileToUpload)

# Download a file annotation linked to a Dataset
# ==============================================
# make a location to download the file. "download" folder.
path = os.path.join(os.path.dirname(__file__), "download")
if not os.path.exists(path):
    os.makedirs(path)
# Go through all the annotations on the Dataset. Download any file annotations
# we find.
print "\nAnnotations on Dataset:", dataset.getName()
for ann in dataset.listAnnotations():
开发者ID:kennethgillen,项目名称:openmicroscopy,代码行数:34,代码来源:Write_Data.py

示例3: hstack

# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import createFileAnnfromLocalFile [as 别名]
# ** BONUS **
# stack the numpy columns horizontally. hstack is a numpy function
kymograph_data = hstack(col_data)
print "kymograph_data", kymograph_data.shape


if kymograph_data.dtype.name not in ('uint8', 'int8'):      # we need to scale...
    minVal = kymograph_data.min()
    maxVal = kymograph_data.max()
    valRange = maxVal - minVal
    scaled = (kymograph_data - minVal) * (float(255) / valRange)
    convArray = zeros(kymograph_data.shape, dtype=uint8)
    convArray += scaled
    print "using converted int8 plane: dtype: %s min: %s max: %s" % (convArray.dtype.name, convArray.min(), convArray.max())
    i = Image.fromarray(convArray)
else:
    i = Image.fromarray(plane)
#i.show()
i.save("kymograph.png", 'PNG')

# attach the png to the image
fileAnn = conn.createFileAnnfromLocalFile("kymograph.png", mimetype="image/png")
print "Attaching kymograph.png to image"
image.linkAnnotation(fileAnn)


message = "Tile average value: %s" % average
client.setOutput("Message", rstring(message))
client.setOutput("Kymograph", robject(fileAnn._obj))
client.closeSession()
开发者ID:DirkHaehnel,项目名称:openmicroscopy,代码行数:32,代码来源:Raw_Data_Task.py


注:本文中的omero.gateway.BlitzGateway.createFileAnnfromLocalFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。