From 29720dd02961b5819534f62f8e78c27114855078 Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Mon, 21 Feb 2022 12:34:47 +0800 Subject: [PATCH] calculate min/max foreground Signed-off-by: Yiheng Wang --- monai/data/dataset_summary.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monai/data/dataset_summary.py b/monai/data/dataset_summary.py index 956e038569..b447585d3e 100644 --- a/monai/data/dataset_summary.py +++ b/monai/data/dataset_summary.py @@ -140,10 +140,10 @@ def calculate_statistics(self, foreground_threshold: int = 0): image, *_ = convert_data_type(data=image, output_type=torch.Tensor) label, *_ = convert_data_type(data=label, output_type=torch.Tensor) - voxel_max.append(image.max().item()) - voxel_min.append(image.min().item()) - image_foreground = image[torch.where(label > foreground_threshold)] + + voxel_max.append(image_foreground.max().item()) + voxel_min.append(image_foreground.min().item()) voxel_ct += len(image_foreground) voxel_sum += image_foreground.sum() voxel_square_sum += torch.square(image_foreground).sum()