def _set3DScaleAndOrigin(self, calibrations): """Set scale and origin for all 3 axes, to be used when plotting an image. See setStack for parameter documentation """ if calibrations is None: self.calibrations3D = (calibration.NoCalibration(), calibration.NoCalibration(), calibration.NoCalibration()) else: self.calibrations3D = [] for i, calib in enumerate(calibrations): if hasattr(calib, "__len__") and len(calib) == 2: calib = calibration.LinearCalibration(calib[0], calib[1]) elif calib is None: calib = calibration.NoCalibration() elif not isinstance(calib, calibration.AbstractCalibration): raise TypeError("calibration must be a 2-tuple, None or" + " an instance of an AbstractCalibration " + "subclass") elif not calib.is_affine(): _logger.warning( "Calibration for dimension %d is not linear, " "it will be ignored for scaling the graph axes.", i) self.calibrations3D.append(calib)
def getCalibrations(self, order='array'): """Returns currently used calibrations for each axis Returned calibrations might differ from the ones that were set as non-linear calibrations used for image axes are temporarily ignored. :param str order: 'array' to sort calibrations as data array (dim0, dim1, dim2), 'axes' to sort calibrations as currently selected x, y and z axes. :return: Calibrations ordered depending on order :rtype: List[~silx.math.calibration.AbstractCalibration] """ assert order in ('array', 'axes') calibs = [] # filter out non-linear calibration for graph axes for index, calib in enumerate(self.calibrations3D): if index != self._perspective and not calib.is_affine(): calib = calibration.NoCalibration() calibs.append(calib) if order == 'axes': # Move 'z' axis to the end xy_dims = [d for d in (0, 1, 2) if d != self._perspective] calibs = [calibs[max(xy_dims)], calibs[min(xy_dims)], calibs[self._perspective]] return tuple(calibs)
def _set3DScaleAndOrigin(self, calibrations): """Set scale and origin for all 3 axes, to be used when plotting an image. See setStack for parameter documentation """ if calibrations is None: self.calibrations3D = (calibration.NoCalibration(), calibration.NoCalibration(), calibration.NoCalibration()) else: self.calibrations3D = [] for calib in calibrations: if hasattr(calib, "__len__") and len(calib) == 2: calib = calibration.LinearCalibration(calib[0], calib[1]) elif calib is None: calib = calibration.NoCalibration() elif not isinstance(calib, calibration.AbstractCalibration): raise TypeError("calibration must be a 2-tuple, None or" + " an instance of an AbstractCalibration " + "subclass") self.calibrations3D.append(calib)
def __init__(self, parent=None, resetzoom=True, backend=None, autoScale=False, logScale=False, grid=False, colormap=True, aspectRatio=True, yinverted=True, copy=True, save=True, print_=True, control=False, position=None, mask=True): qt.QMainWindow.__init__(self, parent) if parent is not None: # behave as a widget self.setWindowFlags(qt.Qt.Widget) else: self.setWindowTitle('StackView') self._stack = None """Loaded stack, as a 3D array, a 3D dataset or a list of 2D arrays.""" self.__transposed_view = None """View on :attr:`_stack` with the axes sorted, to have the orthogonal dimension first""" self._perspective = 0 """Orthogonal dimension (depth) in :attr:`_stack`""" self.__imageLegend = '__StackView__image' + str(id(self)) self.__autoscaleCmap = False """Flag to disable/enable colormap auto-scaling based on the min/max values of the entire 3D volume""" self.__dimensionsLabels = ["Dimension 0", "Dimension 1", "Dimension 2"] """These labels are displayed on the X and Y axes. :meth:`setLabels` updates this attribute.""" self._first_stack_dimension = 0 """Used for dimension labels and combobox""" self._titleCallback = self._defaultTitleCallback """Function returning the plot title based on the frame index. It can be set to a custom function using :meth:`setTitleCallback`""" self.calibrations3D = (calibration.NoCalibration(), calibration.NoCalibration(), calibration.NoCalibration()) central_widget = qt.QWidget(self) self._plot = PlotWindow(parent=central_widget, backend=backend, resetzoom=resetzoom, autoScale=autoScale, logScale=logScale, grid=grid, curveStyle=False, colormap=colormap, aspectRatio=aspectRatio, yInverted=yinverted, copy=copy, save=save, print_=print_, control=control, position=position, roi=False, mask=mask) self._plot.getIntensityHistogramAction().setVisible(True) self.sigInteractiveModeChanged = self._plot.sigInteractiveModeChanged self.sigActiveImageChanged = self._plot.sigActiveImageChanged self.sigPlotSignal = self._plot.sigPlotSignal if silx.config.DEFAULT_PLOT_IMAGE_Y_AXIS_ORIENTATION == 'downward': self._plot.getYAxis().setInverted(True) self._addColorBarAction() self._plot.profile = Profile3DToolBar(parent=self._plot, stackview=self) self._plot.addToolBar(self._plot.profile) self._plot.getXAxis().setLabel('Columns') self._plot.getYAxis().setLabel('Rows') self._plot.sigPlotSignal.connect(self._plotCallback) self.__planeSelection = PlanesWidget(self._plot) self.__planeSelection.sigPlaneSelectionChanged.connect(self.setPerspective) self._browser_label = qt.QLabel("Image index (Dim0):") self._browser = HorizontalSliderWithBrowser(central_widget) self._browser.setRange(0, 0) self._browser.valueChanged[int].connect(self.__updateFrameNumber) self._browser.setEnabled(False) layout = qt.QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._plot, 0, 0, 1, 3) layout.addWidget(self.__planeSelection, 1, 0) layout.addWidget(self._browser_label, 1, 1) layout.addWidget(self._browser, 1, 2) central_widget.setLayout(layout) self.setCentralWidget(central_widget) # clear profile lines when the perspective changes (plane browsed changed) self.__planeSelection.sigPlaneSelectionChanged.connect( self._plot.profile.getProfilePlot().clear) self.__planeSelection.sigPlaneSelectionChanged.connect( self._plot.profile.clearProfile)