예제 #1
0
    def _attemptOpenAsKlb(self, filePath):
        if not os.path.splitext(filePath)[1].lower() == '.klb':
            return ([], None)

        opReader = OpKlbReader(parent=self)
        opReader.FilePath.setValue(filePath)
        return [opReader, opReader.Output]
예제 #2
0
    def testBasic(self):
        tmpdir = tempfile.mkdtemp()
        try:
            filepath = tmpdir + '/random_data.klb'
            shape = (1, 1, 30, 40, 50)
            data_tczyx = np.indices(shape).sum(0).astype(np.uint8)
            pyklb.writefull(data_tczyx,
                            filepath,
                            blocksize_xyzct=np.array([10, 10, 10, 1, 1],
                                                     dtype=np.uint32))
            readback = pyklb.readroi(filepath, (0, 0, 0, 0, 0),
                                     np.array(shape) - 1)

            op = OpKlbReader(graph=Graph())
            op.FilePath.setValue(filepath)

            assert op.Output.meta.shape == shape
            assert op.Output.meta.dtype == np.uint8

            read_data = op.Output[:].wait()
            assert (read_data == data_tczyx).all()

        finally:
            shutil.rmtree(tmpdir)