def test_flatfield_correction_differing_integration_times(self): MSI_INTEGRATION_TIME = 3.0 FLATFIELD_INTEGRATION_TIME = 2.0 desired_image_data = np.ones_like(self.specialmsi.get_image()) * \ FLATFIELD_INTEGRATION_TIME / MSI_INTEGRATION_TIME desired_image_data[2, 2, 0] = np.nan self.specialmsi.add_property({"integration times": np.ones_like( self.specialmsi.get_image()[0, 0, :]) * MSI_INTEGRATION_TIME}) flatfield = copy.deepcopy(self.specialmsi) flatfield.add_property({"integration times": np.ones_like( flatfield.get_image()[0, 0, :]) * FLATFIELD_INTEGRATION_TIME}) # for testing if flatfield does not changed by correction we copy it flatfield_copy = copy.deepcopy(flatfield) mani.flatfield_correction(self.specialmsi, flatfield_copy) np.testing.assert_almost_equal(self.specialmsi.get_image(), desired_image_data, 15, "corrected image is a division of integration times") np.testing.assert_equal(flatfield.get_image(), flatfield_copy.get_image(), "flatfield doesn't change by correction")
def test_flatfield_correction(self): desired_image_data = np.ones_like(self.specialmsi.get_image()) desired_image_data[2, 2, 0] = np.nan mani.flatfield_correction(self.specialmsi, self.specialmsi) np.testing.assert_equal(self.specialmsi.get_image(), desired_image_data, "correct image by itself should lead to only 1s ")
def test_flatfield_correction_with_single_value(self): desired_image_data = np.ones_like(self.msi.get_image()) flatfield = copy.copy(self.msi) mani.calculate_mean_spectrum(flatfield) unchanged_flatfield = copy.deepcopy(flatfield) mani.flatfield_correction(self.msi, flatfield) np.testing.assert_equal(self.msi.get_image(), desired_image_data, "flatfield correctly accounted for from singular reference value") np.testing.assert_equal(flatfield, unchanged_flatfield, "flatfield not changed by algorithm")