예제 #1
0
    def test_put_probmap_data_when_no_labels_available(self):

        img_path = os.path.abspath(
            os.path.join(base_path, '../test_data/tiffconnector_1/im/*'))

        c = io_connector(img_path, '', savepath=self.tmpdir)
        d = Dataset(c)

        size = (1, 3, 4)
        batch_size = 2

        p = PredictionBatch(d, batch_size, size)

        data = np.ones((2, 2, 1, 3, 4))
        p[0].put_probmap_data(data)

        data = np.ones((2, 2, 1, 3, 4))
        p[1].put_probmap_data(data)

        data = np.ones((2, 2, 1, 3, 4))
        p[2].put_probmap_data(data)

        val = [
            '40width26height3slices_rgb_class_1.tif',
            '40width26height3slices_rgb_class_2.tif'
        ]
        self.assertEqual(sorted(os.listdir(self.tmpdir)), val)
예제 #2
0
    def load_training_data(self, image_path, label_path, batch_size=None):
        '''
        Connect to a training dataset.

        Parameters
        ----------
        image_path : string
            Path to folder with tiff images.
        label_path : string
            Path to folder with label tiff images or path to ilastik project
            file (.ilp file).
        '''

        _connector = io_connector(image_path, label_path)
        self.lbl_map = _connector.labelvalue_mapping[0]

        self.dataset = Dataset(_connector)
        if batch_size is None:
            self.batch_size = len(self.dataset.label_values())
        else:
            self.batch_size = batch_size

        msg = '\n\nImport taining dataset:\n{}\n'.format(
            self.dataset.pixel_connector.__repr__())
        sys.stdout.write(msg)
예제 #3
0
파일: session.py 프로젝트: doshih/yapic
    def load_prediction_data(self, image_path, save_path):
        '''
        Connect to a prediction dataset.

        Parameters
        ----------
        image_path : string
            Path to folder with tiff images to predict.
        save_path : string
            Path to folder for saving prediction images.
        '''

        self.dataset = Dataset(
            io_connector(image_path,
                         '/tmp/this_should_not_exist',
                         savepath=save_path))
예제 #4
0
    def test_load_label_counts_from_ilastik(self):
        img_path = os.path.join(base_path, '../test_data/ilastik')
        lbl_path = os.path.join(base_path,
                                '../test_data/ilastik/ilastik-1.2.ilp')

        c = io_connector(img_path, lbl_path)
        d = Dataset(c)

        actual_counts = c.label_count_for_image(0)
        print(actual_counts)
        label_counts = d.load_label_counts()
        print(label_counts)

        assert_array_equal(label_counts[1], np.array([1]))
        assert_array_equal(label_counts[2], np.array([1]))
        assert_array_equal(label_counts[3], np.array([1]))
예제 #5
0
    def test_pixel_dimensions(self):

        img_path = os.path.abspath(
            os.path.join(base_path, '../test_data/tiffconnector_1/im/*'))
        c = io_connector(img_path, '', savepath=self.tmpdir)
        d = Dataset(c)

        size = (1, 5, 4)
        batch_size = 2

        p = PredictionBatch(d, batch_size, size)[0]

        print(p.pixels().shape)
        self.assertEqual((2, 3, 1, 5, 4), p.pixels().shape)

        p.set_pixel_dimension_order('bzxyc')
        self.assertEqual((2, 1, 5, 4, 3), p.pixels().shape)
예제 #6
0
파일: session.py 프로젝트: doshih/yapic
    def load_training_data(self, image_path, label_path):
        '''
        Connect to a training dataset.

        Parameters
        ----------
        image_path : string
            Path to folder with tiff images.
        label_path : string
            Path to folder with label tiff images or path to ilastik project
            file (.ilp file).
        '''

        print(image_path)
        print(label_path)

        self.dataset = Dataset(io_connector(image_path, label_path))
예제 #7
0
    def load_prediction_data(self, image_path, save_path, batch_size=None):
        '''
        Connect to a prediction dataset.

        Parameters
        ----------
        image_path : string
            Path to folder with tiff images to predict.
        save_path : string
            Path to folder for saving prediction images.
        '''

        self.dataset = Dataset(
            io_connector(image_path,
                         '/tmp/this_should_not_exist',
                         savepath=save_path))
        if batch_size is None:
            self.batch_size = 1
        else:
            self.batch_size = batch_size
        msg = '\n\nImport dataset for prediction:\n{}\n'.format(
            self.dataset.pixel_connector.__repr__())
        sys.stdout.write(msg)