Skip to content

Commit

Permalink
add copy of patch otherwise, the original image and label will be cha…
Browse files Browse the repository at this point in the history
…nged by transformation
  • Loading branch information
xiuliren committed May 7, 2021
1 parent 9bf7b6c commit c9d1872
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions neutorch/dataset/ground_truth_volume.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from abc import ABC, abstractmethod
import random
from typing import Union
from copy import deepcopy

import numpy as np
from scipy.ndimage.measurements import label
Expand Down Expand Up @@ -94,8 +95,10 @@ def patch_from_center(self, center: tuple):
by : by + self.patch_size[-2],
bx : bx + self.patch_size[-1]
]
image_patch = self._expand_to_5d(image_patch)
label_patch = self._expand_to_5d(label_patch)
# if we do not copy here, the augmentation will change our
# image and label volume!
image_patch = self._expand_to_5d(image_patch).copy()
label_patch = self._expand_to_5d(label_patch).copy()
return Patch(image_patch, label_patch)

@property
Expand Down

0 comments on commit c9d1872

Please sign in to comment.