def setUp(self): self.app = wx.App() data = numpy.zeros((2160, 2560), dtype=numpy.uint16) dataRGB = numpy.zeros((2160, 2560, 4)) metadata = { 'Hardware name': 'Andor ZYLA-5.5-USB3 (s/n: VSC-01959)', 'Exposure time': 0.3, 'Pixel size': (1.59604600574173e-07, 1.59604600574173e-07), 'Acquisition date': 1441361559.258568, 'Hardware version': "firmware: '14.9.16.0' (driver 3.10.30003.5)", 'Centre position': (-0.001203511795256, -0.000295338300158), 'Lens magnification': 40.0, 'Input wavelength range': (6.15e-07, 6.350000000000001e-07), 'Shear': -4.358492733391727e-16, 'Description': 'Filtered colour 1', 'Bits per pixel': 16, 'Binning': (1, 1), 'Pixel readout time': 1e-08, 'Gain': 1.1, 'Rotation': 6.279302551026012, 'Light power': 0.0, 'Display tint': (255, 0, 0), 'Output wavelength range': (6.990000000000001e-07, 7.01e-07) } image = model.DataArray(data, metadata) fluo_stream = stream.StaticFluoStream(metadata['Description'], image) fluo_stream_pj = stream.RGBSpatialProjection(fluo_stream) data = numpy.zeros((1024, 1024), dtype=numpy.uint16) dataRGB = numpy.zeros((1024, 1024, 4)) metadata = { 'Hardware name': 'pcie-6251', 'Description': 'Secondary electrons', 'Exposure time': 3e-06, 'Pixel size': (1e-6, 1e-6), 'Acquisition date': 1441361562.0, 'Hardware version': 'Unknown (driver 2.1-160-g17a59fb (driver ni_pcimio v0.7.76))', 'Centre position': (-0.001203511795256, -0.000295338300158), 'Lens magnification': 5000.0, 'Rotation': 0.0 } image = model.DataArray(data, metadata) # export FILENAME = u"test" + tiff.EXTENSIONS[0] tiff.export(FILENAME, image, pyramid=True) # read back acd = tiff.open_data(FILENAME) sem_stream = stream.StaticSEMStream(metadata['Description'], acd.content[0]) sem_stream_pj = stream.RGBSpatialProjection(sem_stream) sem_stream_pj.mpp.value = 1e-6 self.streams = [fluo_stream_pj, sem_stream_pj] self.min_res = (623, 432) # Wait for all the streams to get an RGB image time.sleep(0.5)
def setUp(self): self.app = wx.App() data = numpy.zeros((2160, 2560), dtype=numpy.uint16) dataRGB = numpy.zeros((2160, 2560, 4)) metadata = {'Hardware name': 'Andor ZYLA-5.5-USB3 (s/n: VSC-01959)', 'Exposure time': 0.3, 'Pixel size': (1.59604600574173e-07, 1.59604600574173e-07), 'Acquisition date': 1441361559.258568, 'Hardware version': "firmware: '14.9.16.0' (driver 3.10.30003.5)", 'Centre position': (-0.001203511795256, -0.000295338300158), 'Lens magnification': 40.0, 'Input wavelength range': (6.15e-07, 6.350000000000001e-07), 'Shear':-4.358492733391727e-16, 'Description': 'Filtered colour 1', 'Bits per pixel': 16, 'Binning': (1, 1), 'Pixel readout time': 1e-08, 'Gain': 1.1, 'Rotation': 6.279302551026012, 'Light power': 0.0, 'Display tint': (255, 0, 0), 'Output wavelength range': (6.990000000000001e-07, 7.01e-07)} image = model.DataArray(data, metadata) fluo_stream = stream.StaticFluoStream(metadata['Description'], image) #fluo_stream.image.value = model.DataArray(dataRGB, metadata) data = numpy.zeros((1024, 1024), dtype=numpy.uint16) dataRGB = numpy.zeros((1024, 1024, 4)) metadata = {'Hardware name': 'pcie-6251', 'Description': 'Secondary electrons', 'Exposure time': 3e-06, 'Pixel size': (5.9910982493639e-08, 6.0604642506361e-08), 'Acquisition date': 1441361562.0, 'Hardware version': 'Unknown (driver 2.1-160-g17a59fb (driver ni_pcimio v0.7.76))', 'Centre position': (-0.001203511795256, -0.000295338300158), 'Lens magnification': 5000.0, 'Rotation': 0.0, 'Shear': 0.003274715695854} image = model.DataArray(data, metadata) sem_stream = stream.StaticSEMStream(metadata['Description'], image) #sem_stream.image.value = model.DataArray(dataRGB, metadata) # create DataProjections for the streams fluo_stream_pj = stream.RGBSpatialProjection(fluo_stream) sem_stream_pj = stream.RGBSpatialProjection(sem_stream) self.streams = [fluo_stream_pj, sem_stream_pj] self.min_res = (623, 432) # Spectrum stream data = numpy.ones((251, 1, 1, 200, 300), dtype="uint16") data[:, 0, 0, :, 3] = range(200) data[:, 0, 0, :, 3] *= 3 data[:, 0, 0, 1, 3] = range(251) data[2, :, :, :, :] = range(300) data[200, 0, 0, 2] = range(300) wld = 433e-9 + numpy.array(range(data.shape[0])) * 0.1e-9 md = {model.MD_SW_VERSION: "1.0-test", model.MD_HW_NAME: "fake ccd", model.MD_DESCRIPTION: "Spectrum", model.MD_ACQ_DATE: time.time(), model.MD_BPP: 12, model.MD_PIXEL_SIZE: (2e-6, 2e-6), # m/px model.MD_POS: (-0.001203511795256, -0.000295338300158), # m model.MD_EXP_TIME: 0.2, # s model.MD_LENS_MAG: 60, # ratio model.MD_WL_LIST: wld, } spec_data = model.DataArray(data, md) self.spec_stream = stream.StaticSpectrumStream("test spec", spec_data) # Wait for all the streams to get an RGB image time.sleep(0.5)
def _openImage(self, filename, tint, shiftX, shiftY): """ Open the given filename and assign the tint of the corresponding channel. Add the stream to the dialog and apply the crop functionality. Two sliders are displayed for every image to provide the option of shifting the streams in x and y dimension. If there is no filename given return None. Args: filename(str) : the given filename with the R, G or B stream tint(tuple): the color tint to be assigned shiftX(ContinuousVA): shift x value in meters shiftY(ContinuousVA): shift y value in meters Returns (Stream or None): the displayed stream """ if filename == " ": return None try: data = udataio.open_acquisition(filename)[0] pxs = data.metadata.get(model.MD_PIXEL_SIZE, (1e-06, 1e-06)) if pxs[0] > 1e-04 or pxs[1] > 1e-04: data.metadata[model.MD_PIXEL_SIZE] = (1e-06, 1e-06) logging.warning( "The given pixel size %s is too big, it got replaced to the default value %s", pxs, (1e-06, 1e-06)) data = self._ensureRGB(data, tint) except Exception as ex: logging.exception("Failed to open %s", filename) self._showErrorMessage("Failed to open image", "Failed to open image:\n%s" % (ex, )) return None basename, ext = os.path.splitext(os.path.split(filename)[1]) stream_ch = stream.StaticFluoStream(basename, data) self._raw_orig[stream_ch] = data self._dlg.addStream(stream_ch) self._setupStreambar() self._cropBottom() self._connectShift(stream_ch, 0, shiftX) self._connectShift(stream_ch, 1, shiftY) return stream_ch