def test_calculate_mean_spectrum_masked_image(self): mani.apply_segmentation(self.specialmsi, self.segmentation) mani.calculate_mean_spectrum(self.specialmsi) np.testing.assert_equal(self.specialValue, self.specialmsi.get_image(), "mean spectrum is correctly calculated on image with " + "mask applied")
def test_apply_segmentation(self): mani.apply_segmentation(self.specialmsi, self.segmentation) validImageEntries = self.specialmsi.get_image() \ [~self.specialmsi.get_image().mask] np.testing.assert_equal(validImageEntries, self.specialValue, "image has been correctly segmented")
def setUp(self): self.msi = helpers.getFakeMsi() # set one pixel to special values self.specialValue = np.arange(self.msi.get_image().shape[-1]) * 2 self.msi.get_image()[2, 2, :] = self.specialValue # create a segmentation which sets all elements to invalid but the # one pixel with the special value self.segmentation = np.zeros(self.msi.get_image().shape[0:-1]) self.segmentation[2, 2] = 1 # apply this segmentation to the msi msimani.apply_segmentation(self.msi, self.segmentation) self.image = self.msi.get_image()