예제 #1
0
 def __init__(self, *args, **kwargs):
     OverlayWindowInterface.__init__(self, *args, **kwargs)
     if self.func_man is None:
         self.func_man = SimpleManager(
             image_signal=self.image_changed,
             loc_signal=self.loc_changed,
             props_signal=self.image_props_changed)
     vbox = QtGui.QVBoxLayout(self)
     vbox.addWidget(self.func_man.make_panel(parent=self))
     QtGui.QWidget.setSizePolicy(self,
                                 QtGui.QSizePolicy.Expanding,
                                 QtGui.QSizePolicy.Expanding)
     self.updateGeometry()
예제 #2
0
 def deactivate(self, strip_overlay=False):
     if not self._activated:
         return
     OverlayWindowInterface.deactivate(self)
     if strip_overlay:
         self.tf_plane = self._initialize_tf_plane()
     self.tf_plane.canvas.mpl_disconnect(self._cx_id)
     try:
         self.external_loc.disconnect(self.func_man.main_xyz_changed)
     except:
         print 'could not disconnect external location callbacks'
         pass
     self._activated = False
예제 #3
0
 def activate(self):
     if self._activated:
         return
     # call parent class functionality first
     OverlayWindowInterface.activate(self)
     # connect a button press on the TF plane to an update MEG image event
     self._cx_id = self.tf_plane.canvas.mpl_connect(
         'button_press_event',
         self._coordinate_tf_index
         )
     # connect buttons presses on the ortho figures to an update voxel event
     try:
         self.external_loc.connect(self.func_man.main_xyz_changed)
     except:
         print 'not connected to external location signal'
     self._activated = True
예제 #4
0
    def __init__(self, loc_connections, image_connections,
                 image_props_connections, bbox,
                 functional_manager=None,
                 overlay=None, external_loc=None,
                 parent=None, main_ref=None):
        OverlayWindowInterface.__init__(self,
                                        loc_connections,
                                        image_connections,
                                        image_props_connections,
                                        bbox, # <-- TRY TO DECOUPLE THIS
                                        external_loc=external_loc,
                                        parent=parent,
                                        main_ref=main_ref,
                                        functional_manager=functional_manager)
        vbox = QtGui.QVBoxLayout(self)
        self.cbar = ColorbarPanel(parent=self, figsize=(6,2))

        vbox.addWidget(self.cbar)
        if functional_manager is None or \
               not isinstance(functional_manager, ImageOverlayManager):
            self.func_man = ImageOverlayManager(
                bbox, colorbar=self.cbar,
                loc_signal=self.loc_changed,
                image_signal=self.image_changed,
                props_signal=self.image_props_changed,
                overlay=overlay
                )
        self.func_man.connect_colorbar(self.cbar)
        # breaking independence
        if self.func_man.overlay is not None:
            print 'requesting new image signal'
            self.func_man.send_image_signal()
        
        vbox.addWidget(self.func_man.make_panel(parent=self))
        QtGui.QWidget.setSizePolicy(self,
                                    QtGui.QSizePolicy.Expanding,
                                    QtGui.QSizePolicy.Expanding)
        self.updateGeometry()
        r = self.geometry()
        self.cbar.figure.set_size_inches(r.width()/100., r.height()/200.)
        self.cbar.draw()
예제 #5
0
    def __init__(self, loc_connections, image_connections,
                 image_props_connections, bbox,
                 functional_manager=None,
                 external_loc=None, parent=None, main_ref=None,
                 tfbeam=None, **kwargs):
        """
        Creates a new MplQT4TimeFreqWindow, which controls interaction
        with Nutmeg TFBeam objects. This window is a QT4TopLevelAuxiliaryWindow,
        giving it top level status. It contains:
         *a 2D image of the time-frequency plane with selectable bins (emits a
          functional image update event and a tf event, described below)
         *a TFBeam management panel, with data management and feature
          localizations (events described below)
         *a threshold management panel, to create different mask criteria

         Time-frequency point updates cause emission of the tf_point signal.
         To cause methods to be connected to this signal, include them in the
         tf_connections iterable argument. Methods will have this signature
         pattern:
         meth(timept, freq_a, freq_b)

         Overlay image updates are also signalled. To cause methods to be
         connected, include them in the image_connections iterable argument.
         Methods will have this signature pattern:
         meth(obj)
          * obj will give access to obj.overlay, obj.alpha,
          * obj.norm, obj.fill_value

         Spatial location updates cause emission of the xyz_point signal. To
         cause methods to be connected to this signal, include them in the
         loc_connections interable argument. Methods will have this signature
         pattern:
         meth(x, y, z)

         Parameters
         ----------
         loc_connections: iterable
             Methods to connect to the xyz_point signal
         image_connections: iterable
             Methods to connect to the new_image signal
         parent: QObject (optional)
             A QT4 QObject to set as the parent of this widget (thus causing
             this widget NOT to run as a top level window)
         main_ref: QObject (optional)
             A QT4 QObject to be considered as the "parent" of this widget,
             when this widget is running as a top level window
         tfbeam: TFBeam (optional)
             A TFBeam with which to preload the beam manager.
         **kwargs:
             figsize, dpi for the time-frequency plane figure
         """

        
        figsize = kwargs.pop('figsize', (6,4))
        dpi = kwargs.pop('dpi', 100)
        # insert some local callbacks into the connection lists
        image_connections = (self._update_from_new_overlay,) + \
                            image_connections
        image_props_connections = (self.update_tf_figure,) + \
                                  image_props_connections
        OverlayWindowInterface.__init__(self,
                                        loc_connections,
                                        image_connections,
                                        image_props_connections,
                                        bbox,
                                        external_loc=external_loc,
                                        parent=parent,
                                        main_ref=main_ref,
                                        functional_manager=functional_manager)

        # make sure that when the tfbeam manager's voxel index changes,
        # the tfplane image gets updated
        self.bvox_signal.connect(self.update_tf_figure)
        if functional_manager is None or \
           not isinstance(functional_manager, TFBeamManager):
            self.func_man = TFBeamManager(
                bbox, image_signal = self.image_changed,
                loc_signal = self.loc_changed,
                props_signal = self.image_props_changed,
                beam_vox_signal=self.bvox_signal
                )

        self.func_man.beam_vox_signal = self.bvox_signal
        
        vbox = QtGui.QVBoxLayout(self)

        # set up figure
        fig = Figure(figsize=figsize, dpi=dpi)
        fig.canvas = Canvas(fig)
        QtGui.QWidget.setSizePolicy(fig.canvas,
                                    QtGui.QSizePolicy.Expanding,
                                    QtGui.QSizePolicy.Expanding)
        Canvas.updateGeometry(fig.canvas)
        fig.canvas.setParent(self)
        self.fig = fig

        # fake plane at first
        self.tf_plane = self._initialize_tf_plane()
        vbox.addWidget(self.fig.canvas)

        vbox.addWidget(self.func_man.make_panel(parent=self))

        QtGui.QWidget.setSizePolicy(self,
                                    QtGui.QSizePolicy.Expanding,
                                    QtGui.QSizePolicy.Expanding)
        self.updateGeometry()
        if tfbeam is not None:
            self.func_man.update_beam(tfbeam)