Beispiel #1
0
    def test_put_probmap_data_dimorder_zxyc(self):

        img_path = os.path.join(
            base_path, '../test_data/ilastik/dimensionstest/images/*')
        label_path = os.path.join(
            base_path,
            '../test_data/ilastik/dimensionstest/x15_y10_z2_c4_classes2.ilp')

        with tempfile.TemporaryDirectory() as tmpdirname:
            c = TiffConnector(img_path, 'some/path', savepath=tmpdirname)
            d = Dataset(c)

            size = (2, 3, 5)  # zxy
            batch_size = 1

            # shape: 1 batch, 4 channels, 2 z, 3 x, 5 y

            p = PredictionBatch(d, batch_size, size)
            self.assertEqual((1, 4, 2, 3, 5), p[0].pixels().shape)
            self.assertEqual((1, 4, 2, 3, 5), p[1].pixels().shape)

            p.set_pixel_dimension_order('bzxyc')

            self.assertEqual((1, 2, 3, 5, 4), p[0].pixels().shape)
            self.assertEqual((1, 2, 3, 5, 4), p[1].pixels().shape)

            pixels = p[0].pixels()

            for tile in p:
                tile.put_probmap_data(pixels)
Beispiel #2
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)