From 62b0453123b069adcdf7f13ff1a9c86c41b9d138 Mon Sep 17 00:00:00 2001 From: Robert Kiewisz <56911280+RRobert92@users.noreply.github.com> Date: Thu, 9 May 2024 15:48:45 +0200 Subject: [PATCH] rollback edt as incompatible with conda --- conda-build/conda_build_config.yml | 5 +- conda-build/meta-v0.2.1.yaml | 1 - conda-build/meta.yaml | 1 - requirements.txt | 1 - .../dist_pytorch/utils/build_point_cloud.py | 84 +++++-------------- 5 files changed, 27 insertions(+), 65 deletions(-) diff --git a/conda-build/conda_build_config.yml b/conda-build/conda_build_config.yml index 81f530ed..49e29b15 100644 --- a/conda-build/conda_build_config.yml +++ b/conda-build/conda_build_config.yml @@ -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 @@ -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 diff --git a/conda-build/meta-v0.2.1.yaml b/conda-build/meta-v0.2.1.yaml index c89610ac..b74a212d 100644 --- a/conda-build/meta-v0.2.1.yaml +++ b/conda-build/meta-v0.2.1.yaml @@ -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 diff --git a/conda-build/meta.yaml b/conda-build/meta.yaml index e9898647..68df0aa9 100644 --- a/conda-build/meta.yaml +++ b/conda-build/meta.yaml @@ -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 diff --git a/requirements.txt b/requirements.txt index a60a884b..081d7193 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/tardis_em/dist_pytorch/utils/build_point_cloud.py b/tardis_em/dist_pytorch/utils/build_point_cloud.py index cb34ca4e..aed5f8b3 100644 --- a/tardis_em/dist_pytorch/utils/build_point_cloud.py +++ b/tardis_em/dist_pytorch/utils/build_point_cloud.py @@ -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: @@ -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