Skip to content

Commit

Permalink
rollback edt as incompatible with conda
Browse files Browse the repository at this point in the history
  • Loading branch information
RRobert92 committed May 9, 2024
1 parent f0a3993 commit 62b0453
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 65 deletions.
5 changes: 4 additions & 1 deletion conda-build/conda_build_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ python:
- 3.9
- 3.10
- 3.11
channels:
- open3d-admin
- defaults
- conda-forge
dependencies:
- python>=3.8
- pytorch>=1.12.0
Expand All @@ -14,7 +18,6 @@ dependencies:
- scikit-learn>1.0.1
- scikit-image>0.19.2
- scipy>=1.8.1
- edt>=2.3.0
- pillow>10.0.0
- open3d>=0.9.0
- requests>2.28.0
Expand Down
1 change: 0 additions & 1 deletion conda-build/meta-v0.2.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ requirements:
- scikit-learn>1.0.1
- scikit-image>0.19.2
- scipy>=1.8.1
- edt>=2.3.0
- pillow>10.0.0
- open3d>=0.9.0
- requests>2.28.0
Expand Down
1 change: 0 additions & 1 deletion conda-build/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ requirements:
- scikit-learn>1.0.1
- scikit-image>0.19.2
- scipy>=1.8.1
- edt>=2.3.0
- pillow>10.0.0
- open3d>=0.9.0
- requests>2.28.0
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ imagecodecs>2021.11.00
scikit-learn>1.0.1
scikit-image>0.19.2
scipy>=1.8.1
edt>=2.3.0
pillow>10.0.0

# External file format reader
Expand Down
84 changes: 23 additions & 61 deletions tardis_em/dist_pytorch/utils/build_point_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

from tardis_em.dist_pytorch.utils.utils import VoxelDownSampling
from tardis_em.utils.errors import TardisError
from tardis_em.dist_pytorch.utils.utils import pc_median_dist
from copy import deepcopy


class BuildPointCloud:
Expand Down Expand Up @@ -129,67 +127,31 @@ def build_point_cloud(

return e, e

if EDT:
import edt
"""Skeletonization"""
if image.ndim == 2:
image_point = skeletonize(image)
elif as_2d:
image_point = np.zeros(image.shape, dtype=np.uint8)

"""Calculate EDT and apply threshold based on predefine mask size"""
if image.ndim == 2:
image_edt = edt.edt(image)
image_edt = np.where(image_edt > mask_size, 1, 0)
else:
image_edt = np.zeros(image.shape, dtype=np.uint8)

if as_2d:
for i in range(image_edt.shape[0]):
df_edt = edt.edt(image[i, :])

image_edt[i, :] = np.where(df_edt > mask_size, 1, 0)
else:
image_edt = edt.edt(image)
image_edt = np.where(image_edt > mask_size, 1, 0)

image_edt = image_edt.astype(np.uint8)

"""Skeletonization"""
if image.ndim == 2:
image_point = skeletonize(image_edt)
elif as_2d:
image_point = np.zeros(image_edt.shape, dtype=np.uint8)

for i in range(image_point.shape[0]):
image_point[i, :] = np.where(skeletonize(image_edt[i, :]), 1, 0)
else:
image_point = skeletonize_3d(image_edt)
image_point = np.where(image_point > 0)

"""CleanUp to avoid memory loss"""
del image, image_edt
else:
"""Skeletonization"""
if image.ndim == 2:
image_point = skeletonize(image)
elif as_2d:
image_point = np.zeros(image.shape, dtype=np.uint8)

for i in range(image_point.shape[0]):
image_point[i, :] = np.where(skeletonize(image[i, :]), 1, 0)
else:
image_point = skeletonize_3d(image)
image_point = np.where(image_point > 0)

"""CleanUp to avoid memory loss"""
del image

"""Output point cloud [X x Y x Z]"""
if len(image_point) == 2:
"""If 2D bring artificially Z dim == 0"""
coordinates_HD = np.stack(
(image_point[1], image_point[0], np.zeros(image_point[0].shape))
).T
for i in range(image_point.shape[0]):
image_point[i, :] = np.where(skeletonize(image[i, :]), 1, 0)
else:
coordinates_HD = np.stack(
(image_point[2], image_point[1], image_point[0])
).T
image_point = skeletonize_3d(image)
image_point = np.where(image_point > 0)

"""CleanUp to avoid memory loss"""
del image

"""Output point cloud [X x Y x Z]"""
if len(image_point) == 2:
"""If 2D bring artificially Z dim == 0"""
coordinates_HD = np.stack(
(image_point[1], image_point[0], np.zeros(image_point[0].shape))
).T
else:
coordinates_HD = np.stack(
(image_point[2], image_point[1], image_point[0])
).T

"""CleanUp to avoid memory loss"""
del image_point
Expand Down

0 comments on commit 62b0453

Please sign in to comment.