:param mode: 'train','val','test' :param dataset_path: root dataset folder :param crop_dim: subvolume tuple :param fold_id: 1 to 10 values :param samples: number of sub-volumes that you want to create
(self, args, mode, dataset_path='./datasets', crop_dim=(32, 32, 32), split_id=1, samples=1000,
load=False)
| 17 | """ |
| 18 | |
| 19 | def __init__(self, args, mode, dataset_path='./datasets', crop_dim=(32, 32, 32), split_id=1, samples=1000, |
| 20 | load=False): |
| 21 | """ |
| 22 | :param mode: 'train','val','test' |
| 23 | :param dataset_path: root dataset folder |
| 24 | :param crop_dim: subvolume tuple |
| 25 | :param fold_id: 1 to 10 values |
| 26 | :param samples: number of sub-volumes that you want to create |
| 27 | """ |
| 28 | self.mode = mode |
| 29 | self.root = str(dataset_path) |
| 30 | self.training_path = self.root + '/iseg_2017/iSeg-2017-Training/' |
| 31 | self.testing_path = self.root + '/iseg_2017/iSeg-2017-Testing/' |
| 32 | self.CLASSES = 4 |
| 33 | self.full_vol_dim = (144, 192, 256) # slice, width, height |
| 34 | self.threshold = args.threshold |
| 35 | self.normalization = args.normalization |
| 36 | self.augmentation = args.augmentation |
| 37 | self.crop_size = crop_dim |
| 38 | self.list = [] |
| 39 | self.samples = samples |
| 40 | self.full_volume = None |
| 41 | self.save_name = self.root + '/iseg_2017/iSeg-2017-Training/iseg2017-list-' + mode + '-samples-' + str( |
| 42 | samples) + '.txt' |
| 43 | if self.augmentation: |
| 44 | self.transform = augment3D.RandomChoice( |
| 45 | transforms=[augment3D.GaussianNoise(mean=0, std=0.01), augment3D.RandomFlip(), |
| 46 | augment3D.ElasticTransform()], p=0.5) |
| 47 | if load: |
| 48 | ## load pre-generated data |
| 49 | self.list = utils.load_list(self.save_name) |
| 50 | list_IDsT1 = sorted(glob.glob(os.path.join(self.training_path, '*T1.img'))) |
| 51 | self.affine = img_loader.load_affine_matrix(list_IDsT1[0]) |
| 52 | return |
| 53 | |
| 54 | subvol = '_vol_' + str(crop_dim[0]) + 'x' + str(crop_dim[1]) + 'x' + str(crop_dim[2]) |
| 55 | self.sub_vol_path = self.root + '/iseg_2017/generated/' + mode + subvol + '/' |
| 56 | |
| 57 | utils.make_dirs(self.sub_vol_path) |
| 58 | list_IDsT1 = sorted(glob.glob(os.path.join(self.training_path, '*T1.img'))) |
| 59 | list_IDsT2 = sorted(glob.glob(os.path.join(self.training_path, '*T2.img'))) |
| 60 | labels = sorted(glob.glob(os.path.join(self.training_path, '*label.img'))) |
| 61 | self.affine = img_loader.load_affine_matrix(list_IDsT1[0]) |
| 62 | |
| 63 | if self.mode == 'train': |
| 64 | |
| 65 | list_IDsT1 = list_IDsT1[:split_id] |
| 66 | list_IDsT2 = list_IDsT2[:split_id] |
| 67 | labels = labels[:split_id] |
| 68 | |
| 69 | self.list = create_sub_volumes(list_IDsT1, list_IDsT2, labels, dataset_name="iseg2017", |
| 70 | mode=mode, samples=samples, full_vol_dim=self.full_vol_dim, |
| 71 | crop_size=self.crop_size, |
| 72 | sub_vol_path=self.sub_vol_path, th_percent=self.threshold, |
| 73 | normalization=args.normalization) |
| 74 | |
| 75 | |
| 76 | elif self.mode == 'val': |
nothing calls this directly
no test coverage detected