예제 #1
0
    def test_line_raw(self):
        filename = "test-spec-line.csv"

        self.spec_stream.selectionWidth.value = 1
        proj = LineSpectrumProjection(self.spec_stream)
        exported_data = img.line_to_export_data(proj, True)
        self.assertEqual(exported_data.shape[1], self.spec_data.shape[0])
        self.assertGreater(exported_data.shape[0], 64)  # at least 65-1 px
        self.assertEqual(exported_data.metadata[model.MD_DIMS], "XC")

        # Save into a CSV file
        exporter = dataio.get_converter("CSV")
        exporter.export(filename, exported_data)
        st = os.stat(filename)  # this test also that the file is created
        self.assertGreater(st.st_size, 100)

        self.spec_stream.selectionWidth.value = 4
        exported_data = img.line_to_export_data(proj, True)
        self.assertEqual(exported_data.shape[1], self.spec_data.shape[0])
        self.assertGreater(exported_data.shape[0], 64)  # at least 65-1 px
        self.assertEqual(exported_data.metadata[model.MD_DIMS], "XC")

        # Save into a CSV file
        exporter = dataio.get_converter("CSV")
        exporter.export(filename, exported_data)
        st = os.stat(filename)  # this test also that the file is created
        self.assertGreater(st.st_size, 100)

        # clean up
        try:
            os.remove(filename)
        except Exception:
            pass
예제 #2
0
파일: img_test.py 프로젝트: pieleric/odemis
    def test_line_raw(self):
        filename = "test-spec-line.csv"

        self.spec_stream.selectionWidth.value = 1
        proj = LineSpectrumProjection(self.spec_stream)
        exported_data = img.line_to_export_data(proj, True)
        self.assertEqual(exported_data.shape[1], self.spec_data.shape[0])
        self.assertGreater(exported_data.shape[0], 64)  # at least 65-1 px
        self.assertEqual(exported_data.metadata[model.MD_DIMS],"XC")

        # Save into a CSV file
        exporter = dataio.get_converter("CSV")
        exporter.export(filename, exported_data)
        st = os.stat(filename)  # this test also that the file is created
        self.assertGreater(st.st_size, 100)

        self.spec_stream.selectionWidth.value = 4
        exported_data = img.line_to_export_data(proj, True)
        self.assertEqual(exported_data.shape[1], self.spec_data.shape[0])
        self.assertGreater(exported_data.shape[0], 64)  # at least 65-1 px
        self.assertEqual(exported_data.metadata[model.MD_DIMS],"XC")

        # Save into a CSV file
        exporter = dataio.get_converter("CSV")
        exporter.export(filename, exported_data)
        st = os.stat(filename)  # this test also that the file is created
        self.assertGreater(st.st_size, 100)

        # clean up
        try:
            os.remove(filename)
        except Exception:
            pass
예제 #3
0
    def test_line_ready(self):
        self.spec_stream.selectionWidth.value = 1
        exported_data = img.line_to_export_data(self.spec_stream, False)
        self.assertEqual(exported_data.metadata[model.MD_DIMS], 'YXC')  # ready for RGB export
        self.assertEqual(exported_data.shape[:2],
                         (img.SPEC_PLOT_SIZE + img.SPEC_SCALE_HEIGHT + img.SMALL_SCALE_WIDTH,
                          img.SPEC_PLOT_SIZE + img.SPEC_SCALE_WIDTH + img.SMALL_SCALE_WIDTH))  # exported image includes scale bars

        self.spec_stream.selectionWidth.value = 3
        exported_data = img.line_to_export_data(self.spec_stream, False)
        self.assertEqual(exported_data.metadata[model.MD_DIMS], 'YXC')  # ready for RGB export
        self.assertEqual(exported_data.shape[:2],
                         (img.SPEC_PLOT_SIZE + img.SPEC_SCALE_HEIGHT + img.SMALL_SCALE_WIDTH,
                          img.SPEC_PLOT_SIZE + img.SPEC_SCALE_WIDTH + img.SMALL_SCALE_WIDTH))  # exported image includes scale bars
예제 #4
0
    def test_line_ready(self):
        self.spec_stream.selectionWidth.value = 1
        exported_data = img.line_to_export_data(self.spec_stream, False)
        self.assertEqual(exported_data.metadata[model.MD_DIMS], 'YXC')  # ready for RGB export
        self.assertEqual(exported_data.shape[:2],
                         (img.SPEC_PLOT_SIZE + img.SPEC_SCALE_HEIGHT + img.SMALL_SCALE_WIDTH,
                          img.SPEC_PLOT_SIZE + img.SPEC_SCALE_WIDTH + img.SMALL_SCALE_WIDTH))  # exported image includes scale bars

        self.spec_stream.selectionWidth.value = 3
        exported_data = img.line_to_export_data(self.spec_stream, False)
        self.assertEqual(exported_data.metadata[model.MD_DIMS], 'YXC')  # ready for RGB export
        self.assertEqual(exported_data.shape[:2],
                         (img.SPEC_PLOT_SIZE + img.SPEC_SCALE_HEIGHT + img.SMALL_SCALE_WIDTH,
                          img.SPEC_PLOT_SIZE + img.SPEC_SCALE_WIDTH + img.SMALL_SCALE_WIDTH))  # exported image includes scale bars
예제 #5
0
파일: export.py 프로젝트: ktsitsikas/odemis
    def export(self, export_type, raw=False):
        """
        Returns the data to be exported with respect to the settings and options.

        :param export_type (string): spatial, AR, spectrum or spectrum-line
        :param raw (boolean): raw data format if True
        :param interpolate_data (boolean): apply interpolation on data if True

        returns DataArray or list of DataArray: the data to be exported, either
          an RGB image or raw data.
        raises:
            LookupError: if no data found to export
        """
        fview = self._data_model.focussedView.value
        vp = self.get_viewport_by_view(fview)
        streams = fview.getStreams()
        if export_type == 'AR':
            # TODO: set MD_ACQ_TYPE in stream code
            for i, _ in enumerate(streams):
                for r in streams[i].raw:
                    r.metadata[model.MD_ACQ_TYPE] = model.MD_AT_AR
            exported_data = ar_to_export_data(streams, raw)
        elif export_type == 'spectrum':
            spectrum = vp.stream.get_pixel_spectrum()
            spectrum_range, unit = vp.stream.get_spectrum_range()
            spectrum.metadata[model.MD_ACQ_TYPE] = model.MD_AT_SPECTRUM
            exported_data = spectrum_to_export_data(spectrum, raw, unit, spectrum_range)
        elif export_type == 'spectrum-line':
            spectrum_md = vp.stream.get_pixel_spectrum().metadata
            spectrum = vp.stream.get_line_spectrum()
            # copy only non existed values (we mainly care about MD_WL_*)
            spectrum.metadata.update({k: v for k, v in spectrum_md.iteritems() if k not in spectrum.metadata})
            spectrum_range, unit = vp.stream.get_spectrum_range()
            spectrum.metadata[model.MD_ACQ_TYPE] = model.MD_AT_SPECTRUM
            exported_data = line_to_export_data(spectrum, raw, unit, spectrum_range)
        else:
            export_type = 'spatial'
            view_px = tuple(vp.canvas.ClientSize)
            view_mpp = fview.mpp.value
            view_hfw = (view_mpp * view_px[0], view_mpp * view_px[1])
            view_pos = fview.view_pos.value
            draw_merge_ratio = fview.stream_tree.kwargs.get("merge", 0.5)
            interpolate_data = fview.interpolate_content.value
            exported_data = images_to_export_data(streams,
                                                  view_hfw, view_pos,
                                                  draw_merge_ratio, raw,
                                                  interpolate_data=interpolate_data,
                                                  logo=self._main_frame.legend_logo)

        return exported_data
예제 #6
0
파일: export.py 프로젝트: lanery/odemis
    def export(self, export_type, raw=False):
        """
        Returns the data to be exported with respect to the settings and options.

        :param export_type (string): spatial, AR, spectrum, spectrum-temporal,
            spectrum-time, or spectrum-line
        :param raw (boolean): raw data format if True
        :param interpolate_data (boolean): apply interpolation on data if True

        returns DataArray or list of DataArray: the data to be exported, either
          an RGB image or raw data.
        raises:
            LookupError: if no data found to export
        """
        fview = self._data_model.focussedView.value
        vp = self.get_viewport_by_view(fview)
        streams = fview.stream_tree.getProjections(
        )  # Stream tree to get the DataProjection
        if export_type == 'AR':
            exported_data = ar_to_export_data(streams, raw)
        elif export_type == 'spectrum':
            exported_data = spectrum_to_export_data(streams[0], raw, vp)
        elif export_type == 'spectrum-line':
            exported_data = line_to_export_data(streams[0], raw)
        elif export_type == 'spectrum-temporal':
            exported_data = temporal_spectrum_to_export_data(streams[0], raw)
        elif export_type == 'spectrum-time':
            exported_data = chronogram_to_export_data(streams[0], raw, vp)
        else:
            view_px = tuple(vp.canvas.ClientSize)
            view_mpp = fview.mpp.value
            view_hfw = (view_mpp * view_px[0], view_mpp * view_px[1])
            view_pos = fview.view_pos.value
            draw_merge_ratio = fview.stream_tree.kwargs.get("merge", 0.5)
            interpolate_data = fview.interpolate_content.value
            exported_data = images_to_export_data(
                streams,
                view_hfw,
                view_pos,
                draw_merge_ratio,
                raw,
                vp.canvas,
                interpolate_data=interpolate_data,
                logo=self._main_frame.legend_logo)

        return exported_data
예제 #7
0
    def test_line_raw(self):
        filename = "test-spec-line.csv"

        exported_data = img.line_to_export_data(self.spectrum, True, self.unit, self.spectrum_range)
        self.assertEqual(exported_data.shape[0], self.spectrum.shape[1])
        self.assertEqual(exported_data.shape[1], self.spectrum.shape[0])

        # Save into a CSV file
        exporter = dataio.get_converter("CSV")
        exporter.export(filename, exported_data)
        st = os.stat(filename)  # this test also that the file is created
        self.assertGreater(st.st_size, 100)

        # clean up
        try:
            os.remove(filename)
        except Exception:
            pass
예제 #8
0
파일: export.py 프로젝트: delmic/odemis
    def export(self, export_type, raw=False):
        """
        Returns the data to be exported with respect to the settings and options.

        :param export_type (string): spatial, AR, spectrum, spectrum-temporal,
            spectrum-time, or spectrum-line
        :param raw (boolean): raw data format if True
        :param interpolate_data (boolean): apply interpolation on data if True

        returns DataArray or list of DataArray: the data to be exported, either
          an RGB image or raw data.
        raises:
            LookupError: if no data found to export
        """
        fview = self._data_model.focussedView.value
        vp = self.get_viewport_by_view(fview)
        streams = fview.stream_tree.getProjections()  # Stream tree to get the DataProjection
        if export_type == 'AR':
            exported_data = ar_to_export_data(streams, raw)
        elif export_type == 'spectrum':
            exported_data = spectrum_to_export_data(streams[0], raw, vp)
        elif export_type == 'spectrum-line':
            exported_data = line_to_export_data(streams[0], raw)
        elif export_type == 'spectrum-temporal':
            exported_data = temporal_spectrum_to_export_data(streams[0], raw)
        elif export_type == 'spectrum-time':
            exported_data = chronogram_to_export_data(streams[0], raw, vp)
        else:
            view_px = tuple(vp.canvas.ClientSize)
            view_mpp = fview.mpp.value
            view_hfw = (view_mpp * view_px[0], view_mpp * view_px[1])
            view_pos = fview.view_pos.value
            draw_merge_ratio = fview.stream_tree.kwargs.get("merge", 0.5)
            interpolate_data = fview.interpolate_content.value
            exported_data = images_to_export_data(streams,
                                                  view_hfw, view_pos,
                                                  draw_merge_ratio, raw,
                                                  interpolate_data=interpolate_data,
                                                  logo=self._main_frame.legend_logo)

        return exported_data
예제 #9
0
 def test_line_ready(self):
     exported_data = img.line_to_export_data(self.spectrum, False, self.unit, self.spectrum_range)
     self.assertEqual(exported_data.metadata[model.MD_DIMS], 'YXC')  # ready for RGB export
     self.assertEqual(exported_data.shape[:2],
                      (img.SPEC_PLOT_SIZE + img.SPEC_SCALE_HEIGHT + img.SMALL_SCALE_WIDTH,
                       img.SPEC_PLOT_SIZE + img.SPEC_SCALE_WIDTH + img.SMALL_SCALE_WIDTH))  # exported image includes scale bars