Skip to content

Commit

Permalink
Fix 2D collage not running because of 3D z range clamping.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhillyer committed Sep 20, 2020
1 parent f409a01 commit 8b59241
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
2 changes: 1 addition & 1 deletion docker/dev_environment/collageradiomics_pip/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
2 changes: 1 addition & 1 deletion module/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.5
0.2.6
6 changes: 3 additions & 3 deletions module/collageradiomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8b59241

Please sign in to comment.