Пример #1
0
    def _updateStack(self):
        """Update displayed stack according to the current axes selector
        data."""
        stk = self._selector.selectedData()
        x_axis = self.__x_axis
        y_axis = self.__y_axis
        z_axis = self.__z_axis

        calibrations = []
        for axis in [z_axis, y_axis, x_axis]:

            if axis is None:
                calibrations.append(NoCalibration())
            elif len(axis) == 2:
                calibrations.append(
                    LinearCalibration(y_intercept=axis[0], slope=axis[1]))
            else:
                calibrations.append(ArrayCalibration(axis))

        legend = self.__signal_name + "["
        for sl in self._selector.selection():
            if sl == slice(None):
                legend += ":, "
            else:
                legend += str(sl) + ", "
        legend = legend[:-2] + "]"
        self._legend.setText("Displayed data: " + legend)

        self._stack_view.setStack(stk, calibrations=calibrations)
        self._stack_view.setLabels(labels=[
            self.__z_axis_name, self.__y_axis_name, self.__x_axis_name
        ])
Пример #2
0
class TestLinearCalibration(unittest.TestCase):
    def setUp(self):
        self.y_intercept = 1.5
        self.slope = 2.5
        self.calib = LinearCalibration(y_intercept=self.y_intercept,
                                       slope=self.slope)

    def testIsAffine(self):
        self.assertTrue(self.calib.is_affine())

    def testSlope(self):
        self.assertEqual(self.calib.get_slope(), self.slope)

    def testYIntercept(self):
        self.assertEqual(self.calib(0.),
                         self.y_intercept)

    def testCall(self):
        self.assertTrue(numpy.array_equal(self.calib(X),
                                          self.y_intercept + self.slope * X))
Пример #3
0
class TestLinearCalibration(unittest.TestCase):
    def setUp(self):
        self.y_intercept = 1.5
        self.slope = 2.5
        self.calib = LinearCalibration(y_intercept=self.y_intercept,
                                       slope=self.slope)

    def testIsAffine(self):
        self.assertTrue(self.calib.is_affine())

    def testSlope(self):
        self.assertEqual(self.calib.get_slope(), self.slope)

    def testYIntercept(self):
        self.assertEqual(self.calib(0.),
                         self.y_intercept)

    def testCall(self):
        self.assertTrue(numpy.array_equal(self.calib(X),
                                          self.y_intercept + self.slope * X))
Пример #4
0
    def _updateVolume(self):
        """Update displayed stack according to the current axes selector
        data."""
        x_axis = self.__x_axis
        y_axis = self.__y_axis
        z_axis = self.__z_axis

        offset = []
        scale = []
        for axis in [x_axis, y_axis, z_axis]:
            if axis is None:
                calibration = NoCalibration()
            elif len(axis) == 2:
                calibration = LinearCalibration(y_intercept=axis[0],
                                                slope=axis[1])
            else:
                calibration = ArrayCalibration(axis)
            if not calibration.is_affine():
                _logger.warning("Axis has not linear values, ignored")
                offset.append(0.)
                scale.append(1.)
            else:
                offset.append(calibration(0))
                scale.append(calibration.get_slope())

        legend = self.__signal_name + "["
        for sl in self._selector.selection():
            if sl == slice(None):
                legend += ":, "
            else:
                legend += str(sl) + ", "
        legend = legend[:-2] + "]"
        self._legend.setText("Displayed data: " + legend)

        # Update SceneWidget
        data = self._selector.selectedData()

        volumeView = self.getVolumeView()
        volumeView.setData(data, offset=offset, scale=scale)
        volumeView.setAxesLabels(self.__x_axis_name, self.__y_axis_name,
                                 self.__z_axis_name)
Пример #5
0
 def setUp(self):
     self.y_intercept = 1.5
     self.slope = 2.5
     self.calib = LinearCalibration(y_intercept=self.y_intercept,
                                    slope=self.slope)
Пример #6
0
 def setUp(self):
     self.y_intercept = 1.5
     self.slope = 2.5
     self.calib = LinearCalibration(y_intercept=self.y_intercept,
                                    slope=self.slope)