Exemplo n.º 1
0
    def __init__(self,
                 data_root_path,
                 folder,
                 crop_size=None,
                 trf_op=None,
                 Dataset_name="test"):
        self.Dataset_name = Dataset_name
        self.trf_op = trf_op
        self.crop_size = crop_size
        self.fix_list = [
            RandomCrop(self.crop_size),
            Normalize(),
            Any2One(),
            ToTensor()
        ]

        if Dataset_name is "train":
            self.image_paths = [
                findFiles(data_root_path + "/{}/{}/*.IMA".format(x, y))
                for x in folder["patients"] for y in folder["SliceThickness"]
            ]
            self.image_paths = [x for j in self.image_paths for x in j]
        else:
            self.image_paths = findFiles("{}/{}/{}/*.IMA".format(
                data_root_path, folder["patients"], folder["SliceThickness"]))
Exemplo n.º 2
0
    def __getitem__(self, idx):
        full_image, quarter_image = self.imgset[idx]

        if self.patch_size != 64:
            crop_point = [0, 0]
        else:
            crop_point = np.random.randint(
                512, size=2)  ## Random interception patch

        fix_list = [
            Scale2Gen(scale_type="image"),
            Normalize(normalize_type="image"),
            RandomCrop(self.patch_size, crop_point),
            ToTensor()
        ]
        transf = self.Cal_transform(self.Dataset_name, self.pre_trans_img,
                                    fix_list)

        full_image = self.preProcess(full_image,
                                     transf,
                                     patch_size=self.patch_size)
        quarter_image = self.preProcess(quarter_image,
                                        transf,
                                        patch_size=self.patch_size)

        sample = {
            "full_image": full_image.unsqueeze_(0),
            "quarter_image": quarter_image.unsqueeze_(0)
        }
        return sample