def __init__(self, name, image): """ Note: parameters are different from the base class. image (DataArray of shape (111)YX): raw data. The metadata should contain at least MD_POS and MD_PIXEL_SIZE. It should also contain MD_IN_WL and MD_OUT_WL. """ # Wavelengths try: exc_range = image.metadata[model.MD_IN_WL] self.excitation = VigilantAttribute(exc_range, unit="m", readonly=True) except KeyError: logging.warning("No excitation wavelength for fluorescence stream") try: em_range = image.metadata[model.MD_OUT_WL] self.emission = VigilantAttribute(em_range, unit="m", readonly=True) default_tint = conversion.wave2rgb(numpy.mean(em_range)) except KeyError: logging.warning("No emission wavelength for fluorescence stream") default_tint = (0, 255, 0) # green is most typical # colouration of the image tint = image.metadata.get(model.MD_USER_TINT, default_tint) self.tint = model.ListVA(tint, unit="RGB") # 3-tuple R,G,B self.tint.subscribe(self.onTint) # Do it at the end, as it forces it the update of the image StaticStream.__init__(self, name, image)
def __init__(self, name, raw): """ Note: parameters are different from the base class. raw (DataArray of shape (111)YX): raw data. The metadata should contain at least MD_POS and MD_PIXEL_SIZE. It should also contain MD_IN_WL and MD_OUT_WL. """ # Note: it will update the image, and changing the tint will do it again super(StaticFluoStream, self).__init__(name, raw) # Wavelengths try: exc_range = raw.metadata[model.MD_IN_WL] self.excitation = VigilantAttribute(exc_range, unit="m", readonly=True) except KeyError: logging.warning("No excitation wavelength for fluorescence stream") default_tint = (0, 255, 0) # green is most typical try: em_range = raw.metadata[model.MD_OUT_WL] if isinstance(em_range, basestring): unit = None else: unit = "m" default_tint = conversion.wave2rgb(numpy.mean(em_range)) self.emission = VigilantAttribute(em_range, unit=unit, readonly=True) except KeyError: logging.warning("No emission wavelength for fluorescence stream") # colouration of the image tint = raw.metadata.get(model.MD_USER_TINT, default_tint) self.tint.value = tint
def __init__(self, main): self.main = main # Streams available (handled by StreamController) # Note: we need to make sure ourselves that each stream in this # attribute is unique (i.e. only occurs once in the list). self.streams = model.ListVA() # Available Views. The are handled by the ViewController. # The `views` list basically keeps track of the relevant references. self.views = model.ListVA() # Current tool selected (from the toolbar, cf cont.tools) self.tool = None # Needs to be overridden by a IntEnumerated # The MicroscopeView currently focused, it is one of the `views` # or `None`. self.focussedView = VigilantAttribute(None) layouts = set( [VIEW_LAYOUT_ONE, VIEW_LAYOUT_22, VIEW_LAYOUT_FULLSCREEN]) self.viewLayout = model.IntEnumerated(VIEW_LAYOUT_22, choices=layouts) # The subset of views taken from `views` that *can* actually displayed, # but they might be hidden as well. # This attribute is also handled and manipulated by the ViewController. self.visible_views = model.ListVA()
def __init__(self, main): MicroscopyGUIData.__init__(self, main) self._conf = get_general_conf() # only tool to zoom and pick point/line tools = set([TOOL_NONE, TOOL_ZOOM, TOOL_POINT, TOOL_LINE]) self.tool = IntEnumerated(TOOL_NONE, choices=tools) # The current file it displays. If None, it means there is no file # associated to the data displayed self.acq_fileinfo = VigilantAttribute(None) # a FileInfo # The current file being used for calibration. It is set to u"" # when no calibration is used. They are directly synchronised with the # configuration file. ar_file = self._conf.get("calibration", "ar_file") spec_bck_file = self._conf.get("calibration", "spec_bck_file") spec_file = self._conf.get("calibration", "spec_file") self.ar_cal = StringVA(ar_file) # a unicode self.spec_bck_cal = StringVA(spec_bck_file) # a unicode self.spec_cal = StringVA(spec_file) # a unicode self.ar_cal.subscribe(self._on_ar_cal) self.spec_bck_cal.subscribe(self._on_spec_bck_cal) self.spec_cal.subscribe(self._on_spec_cal)
def __init__(self, name): self.name = model.StringVA(name) # a thumbnail version of what is displayed self.thumbnail = VigilantAttribute(None) # contains a wx.Image # Last time the image of the view was changed. It's actually mostly # a trick to allow other parts of the GUI to know when the (theoretical) # composited image has changed. self.lastUpdate = model.FloatVA(time.time(), unit="s")
def __init__(self, name, image): """ Note: parameters are different from the base class. image (DataArray of shape YX3): image to display. The metadata should contain at least MD_POS and MD_PIXEL_SIZE. """ Stream.__init__(self, name, None, None, None) # Check it's 2D if not (len(image.shape) == 3 and image.shape[2] in [3, 4]): raise ValueError("Data must be RGB(A)") # TODO: use original image as raw, to allow changing the B/C/tint # Need to distinguish between greyscale (possible) and colour (impossible) self.image = VigilantAttribute(image)
def __init__(self, plugin, title, text=None): """ Creates a modal window. The return code is the button number that was last pressed before closing the window. title (str): The title of the window text (None or str): If provided, it is displayed at the top of the window """ super(AcquisitionDialog, self).__init__(plugin.main_app.main_frame) self.plugin = plugin self.SetTitle(title) if text is not None: self.lbl_description = AutoWrapStaticText(self.pnl_desc, "") self.lbl_description.SetBackgroundColour( self.pnl_desc.GetBackgroundColour()) self.pnl_desc.GetSizer().Add(self.lbl_description, flag=wx.EXPAND | wx.ALL, border=10) self.lbl_description.SetLabel(text) self.entries = [] # Setting entries self._acq_future_connector = None self.canvas = None self.buttons = [] # The buttons self.current_future = None self.btn_cancel.Bind(wx.EVT_BUTTON, self._cancel_future) self.setting_controller = SettingsController(self.fp_settings, "No settings defined") # Create a minimal model for use in the streambar controller data_model = MicroscopyGUIData(plugin.main_app.main_data) self.microscope_view = MicroscopeView("Plugin View") data_model.focussedView = VigilantAttribute(self.microscope_view) self.viewport.setView(self.microscope_view, data_model) self.streambar_controller = StreamBarController(data_model, self.pnl_streams, ignore_view=True) self.Refresh() self.Fit()
def __init__(self, name, raw): """ Note: parameters are different from the base class. raw (DataArray of shape (111)YX): raw data. The metadata should contain at least MD_POS and MD_PIXEL_SIZE. It should also contain MD_OUT_WL. """ try: em_range = raw.metadata[model.MD_OUT_WL] if isinstance(em_range, basestring): unit = None else: unit = "m" self.emission = VigilantAttribute(em_range, unit=unit, readonly=True) except KeyError: logging.warning("No emission wavelength for CL stream") # Do it at the end, as it forces it the update of the image Static2DStream.__init__(self, name, raw)