Example #1
0
 def intensity(self, x):
     transform = tio.OneOf([
         tio.RandomMotion(translation=1),
         tio.RandomBlur(),
         tio.RandomGamma(),
         tio.RandomSpike(intensity=[0.2, 0.5]),
         tio.RandomBiasField()
     ])
     x = transform(x.unsqueeze(0)).squeeze(0)
     return x
Example #2
0
    def __init__(self, X, Y, mixup=0, aug=False):

        self.X = X.astype('float32')
        self.Y = Y.astype('float32')
        self.aug = aug
        if self.aug:
            self.intensity = [
                tio.RandomMotion(translation=1),
                tio.RandomBlur(),
                tio.RandomGamma(),
                tio.RandomSpike(intensity=[0.2, 0.5]),
                tio.RandomBiasField()
            ]
        else:
            self.intensity = None
        self.mixup = mixup
Example #3
0
 def train_transform(self):
     # tf_list = [iotf.CropOrPad(self.volume_size, padding_mode='edge')]
     tf_list = []
     if self.randomflip['enable']:
         params = {
             key: val
             for key, val in self.randomflip.items() if key != 'enable'
         }
         tf_list.append(iotf.RandomFlip(**params))
     if self.randomaffine['enable']:
         params = {
             key: val
             for key, val in self.randomaffine.items() if key != 'enable'
         }
         tf_list.append(iotf.RandomAffine(**params))
     if self.randomblur['enable']:
         params = {
             key: val
             for key, val in self.randomblur.items() if key != 'enable'
         }
         tf_list.append(iotf.RandomBlur(**params))
     if self.randomnoise['enable']:
         params = {
             key: val
             for key, val in self.randomnoise.items() if key != 'enable'
         }
         tf_list.append(iotf.RandomNoise(**params))
     if self.randomswap['enable']:
         params = {
             key: val
             for key, val in self.randomswap.items() if key != 'enable'
         }
         tf_list.append(iotf.RandomSwap(**params))
     if self.randomelasticdeformation['enable']:
         params = {
             key: val
             for key, val in self.randomelasticdeformation.items()
             if key != 'enable'
         }
         tf_list.append(iotf.RandomElasticDeformation(**params))
     transform = iotf.Compose(tf_list)
     return transform