def image_rois(self, user1, shapes): """Return Image with ROIs.""" image = ImageI() image.name = rstring('Image for ROIs') image = get_update_service(user1).saveAndReturnObject(image) # ROI with all but one shapes rois = [] roi = RoiI() for shape in shapes[:-1]: roi.addShape(shape) roi.setImage(image) rois.append(roi) # roi without shapes roi = RoiI() roi.setImage(image) rois.append(roi) # roi without image roi = RoiI() roi.addShape(shapes[-1]) rois.append(roi) rois = get_update_service(user1).saveAndReturnArray(rois) rois.sort(key=lambda x: x.id.val) return image, rois
def image_no_acquisition_date(request, gatewaywrapper): """Creates an Image.""" gatewaywrapper.loginAsAuthor() gw = gatewaywrapper.gateway update_service = gw.getUpdateService() image = ImageI() image.name = rstring('an image') image.acquisitionDate = rtime(0L) image_id, = update_service.saveAndReturnIds([image]) return gw.getObject('Image', image_id)
def wrapped_image(): image = ImageI() image.id = rlong(1L) image.description = rstring('description') image.name = rstring('name') image.acquisitionDate = rtime(1000) # In milliseconds image.details.owner = ExperimenterI(1L, False) creation_event = EventI() creation_event.time = rtime(2000) # In milliseconds image.details.creationEvent = creation_event return ImageWrapper(conn=MockConnection(), obj=image)
def image(request, gatewaywrapper): """Creates an Image.""" gatewaywrapper.loginAsAuthor() gw = gatewaywrapper.gateway update_service = gw.getUpdateService() image = ImageI() image.name = rstring('an image') # 2015-04-21 01:15:00 image.acquisitionDate = rtime(int(1429578900000)) image_id, = update_service.saveAndReturnIds([image]) return gw.getObject('Image', image_id)
def testListOrphans(self, orphaned, load_pixels, gatewaywrapper): # We login as 'User', since they have no other orphaned images gatewaywrapper.loginAsUser() conn = gatewaywrapper.gateway eid = conn.getUserId() # Create 5 orphaned images iids = [] for i in range(0, 5): img = gatewaywrapper.createTestImage(imageName=str(uuid.uuid1())) iids.append(img.id) # Create image in Dataset, to check this isn't found dataset = DatasetI() dataset.name = wrap('testListOrphans') image = ImageI() image.name = wrap('testListOrphans') dataset.linkImage(image) dataset = conn.getUpdateService().saveAndReturnObject(dataset) try: # Only test listOrphans() if orphaned if orphaned: # Pagination params = omero.sys.ParametersI() params.page(1, 3) findImagesInPage = list( conn.listOrphans("Image", eid=eid, params=params)) assert len(findImagesInPage) == 3 # No pagination (all orphans) findImages = list( conn.listOrphans("Image", loadPixels=load_pixels)) assert len(findImages) == 5 for p in findImages: assert p._obj.pixelsLoaded == load_pixels # Test getObjects() with 'orphaned' option opts = {'orphaned': orphaned, 'load_pixels': load_pixels} getImages = list(conn.getObjects("Image", opts=opts)) assert orphaned == (len(getImages) == 5) for p in getImages: assert p._obj.pixelsLoaded == load_pixels # Simply check this doesn't fail See https://github.com/ # openmicroscopy/openmicroscopy/pull/4950#issuecomment-264142956 dsIds = [d.id for d in conn.listOrphans("Dataset")] assert dataset.id.val in dsIds finally: # Cleanup - Delete what we created conn.deleteObjects('Image', iids, deleteAnns=True, wait=True) conn.deleteObjects('Dataset', [dataset.id.val], deleteChildren=True, wait=True)
def create_image(image_index): image = ImageI() image.name = rstring("%s_%d" % (uuid(), image_index)) image.acquisitionDate = rtime(0) pixels = PixelsI() pixels.sha1 = rstring("") pixels.sizeX = rint(1) pixels.sizeY = rint(1) pixels.sizeZ = rint(1) pixels.sizeC = rint(1) pixels.sizeT = rint(1) pixels.dimensionOrder = DimensionOrderI(1L, False) # XYZCT pixels.pixelsType = PixelsTypeI(1L, False) # bit image.addPixels(pixels) return image
def create_image(image_index): image = ImageI() image.name = rstring('%s_%d' % (uuid(), image_index)) image.acquisitionDate = rtime(0) pixels = PixelsI() pixels.sha1 = rstring('') pixels.sizeX = rint(1) pixels.sizeY = rint(1) pixels.sizeZ = rint(1) pixels.sizeC = rint(1) pixels.sizeT = rint(1) pixels.dimensionOrder = DimensionOrderI(1L, False) # XYZCT pixels.pixelsType = PixelsTypeI(1L, False) # bit image.addPixels(pixels) return image
def plate(request, gatewaywrapper): """Creates a Plate.""" gatewaywrapper.loginAsAuthor() gw = gatewaywrapper.gateway update_service = gw.getUpdateService() plate = PlateI() plate.name = rstring(uuid()) for well_index in range(3): well = WellI() well.row = rint(well_index**2) well.column = rint(well_index**3) for well_sample_index in range(2): well_sample = WellSampleI() image = ImageI() image.name = rstring('%s_%d' % (uuid(), well_sample_index)) image.acquisitionDate = rtime(0) well_sample.image = image well.addWellSample(well_sample) plate.addWell(well) plate_id, = update_service.saveAndReturnIds([plate]) return gw.getObject('Plate', plate_id)
def create_image(image_id, with_pixels=False): image_format = FormatI(1L) image_format.value = rstring("PNG") image = ImageI() image.id = rlong(image_id) image.acquisitionDate = rtime(1L) image.archived = rbool(False) image.description = rstring("image_description_%d" % image_id) image.name = rstring("image_name_%d" % image_id) image.partial = rbool(False) image.series = rint(0) image.format = image_format if not with_pixels: return image dimension_order = DimensionOrderI(1L) dimension_order.value = rstring("XYZCT") pixels_type = PixelsTypeI(1L) pixels_type.value = "bit" pixels = PixelsI(1L) pixels.methodology = rstring("methodology") pixels.physicalSizeX = LengthI(1.0, UnitsLength.MICROMETER) pixels.physicalSizeY = LengthI(2.0, UnitsLength.MICROMETER) pixels.physicalSizeZ = LengthI(3.0, UnitsLength.MICROMETER) pixels.sha1 = rstring("61ee8b5601a84d5154387578466c8998848ba089") pixels.significantBits = rint(16) pixels.sizeX = rint(1) pixels.sizeY = rint(2) pixels.sizeZ = rint(3) pixels.sizeC = rint(4) pixels.sizeT = rint(5) pixels.timeIncrement = TimeI(1.0, UnitsTime.MILLISECOND) pixels.waveIncrement = rdouble(2.0) pixels.waveStart = rint(1) pixels.dimensionOrder = dimension_order pixels.pixelsType = pixels_type image.addPixels(pixels) contrast_method = ContrastMethodI(8L) contrast_method.value = rstring("Fluorescence") illumination = IlluminationI(1L) illumination.value = rstring("Transmitted") acquisition_mode = AcquisitionModeI(1L) acquisition_mode.value = rstring("WideField") photometric_interpretation = PhotometricInterpretationI(1L) photometric_interpretation.value = rstring("RGB") channel_1 = ChannelI(1L) channel_1.alpha = rint(255) channel_1.blue = rint(0) channel_1.green = rint(255) channel_1.red = rint(0) channel_1.lookupTable = rstring("rainbow") logical_channel_1 = LogicalChannelI(1L) logical_channel_1.emissionWave = LengthI(509.0, UnitsLength.NANOMETER) logical_channel_1.excitationWave = LengthI(488.0, UnitsLength.NANOMETER) logical_channel_1.fluor = rstring("GFP") logical_channel_1.name = rstring("GFP/488") logical_channel_1.ndFilter = rdouble(1.0) logical_channel_1.pinHoleSize = LengthI(1.0, UnitsLength.NANOMETER) logical_channel_1.pockelCellSetting = rint(0) logical_channel_1.samplesPerPixel = rint(2) logical_channel_1.contrastMethod = contrast_method logical_channel_1.illumination = illumination logical_channel_1.mode = acquisition_mode logical_channel_1.photometricInterpretation = photometric_interpretation channel_1.logicalChannel = logical_channel_1 channel_2 = ChannelI(2L) channel_2.alpha = rint(255) channel_2.blue = rint(255) channel_2.green = rint(0) channel_2.red = rint(0) channel_2.lookupTable = rstring("rainbow") logical_channel_2 = LogicalChannelI(2L) logical_channel_2.emissionWave = LengthI(470.0, UnitsLength.NANOMETER) logical_channel_2.excitationWave = LengthI(405.0, UnitsLength.NANOMETER) logical_channel_2.fluor = rstring("DAPI") logical_channel_2.name = rstring("DAPI/405") logical_channel_2.ndFilter = rdouble(1.0) logical_channel_2.pinHoleSize = LengthI(2.0, UnitsLength.NANOMETER) logical_channel_2.pockelCellSetting = rint(0) logical_channel_2.samplesPerPixel = rint(2) logical_channel_2.contrastMethod = contrast_method logical_channel_2.illumination = illumination logical_channel_2.mode = acquisition_mode logical_channel_2.photometricInterpretation = photometric_interpretation channel_2.logicalChannel = logical_channel_2 pixels.addChannel(channel_1) pixels.addChannel(channel_2) return image
def create_image(image_id, with_pixels=False): image_format = FormatI(1L) image_format.value = rstring('PNG') image = ImageI() image.id = rlong(image_id) image.acquisitionDate = rtime(1L) image.archived = rbool(False) image.description = rstring('image_description_%d' % image_id) image.name = rstring('image_name_%d' % image_id) image.partial = rbool(False) image.series = rint(0) image.format = image_format if not with_pixels: return image dimension_order = DimensionOrderI(1L) dimension_order.value = rstring('XYZCT') pixels_type = PixelsTypeI(1L) pixels_type.value = 'bit' pixels = PixelsI(1L) pixels.methodology = rstring('methodology') pixels.physicalSizeX = LengthI(1.0, UnitsLength.MICROMETER) pixels.physicalSizeY = LengthI(2.0, UnitsLength.MICROMETER) pixels.physicalSizeZ = LengthI(3.0, UnitsLength.MICROMETER) pixels.sha1 = rstring('61ee8b5601a84d5154387578466c8998848ba089') pixels.significantBits = rint(16) pixels.sizeX = rint(1) pixels.sizeY = rint(2) pixels.sizeZ = rint(3) pixels.sizeC = rint(4) pixels.sizeT = rint(5) pixels.timeIncrement = TimeI(1.0, UnitsTime.MILLISECOND) pixels.waveIncrement = rdouble(2.0) pixels.waveStart = rint(1) pixels.dimensionOrder = dimension_order pixels.pixelsType = pixels_type image.addPixels(pixels) contrast_method = ContrastMethodI(8L) contrast_method.value = rstring('Fluorescence') illumination = IlluminationI(1L) illumination.value = rstring('Transmitted') acquisition_mode = AcquisitionModeI(1L) acquisition_mode.value = rstring('WideField') photometric_interpretation = PhotometricInterpretationI(1L) photometric_interpretation.value = rstring('RGB') channel_1 = ChannelI(1L) channel_1.alpha = rint(255) channel_1.blue = rint(0) channel_1.green = rint(255) channel_1.red = rint(0) channel_1.lookupTable = rstring('rainbow') logical_channel_1 = LogicalChannelI(1L) logical_channel_1.emissionWave = LengthI(509.0, UnitsLength.NANOMETER) logical_channel_1.excitationWave = LengthI(488.0, UnitsLength.NANOMETER) logical_channel_1.fluor = rstring('GFP') logical_channel_1.name = rstring('GFP/488') logical_channel_1.ndFilter = rdouble(1.0) logical_channel_1.pinHoleSize = LengthI(1.0, UnitsLength.NANOMETER) logical_channel_1.pockelCellSetting = rint(0) logical_channel_1.samplesPerPixel = rint(2) logical_channel_1.contrastMethod = contrast_method logical_channel_1.illumination = illumination logical_channel_1.mode = acquisition_mode logical_channel_1.photometricInterpretation = photometric_interpretation channel_1.logicalChannel = logical_channel_1 channel_2 = ChannelI(2L) channel_2.alpha = rint(255) channel_2.blue = rint(255) channel_2.green = rint(0) channel_2.red = rint(0) channel_2.lookupTable = rstring('rainbow') logical_channel_2 = LogicalChannelI(2L) logical_channel_2.emissionWave = LengthI(470.0, UnitsLength.NANOMETER) logical_channel_2.excitationWave = LengthI(405.0, UnitsLength.NANOMETER) logical_channel_2.fluor = rstring('DAPI') logical_channel_2.name = rstring('DAPI/405') logical_channel_2.ndFilter = rdouble(1.0) logical_channel_2.pinHoleSize = LengthI(2.0, UnitsLength.NANOMETER) logical_channel_2.pockelCellSetting = rint(0) logical_channel_2.samplesPerPixel = rint(2) logical_channel_2.contrastMethod = contrast_method logical_channel_2.illumination = illumination logical_channel_2.mode = acquisition_mode logical_channel_2.photometricInterpretation = photometric_interpretation channel_2.logicalChannel = logical_channel_2 pixels.addChannel(channel_1) pixels.addChannel(channel_2) return image