Esempio n. 1
0
    def load(self, fnames, shape, dtype, stackUnits=[1., 1., 1.]):
        if fnames:

            if len(fnames) == 0:
                raise Exception("filelist %s seems to be empty" % fnames)

            try:

                if shape is None or dtype is None:
                    shape, dtype, ok = ShapeDtypeDialog.get_properties()
                    if not ok:
                        return None

                data = np.fromfile(fnames[0], dtype=dtype)

                print(data.shape)
                if len(shape) < 3:
                    shape = (1, ) * (len(shape) - 4) + shape

                self.dtype = dtype
                self.data = data.reshape(shape)
                self.stackSize = (len(fnames), ) + shape[1:]

            except Exception as e:
                print(e)
                raise Exception("couldnt open %s as RawData" % fnames[0])
                return None

            self.stackUnits = stackUnits
Esempio n. 2
0
    def load(self, fnames, shape, dtype, stackUnits=[1., 1., 1.]):
        if fnames:

            if len(fnames) == 0:
                raise Exception("filelist %s seems to be empty" % fnames)

            try:

                if shape is None or dtype is None:
                    shape, dtype, ok = ShapeDtypeDialog.get_properties()
                    if not ok:
                        return None

                data = np.fromfile(fnames[0], dtype=dtype)

                print(data.shape)
                if len(shape) < 3:
                    shape = (1,) * (len(shape) - 4) + shape

                self.dtype = dtype
                self.data = data.reshape(shape)
                self.stackSize = (len(fnames),) + shape[1:]

            except Exception as e:
                print(e)
                raise Exception("couldnt open %s as RawData" % fnames[0])
                return None

            self.stackUnits = stackUnits
Esempio n. 3
0
    def load(self,
             fname,
             shape=None,
             dtype=np.uint16,
             stackUnits=[1., 1., 1.]):
        if fname:
            try:
                print(shape, dtype)
                if shape is None or dtype is None:
                    shape, dtype, ok = ShapeDtypeDialog.get_properties()
                    if not ok:
                        return None

                data = np.fromfile(fname, dtype=dtype)

                if len(shape) < 4:
                    shape = (1, ) * (len(shape) - 4) + shape
                elif len(shape) > 4:
                    raise ValueError("shape should have length of 4!")

                self.data = data.reshape(shape)
                self.stackSize = shape

            except Exception as e:
                print(e)
                self.fName = ""
                raise Exception("couldnt open %s as RawData" % fname)
                return None

            self.stackUnits = stackUnits
            self.fName = fname
Esempio n. 4
0
    def load(self, fname, shape=None, dtype=np.uint16, stackUnits=[1., 1., 1.]):
        if fname:
            try:
                print(shape, dtype)
                if shape is None or dtype is None:
                    shape, dtype, ok = ShapeDtypeDialog.get_properties()
                    if not ok:
                        return None

                data = np.fromfile(fname, dtype=dtype)

                if len(shape) < 4:
                    shape = (1,) * (len(shape) - 4) + shape
                elif len(shape)>4:
                    raise ValueError("shape should have length of 4!")

                self.data = data.reshape(shape)
                self.stackSize = shape

            except Exception as e:
                print(e)
                self.fName = ""
                raise Exception("couldnt open %s as RawData" % fname)
                return None

            self.stackUnits = stackUnits
            self.fName = fname