Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import omero
- from omero.rtypes import rstring
- import omero.grid
- from omero.gateway import BlitzGateway
- USERNAME = "will"
- PASSWORD = "ome"
- HOST = "localhost"
- PORT = 4064
- plateId = 103
- conn = BlitzGateway(USERNAME, PASSWORD, host=HOST, port=PORT)
- conn.connect()
- tablename = "Channels_Min_Mex_Intensity"
- # Go through all wells in Plate, adding row for each
- plate = conn.getObject("Plate", plateId)
- wellIds = []
- rowData = []
- chCount = 0
- for well in plate._listChildren():
- well = omero.gateway.WellWrapper(conn, well)
- image = well.getImage()
- if image is None:
- continue
- wellIds.append(well.id)
- chCount = image.getSizeC()
- row = []
- print "well, image", well.id, image.id
- for ch in image.getChannels():
- row.append(long(ch.getWindowMin()))
- row.append(long(ch.getWindowMax()))
- rowData.append(row)
- print 'wellIds', wellIds
- print 'rowData', rowData
- # Now we know how many channels, we can make the table
- col1 = omero.grid.WellColumn('Well', '', [])
- columns = [col1]
- colNames = []
- for chIdx in range(chCount):
- for name in ['Ch%sMin' % chIdx, 'Ch%sMax' % chIdx]:
- colNames.append(name)
- columns.append(omero.grid.LongColumn(name, '', []))
- table = conn.c.sf.sharedResources().newTable(1, tablename)
- table.initialize(columns)
- # Add Data from above
- data1 = omero.grid.WellColumn('Well', '', wellIds)
- data = [data1]
- for colIdx in range(len(rowData[0])):
- colData = [r[colIdx] for r in rowData]
- print "colData", len(colData)
- name = colNames[colIdx]
- data.append(omero.grid.LongColumn(name, '', colData))
- print "Adding data: ", len(data)
- table.addData(data)
- table.close()
- print "table closed..."
- orig_file = table.getOriginalFile()
- fileAnn = omero.model.FileAnnotationI()
- fileAnn.ns = rstring('openmicroscopy.org/omero/bulk_annotations')
- fileAnn.setFile(omero.model.OriginalFileI(orig_file.id.val, False))
- fileAnn = conn.getUpdateService().saveAndReturnObject(fileAnn)
- link = omero.model.PlateAnnotationLinkI()
- link.setParent(omero.model.PlateI(plateId, False))
- link.setChild(omero.model.FileAnnotationI(fileAnn.id.val, False))
- print "save link..."
- conn.getUpdateService().saveAndReturnObject(link)
- conn._closeSession()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement