From c9d18721612550af1086e6c74cf92c3e52d924e6 Mon Sep 17 00:00:00 2001 From: jingpengw Date: Fri, 7 May 2021 11:24:09 -0400 Subject: [PATCH] add copy of patch otherwise, the original image and label will be changed by transformation --- neutorch/dataset/ground_truth_volume.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/neutorch/dataset/ground_truth_volume.py b/neutorch/dataset/ground_truth_volume.py index b680915..e4e72b3 100644 --- a/neutorch/dataset/ground_truth_volume.py +++ b/neutorch/dataset/ground_truth_volume.py @@ -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 @@ -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