コード例 #1
0
    def test_calculate_mean_spectrum(self):

        mani.calculate_mean_spectrum(self.specialmsi)

        np.testing.assert_equal(np.array([0.96, 2., 3.04, 4.08, 5.12]),
                                self.specialmsi.get_image(),
                        "mean spectrum is correctly calculated on image with " +
                        "no mask applied")
コード例 #2
0
    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")
コード例 #3
0
    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")
コード例 #4
0
    def test_calculate_mean_spectrum(self):

        mani.calculate_mean_spectrum(self.specialmsi)

        np.testing.assert_equal(np.array([0.96, 2., 3.04, 4.08, 5.12]),
                                self.specialmsi.get_image(),
                        "mean spectrum is correctly calculated on image with " +
                        "no mask applied")
コード例 #5
0
    def test_write_one_d_image_works(self):
        writer = NrrdWriter(self.msi)
        msimani.calculate_mean_spectrum(self.msi)
        writer.write(self.fileUriToWrite)

        reader = NrrdReader()
        msi = reader.read(self.fileUriToWrite)
        np.testing.assert_array_equal(msi.get_image(),
                                      np.array([1, 2, 3, 4, 5]),
                                      "1d image correctly written and read")
コード例 #6
0
ファイル: test_nrrdwriter.py プロジェクト: 151706061/MITK
    def test_write_one_d_image_works(self):
        writer = NrrdWriter(self.msi)
        msimani.calculate_mean_spectrum(self.msi)
        writer.write(self.fileUriToWrite)

        reader = NrrdReader()
        msi = reader.read(self.fileUriToWrite)
        np.testing.assert_array_equal(msi.get_image(),
                                      np.array([1, 2, 3, 4, 5]),
                                      "1d image correctly written and read")
コード例 #7
0
    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")
コード例 #8
0
    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")
コード例 #9
0
    def test_dark_correction_with_single_value(self):
        desired_image_data = copy.copy(self.specialmsi.get_image())
        desired_image_data -= 1

        dark = copy.copy(self.specialmsi)
        dark.set_image(np.ones_like(dark.get_image()))
        mani.calculate_mean_spectrum(dark)

        mani.dark_correction(self.specialmsi, dark)

        np.testing.assert_equal(self.specialmsi.get_image(),
                                       desired_image_data,
                "dark image correctly accounted for from singular dark value")
        np.testing.assert_equal(dark.get_image(),
                                       np.ones_like(dark.get_image()),
                "dark image unchanged by dark correction")
コード例 #10
0
    def test_dark_correction_with_single_value(self):
        desired_image_data = copy.copy(self.specialmsi.get_image())
        desired_image_data -= 1

        dark = copy.copy(self.specialmsi)
        dark.set_image(np.ones_like(dark.get_image()))
        mani.calculate_mean_spectrum(dark)

        mani.dark_correction(self.specialmsi, dark)

        np.testing.assert_equal(self.specialmsi.get_image(),
                                       desired_image_data,
                "dark image correctly accounted for from singular dark value")
        np.testing.assert_equal(dark.get_image(),
                                       np.ones_like(dark.get_image()),
                "dark image unchanged by dark correction")
コード例 #11
0
ファイル: tasks_common.py プロジェクト: dishamishra/MITKats
    def run(self):
        tiff_ring_reader = TiffRingReader()
        nr_filters = len(sc.other["RECORDED_WAVELENGTHS"])

        # analyze all the first image files
        image_files = get_image_files_from_folder(self.dark_folder,
                                                  suffix="F0.tiff")

        # returns the mean dark image vector of all inputted dark image
        # overly complicated TODO SW: make this simple code readable.
        dark_means = map(
            lambda image_name: msimani.calculate_mean_spectrum(
                tiff_ring_reader.read(
                    os.path.join(self.dark_folder, image_name), nr_filters)[0]
            ), image_files)
        dark_means_sum = reduce(lambda x, y: x + y.get_image(), dark_means, 0)
        final_dark_mean = dark_means_sum / len(dark_means)

        msi = Msi(image=final_dark_mean)
        msi.set_wavelengths(sc.other["RECORDED_WAVELENGTHS"])

        # write flatfield as nrrd
        writer = NrrdWriter(msi)
        writer.write(self.output().path)
コード例 #12
0
ファイル: tasks_common.py プロジェクト: 151706061/MITK
    def run(self):
        tiff_ring_reader = TiffRingReader()
        nr_filters = len(sc.other["RECORDED_WAVELENGTHS"])

        # analyze all the first image files
        image_files = get_image_files_from_folder(self.dark_folder,
                                                  suffix="F0.tiff")

        # returns the mean dark image vector of all inputted dark image
        # overly complicated TODO SW: make this simple code readable.
        dark_means = map(lambda image_name:
                            msimani.calculate_mean_spectrum(
                                tiff_ring_reader.read(os.path.join(self.dark_folder, image_name),
                                                      nr_filters)[0]),
                         image_files)
        dark_means_sum = reduce(lambda x, y: x+y.get_image(), dark_means, 0)
        final_dark_mean = dark_means_sum / len(dark_means)

        msi = Msi(image=final_dark_mean)
        msi.set_wavelengths(sc.other["RECORDED_WAVELENGTHS"])

        # write flatfield as nrrd
        writer = NrrdWriter(msi)
        writer.write(self.output().path)