Exemplo n.º 1
0
    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.flatfield_folder)
        image_files = filter(lambda image_name: "F0" in image_name,
                             image_files)

        # helper function to take maximum of two images
        def maximum_of_two_images(image_1, image_name_2):
            image_2 = tiff_ring_reader.read(
                os.path.join(self.flatfield_folder, image_name_2),
                nr_filters)[0].get_image()
            return np.maximum(image_1, image_2)

        # now reduce to maximum of all the single images
        flat_maximum = reduce(lambda x, y: maximum_of_two_images(x, y),
                              image_files, 0)
        msi = Msi(image=flat_maximum)
        msi.set_wavelengths(sc.other["RECORDED_WAVELENGTHS"])

        # write flatfield as nrrd
        writer = NrrdWriter(msi)
        writer.write(self.output().path)
Exemplo n.º 2
0
def getFakeMsi():

    # build a fake multispectral image with 5 dimensions.
    image = np.concatenate((np.ones((5, 5, 1)), np.ones(
        (5, 5, 1)) * 2, np.ones((5, 5, 1)) * 3, np.ones(
            (5, 5, 1)) * 4, np.ones((5, 5, 1)) * 5),
                           axis=-1)
    msi = Msi(image)

    msi.set_wavelengths(np.array([5, 4, 3, 2, 1]))

    return msi
Exemplo n.º 3
0
def getFakeMsi():

        # build a fake multispectral image with 5 dimensions.
    image = np.concatenate((np.ones((5, 5, 1)),
                            np.ones((5, 5, 1)) * 2,
                            np.ones((5, 5, 1)) * 3,
                            np.ones((5, 5, 1)) * 4,
                            np.ones((5, 5, 1)) * 5),
                           axis=-1)
    msi = Msi(image)

    msi.set_wavelengths(np.array([5, 4, 3, 2, 1]))

    return msi
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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.flatfield_folder)
        image_files = filter(lambda image_name: "F0" in image_name, image_files)

        # helper function to take maximum of two images
        def maximum_of_two_images(image_1, image_name_2):
            image_2 = tiff_ring_reader.read(os.path.join(self.flatfield_folder,
                                                         image_name_2),
                                            nr_filters)[0].get_image()
            return np.maximum(image_1, image_2)

        # now reduce to maximum of all the single images
        flat_maximum = reduce(lambda x, y: maximum_of_two_images(x, y),
                              image_files, 0)
        msi = Msi(image=flat_maximum)
        msi.set_wavelengths(sc.other["RECORDED_WAVELENGTHS"])

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