From 8521517b3b5e828ad53d1de0db084186d50ccb06 Mon Sep 17 00:00:00 2001 From: AssociatedPrimeIdeal Date: Thu, 30 Apr 2026 02:01:29 +0800 Subject: [PATCH] Move core modules into autoflow package --- .gitignore | 7 ++++--- algorithms.py => autoflow/algorithms.py | 2 +- autoflow/api.py | 4 ++-- app.py => autoflow/app.py | 12 ++++++------ editors.py => autoflow/editors.py | 2 +- autoflow/gui.py | 2 +- io_utils.py => autoflow/io_utils.py | 4 ++-- models.py => autoflow/models.py | 0 ortho_viewer.py => autoflow/ortho_viewer.py | 0 pipeline.py => autoflow/pipeline.py | 6 +++--- utils.py => autoflow/utils.py | 6 +++--- viewer.py => autoflow/viewer.py | 4 ++-- pyproject.toml | 14 -------------- 13 files changed, 25 insertions(+), 38 deletions(-) rename algorithms.py => autoflow/algorithms.py (99%) rename app.py => autoflow/app.py (99%) rename editors.py => autoflow/editors.py (99%) rename io_utils.py => autoflow/io_utils.py (88%) rename models.py => autoflow/models.py (100%) rename ortho_viewer.py => autoflow/ortho_viewer.py (100%) rename pipeline.py => autoflow/pipeline.py (99%) rename utils.py => autoflow/utils.py (99%) rename viewer.py => autoflow/viewer.py (99%) diff --git a/.gitignore b/.gitignore index 796dd8c..7041702 100755 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ __pycache__/ *.pyc *.pyo +/*.py .ipynb_checkpoints/ +*.ipynb +!library_demo.ipynb # Local data and generated outputs /111/ @@ -19,6 +22,4 @@ TODO.md app.png autoflow_mri.egg-info/ build/ -test.ipynb -utils_bgc.py -/scripts/ \ No newline at end of file +/scripts/ diff --git a/algorithms.py b/autoflow/algorithms.py similarity index 99% rename from algorithms.py rename to autoflow/algorithms.py index e861179..ff779d8 100755 --- a/algorithms.py +++ b/autoflow/algorithms.py @@ -9,7 +9,7 @@ from scipy.signal import savgol_filter from skimage.morphology import skeletonize -from models import PlaneData, GraphData, SkeletonParams +from .models import PlaneData, GraphData, SkeletonParams def _axis_pair(a): diff --git a/autoflow/api.py b/autoflow/api.py index 3bacb33..1e5d689 100755 --- a/autoflow/api.py +++ b/autoflow/api.py @@ -6,8 +6,8 @@ import numpy as np -from models import Workspace -from utils import collect_h5_files, process_single, resolve_reuse_plane_file +from .models import Workspace +from .utils import collect_h5_files, process_single, resolve_reuse_plane_file DEFAULT_WSS_BAR_CFG = { "position_x": 0.75, diff --git a/app.py b/autoflow/app.py similarity index 99% rename from app.py rename to autoflow/app.py index f7df325..ce03680 100755 --- a/app.py +++ b/autoflow/app.py @@ -11,12 +11,12 @@ from pyvistaqt import QtInteractor from pyvista import _vtk -from models import Workspace, StepId, ObjectKind -from pipeline import PipelineEngine -from viewer import SceneController -from editors import SkeletonEditor, PlaneEditor -from ortho_viewer import OrthoViewer -from algorithms import compute_plane_metrics, apply_internal_consistency_to_metrics, compute_plane_metrics_multithread +from .models import Workspace, StepId, ObjectKind +from .pipeline import PipelineEngine +from .viewer import SceneController +from .editors import SkeletonEditor, PlaneEditor +from .ortho_viewer import OrthoViewer +from .algorithms import compute_plane_metrics, apply_internal_consistency_to_metrics, compute_plane_metrics_multithread def _parse_plane_index(data_key): diff --git a/editors.py b/autoflow/editors.py similarity index 99% rename from editors.py rename to autoflow/editors.py index eff34e2..61a25c9 100755 --- a/editors.py +++ b/autoflow/editors.py @@ -1,5 +1,5 @@ import numpy as np -from models import PlaneData, GraphData +from .models import PlaneData, GraphData class SkeletonEditor: diff --git a/autoflow/gui.py b/autoflow/gui.py index 1b568ec..73839b1 100755 --- a/autoflow/gui.py +++ b/autoflow/gui.py @@ -6,7 +6,7 @@ def launch_gui() -> None: try: - from app import main as app_main + from .app import main as app_main except ModuleNotFoundError as exc: module_name = exc.name or "" base_name = module_name.split(".", 1)[0] diff --git a/io_utils.py b/autoflow/io_utils.py similarity index 88% rename from io_utils.py rename to autoflow/io_utils.py index fe904cc..889cdea 100755 --- a/io_utils.py +++ b/autoflow/io_utils.py @@ -1,5 +1,5 @@ import json -from models import Workspace +from .models import Workspace def save_workspace_file(path, workspace): @@ -12,4 +12,4 @@ def load_workspace_file(path): d = json.load(f) ws = Workspace() ws.restore_dict(d) - return ws \ No newline at end of file + return ws diff --git a/models.py b/autoflow/models.py similarity index 100% rename from models.py rename to autoflow/models.py diff --git a/ortho_viewer.py b/autoflow/ortho_viewer.py similarity index 100% rename from ortho_viewer.py rename to autoflow/ortho_viewer.py diff --git a/pipeline.py b/autoflow/pipeline.py similarity index 99% rename from pipeline.py rename to autoflow/pipeline.py index 01bc71d..4d6bc78 100755 --- a/pipeline.py +++ b/autoflow/pipeline.py @@ -2,8 +2,8 @@ import os import numpy as np -from models import StepId, ObjectKind -from algorithms import ( +from .models import StepId, ObjectKind +from .algorithms import ( load_h5_data, filter_segmask_labels, merge_segmask_to_3d, preprocess_mask_for_skeleton, @@ -124,7 +124,7 @@ def run_step(self, ws, step, log): def _step_generate_skeleton(self, ws): self.preprocess(ws) if ws.skeleton_params.remove_small_cc: - from algorithms import remove_small_cc_from_binary_mask + from .algorithms import remove_small_cc_from_binary_mask ws.segmask_binary = remove_small_cc_from_binary_mask( ws.segmask_binary, ws.resolution, ws.skeleton_params.min_cc_volume_mm3) ws.segmask_3d = merge_segmask_to_3d(ws.segmask_binary) diff --git a/utils.py b/autoflow/utils.py similarity index 99% rename from utils.py rename to autoflow/utils.py index d995e6d..d2f5990 100755 --- a/utils.py +++ b/autoflow/utils.py @@ -10,9 +10,9 @@ import imageio.v2 as imageio from PIL import Image -from models import Workspace, StepId, PlaneData -from pipeline import PipelineEngine -from algorithms import ( +from .models import Workspace, StepId, PlaneData +from .pipeline import PipelineEngine +from .algorithms import ( load_metrics_as_table, compute_derived_metrics, create_uniform_grid, diff --git a/viewer.py b/autoflow/viewer.py similarity index 99% rename from viewer.py rename to autoflow/viewer.py index cc8e53e..cfe1e4e 100755 --- a/viewer.py +++ b/autoflow/viewer.py @@ -1,8 +1,8 @@ import numpy as np import pyvista as pv -from models import ObjectKind -from algorithms import ( +from .models import ObjectKind +from .algorithms import ( build_multilabel_surface_t, build_surface_from_mask3d, graph_to_polydata, diff --git a/pyproject.toml b/pyproject.toml index 36e48f9..8a9ef2f 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,20 +34,6 @@ test = [ autoflow-run = "autoflow.cli:main" autoflow-gui = "autoflow.gui:main" -[tool.setuptools] -include-package-data = false -py-modules = [ - "algorithms", - "app", - "editors", - "io_utils", - "models", - "ortho_viewer", - "pipeline", - "utils", - "viewer", -] - [tool.setuptools.packages.find] include = ["autoflow"]