def SaveToNpys(self, dir):
     countWrappers = len(self.imgDataWrappers)
     digitWrapperCount = len(str(countWrappers - 1))
     dirImg = os.path.join(dir, "arrImgs")
     dirMask = os.path.join(dir, "masks")
     CommonUtil.Mkdir(dirImg)
     CommonUtil.Mkdir(dirMask)
     for i in range(countWrappers):
         wrapper = self.imgDataWrappers[i]
         arrImgs = wrapper.arrImgs
         masks = wrapper.masks
         fn = str(i).zfill(digitWrapperCount) + ".npy"
         pathImg = os.path.join(dirImg, fn)
         pathMask = os.path.join(dirMask, fn)
         np.save(pathImg, arrImgs)
         np.save(pathMask, masks)
    def __SaveToNPYs(self, dirWrapper, imgs, masks):
        self.pathsImg = []
        self.pathsMasks = []

        suffix = ".npy"
        dirData = os.path.join(dirWrapper, "data")
        dirMasks = os.path.join(dirWrapper, "masks")
        CommonUtil.Mkdir(dirData)
        CommonUtil.Mkdir(dirMasks)
        slices = imgs.shape[-1]
        digitCount = len(str(slices))
        for i in range(slices):
            filename = str(i).zfill(digitCount) + suffix
            pathImg = os.path.join(dirData, filename)
            pathMask = os.path.join(dirMasks, filename)
            np.save(pathImg, imgs[..., i])
            self.pathsImg += [pathImg]
            np.save(pathMask, masks[..., i])
            self.pathsMasks += [pathMask]