本文整理汇总了Python中omero.gateway.BlitzGateway.getContainerService方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway.getContainerService方法的具体用法?Python BlitzGateway.getContainerService怎么用?Python BlitzGateway.getContainerService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类omero.gateway.BlitzGateway
的用法示例。
在下文中一共展示了BlitzGateway.getContainerService方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Omg
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getContainerService [as 别名]
#.........这里部分代码省略.........
u_s = self.conn.getUpdateService()
res = u_s.saveAndReturnObject(obj, self.conn.SERVICE_OPTS)
res.unload()
return res.id.val
def im(self, im_id):
"""
Return an Im object for the image id specified.
"""
img = self.conn.getObject("Image", im_id)
# build pixel np.ndarray
nx, ny = img.getSizeX(), img.getSizeY()
nz, nt, nc = img.getSizeZ(), img.getSizeT(), img.getSizeC()
planes = [(z, c, t) for c in range(nc)
for t in range(nt)
for z in range(nz)]
pix_gen = img.getPrimaryPixels().getPlanes(planes)
pix = np.array([i for i in pix_gen]).reshape((nc, nt, nz, ny, nx))
# initialize Im using pix and extracted metadata
meta = self._extract_meta(img, im_id)
return Im(pix=pix, meta=meta)
def _extract_meta(self, img, im_id):
"""Extract metadata attributes from OMERO Blitz gateway Image"""
meta = {}
meta['name'] = self._unique_name(img.getName(), im_id)
meta['description'] = img.getDescription()
def _extract_ch_info(ch):
"""extract core metadata for for channel, return as dict"""
ch_info = {'label': ch.getLabel()}
ch_info['ex_wave'] = ch.getExcitationWave()
ch_info['em_wave'] = ch.getEmissionWave()
ch_info['color'] = ch.getColor().getRGB()
return ch_info
meta['channels'] = [_extract_ch_info(ch) for ch in img.getChannels()]
meta['pixel_size'] = {'x': img.getPixelSizeX(),
'y': img.getPixelSizeY(),
'z': img.getPixelSizeZ(),
'units': "um"}
tag_type = omero.model.TagAnnotationI
tags = [ann for ann in img.listAnnotations()
if ann.OMERO_TYPE == tag_type]
meta['tags'] = {tag.getValue() + " (" + str(tag.getId()) + ")":
tag.getDescription() for tag in tags}
fa_type = omero.model.FileAnnotationI
attachments = [ann for ann in img.listAnnotations()
if ann.OMERO_TYPE == fa_type]
meta['attachments'] = [att.getFileName() + " (" + str(att.getId()) +
")" for att in attachments]
user_id = self.conn.getUser().getName() + " (" + \
str(self.conn.getUser().getId()) + ") @" + self.conn.host
meta_ext = {}
meta_ext['user_id'] = user_id
meta['meta_ext'] = meta_ext
# TODO: ROIs, display settings?
# objective: Image.loadOriginalMetadata()[1][find 'Lens ID Number'][1],
return meta
def imput(self, im, dataset_id=None):
"""
Create a new OMERO Image using an Im object, returning new image id.
"""
# see: omero/lib/python/omero/util/script_utils.py
# see: omero/lib/python/omeroweb/webclient/webclient_gateway.py
# see: https://gist.github.com/will-moore/4141708
if not isinstance(im, Im):
raise TypeError("first imput argument must be of type Im")
nc, nt, nz, ny, nx = im.shape
ch_nums = range(nc)
q_s = self.conn.getQueryService()
p_s = self.conn.getPixelsService()
c_s = self.conn.getContainerService()
u_s = self.conn.getUpdateService()
pu_s = self.conn.c.sf.createRawPixelsStore()
q_ptype = "from PixelsType as p where p.value='{0}'".format(
str(im.dtype))
pixelsType = q_s.findByQuery(q_ptype, None)
im_id = p_s.createImage(nx, ny, nz, nt, ch_nums, pixelsType,
im.name, im.description)
img_i = c_s.getImages("Image", [im_id.getValue()], None)[0]
img = self.conn.getObject("Image", im_id.getValue())
pix_id = img_i.getPrimaryPixels().getId().getValue()
pu_s.setPixelsId(pix_id, True)
for c in range(nc):
for t in range(nt):
for z in range(nz):
plane = im.pix[c, t, z, :, :]
script_utils.uploadPlaneByRow(pu_s, plane, z, c, t)
l_dset_im = omero.model.DatasetImageLinkI()
dset = self.conn.getObject("Dataset", dataset_id)
l_dset_im.setParent(dset._obj)
l_dset_im.setChild(img._obj)
self._update_meta(im, im_id)
u_s.saveObject(l_dset_im, self.conn.SERVICE_OPTS)
return im_id.getValue()
def _update_meta(self, im, im_id):
"""Set OMERO Image metadata using Im metadata"""