def decode(self, data): v = super(Channel201501Decoder, self).decode(data) self.set_property(v, 'alpha', data.get('Alpha')) self.set_property(v, 'blue', data.get('Blue')) self.set_property(v, 'green', data.get('Green')) self.set_property(v, 'red', data.get('Red')) self.set_property(v, 'lookupTable', data.get('omero:lookupTable')) logical_channel = LogicalChannelI(data.get('omero:LogicalChannelId')) logical_channel.emissionWave = \ self.to_unit(data.get('EmissionWavelength')) logical_channel.excitationWave = \ self.to_unit(data.get('ExcitationWavelength')) self.set_property(logical_channel, 'fluor', data.get('Fluor')) self.set_property(logical_channel, 'name', data.get('Name')) self.set_property(logical_channel, 'ndFilter', data.get('NDFilter')) logical_channel.pinHoleSize = self.to_unit(data.get('PinholeSize')) self.set_property( logical_channel, 'pockelCellSetting', data.get('PockelCellSetting') ) self.set_property( logical_channel, 'samplesPerPixel', data.get('SamplesPerPixel') ) contrast_method = data.get('ContrastMethod') if contrast_method is not None: contrast_method_decoder = self.ctx.get_decoder( contrast_method['@type'] ) logical_channel.contrastMethod = contrast_method_decoder.decode( contrast_method ) illumination = data.get('Illumination') if illumination is not None: illumination_decoder = self.ctx.get_decoder( illumination['@type'] ) logical_channel.illumination = illumination_decoder.decode( illumination ) acquisition_mode = data.get('AcquisitionMode') if acquisition_mode is not None: acquisition_mode_decoder = self.ctx.get_decoder( acquisition_mode['@type'] ) logical_channel.mode = acquisition_mode_decoder.decode( acquisition_mode ) photometric_interpretation = \ data.get('omero:photometricInterpretation') if photometric_interpretation is not None: photometric_interpretation_decoder = self.ctx.get_decoder( photometric_interpretation['@type'] ) logical_channel.photometricInterpretation = \ photometric_interpretation_decoder.decode( photometric_interpretation ) v.logicalChannel = logical_channel return v
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 test_logical_channel(self): name = u'₩€_name_$$' ill_val = u'πλζ.test.ζ' fluor = u'GFP-₹₹' binning_value = u'Φωλ' ph_size = 1.11 ph_units = UnitsLength.MICROMETER ex_wave = 3.34 ex_units = UnitsLength.ANGSTROM version = 123 zoom = 100 gain = 1010.23 di_model = u'Model_ 123_àÅÉ' obj = LogicalChannelI() obj.name = rstring(name) obj.pinHoleSize = LengthI(ph_size, ph_units) illumination = IlluminationI() illumination.value = rstring(ill_val) obj.illumination = illumination obj.excitationWave = LengthI(ex_wave, ex_units) obj.setFluor(rstring(fluor)) ds = DetectorSettingsI() ds.version = rint(version) ds.gain = rdouble(gain) ds.zoom = rdouble(zoom) binning = BinningI() binning.value = rstring(binning_value) ds.binning = binning obj.detectorSettings = ds dichroic = DichroicI() dichroic.model = rstring(di_model) light_path = LightPathI() light_path.dichroic = dichroic obj.lightPath = light_path class MockChannel(LogicalChannelWrapper): def __loadedHotSwap__(self): # Don't need to load data for getLightPath() pass channel = MockChannel(None, obj) assert channel.getName() == name.encode('utf8') assert channel.name == name assert channel.getPinHoleSize().getValue() == ph_size assert channel.getPinHoleSize().getUnit() == ph_units assert channel.getPinHoleSize().getSymbol() == 'µm' # Illumination is an enumeration assert channel.getIllumination().getValue() == ill_val.encode('utf8') assert channel.getExcitationWave().getValue() == ex_wave assert channel.getExcitationWave().getUnit() == ex_units assert channel.getExcitationWave().getSymbol() == 'Å' assert channel.getFluor() == fluor assert channel.fluor == fluor d_settings = channel.getDetectorSettings() assert d_settings.getVersion() == version assert d_settings.version == version assert d_settings.getGain() == gain assert d_settings.gain == gain assert d_settings.getZoom() == zoom assert d_settings.getBinning().getValue() == binning_value assert d_settings.getBinning().value == binning_value assert channel.getLightPath().getDichroic().getModel() == di_model
def create_image(image_id, with_pixels=False): image_format = FormatI(1) image_format.value = rstring('PNG') image = ImageI() image.id = rlong(image_id) image.acquisitionDate = rtime(1) 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(1) dimension_order.value = rstring('XYZCT') pixels_type = PixelsTypeI(1) pixels_type.value = 'bit' pixels = PixelsI(1) 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(8) contrast_method.value = rstring('Fluorescence') illumination = IlluminationI(1) illumination.value = rstring('Transmitted') acquisition_mode = AcquisitionModeI(1) acquisition_mode.value = rstring('WideField') photometric_interpretation = PhotometricInterpretationI(1) photometric_interpretation.value = rstring('RGB') channel_1 = ChannelI(1) channel_1.alpha = rint(255) channel_1.blue = rint(255) channel_1.green = rint(255) channel_1.red = rint(255) channel_1.lookupTable = rstring('rainbow') logical_channel_1 = LogicalChannelI(1) 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(2) channel_2.alpha = rint(255) channel_2.blue = rint(255) channel_2.green = rint(0) channel_2.red = rint(255) channel_2.lookupTable = rstring('rainbow') logical_channel_2 = LogicalChannelI(2) 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