Skip to content

Commit

Permalink
Make random noise transform not in-place
Browse files Browse the repository at this point in the history
  • Loading branch information
fepegar committed Jan 7, 2020
1 parent 46d7a4d commit bf60d5d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions torchio/transforms/random_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def apply_transform(self, sample):
continue
if image_dict['type'] != INTENSITY:
continue
add_noise(image_dict['data'], std)
image_dict['data'] = add_noise(image_dict['data'], std)
return sample

@staticmethod
Expand All @@ -29,4 +29,5 @@ def get_params(std_range):

def add_noise(data, std):
noise = torch.FloatTensor(*data.shape).normal_(mean=0, std=std)
data += noise
data = data + noise
return data

0 comments on commit bf60d5d

Please sign in to comment.