From 8b59241520ceed88a04c3c04dbf84729026eb1a5 Mon Sep 17 00:00:00 2001 From: Nathan Hillyer Date: Sun, 20 Sep 2020 14:54:00 -0500 Subject: [PATCH] Fix 2D collage not running because of 3D z range clamping. --- docker/dev_environment/collageradiomics_examples/Dockerfile | 2 +- docker/dev_environment/collageradiomics_pip/Dockerfile | 2 +- module/VERSION | 2 +- module/collageradiomics.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/dev_environment/collageradiomics_examples/Dockerfile b/docker/dev_environment/collageradiomics_examples/Dockerfile index 67ae611..6f64c1d 100644 --- a/docker/dev_environment/collageradiomics_examples/Dockerfile +++ b/docker/dev_environment/collageradiomics_examples/Dockerfile @@ -2,7 +2,7 @@ FROM nathanhillyer/ml-base ENV LANG C.UTF-8 RUN PIP_INSTALL="python -m pip install --upgrade --no-cache-dir --retries 10 --timeout 60" && \ $PIP_INSTALL \ - collageradiomics==0.2.5 \ + collageradiomics==0.2.6 \ Pillow \ && \ ldconfig && \ diff --git a/docker/dev_environment/collageradiomics_pip/Dockerfile b/docker/dev_environment/collageradiomics_pip/Dockerfile index e32a0a4..ea2c7f8 100644 --- a/docker/dev_environment/collageradiomics_pip/Dockerfile +++ b/docker/dev_environment/collageradiomics_pip/Dockerfile @@ -2,7 +2,7 @@ FROM nathanhillyer/ubuntu-base ENV LANG C.UTF-8 RUN PIP_INSTALL="python -m pip install --upgrade --no-cache-dir --retries 10 --timeout 60" && \ $PIP_INSTALL \ - collageradiomics==0.2.5 \ + collageradiomics==0.2.6 \ && \ ldconfig && \ apt-get clean && \ diff --git a/module/VERSION b/module/VERSION index 28af839..a53741c 100644 --- a/module/VERSION +++ b/module/VERSION @@ -1 +1 @@ -0.2.5 \ No newline at end of file +0.2.6 \ No newline at end of file diff --git a/module/collageradiomics.py b/module/collageradiomics.py index c67bd3d..4cb7f34 100644 --- a/module/collageradiomics.py +++ b/module/collageradiomics.py @@ -368,7 +368,7 @@ def __init__(self, # in the case of a single 2D slice, give it a third dimension of unit length self._img_array = self._img_array.reshape(self._img_array.shape + (1,)) - min_3D_slices = 3; + min_3D_slices = 3 if self._img_array.shape[0] < self._haralick_window_size or self._img_array.shape[1] < self._haralick_window_size or (self._is_3D and self._img_array.shape[2] < min_3D_slices): raise Exception( f'Image is too small for a window size of {self._haralick_window_size} pixels.') @@ -487,8 +487,8 @@ def calculate_haralick_textures(self, dominant_angles): if self.verbose_logging: print('starting haralick calculations...') - # We extended the dominant angles by one slice in each direction, so now we need to trim those off. - for z in range(1, depth - 1): + # In 3D, we extended the dominant angles by one slice in each direction, so now we need to trim those off if we are running in 3D. + for z in range(1, depth - 1) if self.is_3D else range(depth): for y,x in product(range(height), range(width)): if self.mask_array[y,x,z]: haralick_image[y,x,z,:] = self.calculate_haralick_feature_values(dominant_angles_binned[:,:,z], x, y)