Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

BUG: Fix missing channels dimension in normalization #701

Merged
merged 11 commits into from
Jun 13, 2022
Next Next commit
Fix missing channels dimension in normalization
  • Loading branch information
fepegar committed Mar 21, 2022
commit 53e27ac90c3948fb4a7324dd62d66f8c94dfdbfe
7 changes: 7 additions & 0 deletions InnerEye/ML/photometric_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def transform(self, image: Union[np.ndarray, torch.Tensor],
else:
mask = np.ones_like(image)

is3d = image.ndim == 3
fepegar marked this conversation as resolved.
Show resolved Hide resolved
if is3d:
image = image[np.newaxis]

self.status_of_most_recent_call = None
if self.norm_method == PhotometricNormalizationMethod.Unchanged:
image_out = image
Expand Down Expand Up @@ -117,6 +121,9 @@ def transform(self, image: Union[np.ndarray, torch.Tensor],
logging.debug(f"Photonorm patient {patient_id}: {self.status_of_most_recent_call}")
check_array_range(image_out, error_prefix="Normalized image")

if is3d:
image_out = image_out[0]

return image_out


Expand Down