napari-tmidas 0.2.2__py3-none-any.whl → 0.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. napari_tmidas/__init__.py +35 -5
  2. napari_tmidas/_crop_anything.py +1520 -609
  3. napari_tmidas/_env_manager.py +76 -0
  4. napari_tmidas/_file_conversion.py +1646 -1131
  5. napari_tmidas/_file_selector.py +1455 -216
  6. napari_tmidas/_label_inspection.py +83 -8
  7. napari_tmidas/_processing_worker.py +309 -0
  8. napari_tmidas/_reader.py +6 -10
  9. napari_tmidas/_registry.py +2 -2
  10. napari_tmidas/_roi_colocalization.py +1221 -84
  11. napari_tmidas/_tests/test_crop_anything.py +123 -0
  12. napari_tmidas/_tests/test_env_manager.py +89 -0
  13. napari_tmidas/_tests/test_grid_view_overlay.py +193 -0
  14. napari_tmidas/_tests/test_init.py +98 -0
  15. napari_tmidas/_tests/test_intensity_label_filter.py +222 -0
  16. napari_tmidas/_tests/test_label_inspection.py +86 -0
  17. napari_tmidas/_tests/test_processing_basic.py +500 -0
  18. napari_tmidas/_tests/test_processing_worker.py +142 -0
  19. napari_tmidas/_tests/test_regionprops_analysis.py +547 -0
  20. napari_tmidas/_tests/test_registry.py +70 -2
  21. napari_tmidas/_tests/test_scipy_filters.py +168 -0
  22. napari_tmidas/_tests/test_skimage_filters.py +259 -0
  23. napari_tmidas/_tests/test_split_channels.py +217 -0
  24. napari_tmidas/_tests/test_spotiflow.py +87 -0
  25. napari_tmidas/_tests/test_tyx_display_fix.py +142 -0
  26. napari_tmidas/_tests/test_ui_utils.py +68 -0
  27. napari_tmidas/_tests/test_widget.py +30 -0
  28. napari_tmidas/_tests/test_windows_basic.py +66 -0
  29. napari_tmidas/_ui_utils.py +57 -0
  30. napari_tmidas/_version.py +16 -3
  31. napari_tmidas/_widget.py +41 -4
  32. napari_tmidas/processing_functions/basic.py +557 -20
  33. napari_tmidas/processing_functions/careamics_env_manager.py +72 -99
  34. napari_tmidas/processing_functions/cellpose_env_manager.py +415 -112
  35. napari_tmidas/processing_functions/cellpose_segmentation.py +132 -191
  36. napari_tmidas/processing_functions/colocalization.py +513 -56
  37. napari_tmidas/processing_functions/grid_view_overlay.py +703 -0
  38. napari_tmidas/processing_functions/intensity_label_filter.py +422 -0
  39. napari_tmidas/processing_functions/regionprops_analysis.py +1280 -0
  40. napari_tmidas/processing_functions/sam2_env_manager.py +53 -69
  41. napari_tmidas/processing_functions/sam2_mp4.py +274 -195
  42. napari_tmidas/processing_functions/scipy_filters.py +403 -8
  43. napari_tmidas/processing_functions/skimage_filters.py +424 -212
  44. napari_tmidas/processing_functions/spotiflow_detection.py +949 -0
  45. napari_tmidas/processing_functions/spotiflow_env_manager.py +591 -0
  46. napari_tmidas/processing_functions/timepoint_merger.py +334 -86
  47. {napari_tmidas-0.2.2.dist-info → napari_tmidas-0.2.5.dist-info}/METADATA +71 -30
  48. napari_tmidas-0.2.5.dist-info/RECORD +63 -0
  49. napari_tmidas/_tests/__init__.py +0 -0
  50. napari_tmidas-0.2.2.dist-info/RECORD +0 -40
  51. {napari_tmidas-0.2.2.dist-info → napari_tmidas-0.2.5.dist-info}/WHEEL +0 -0
  52. {napari_tmidas-0.2.2.dist-info → napari_tmidas-0.2.5.dist-info}/entry_points.txt +0 -0
  53. {napari_tmidas-0.2.2.dist-info → napari_tmidas-0.2.5.dist-info}/licenses/LICENSE +0 -0
  54. {napari_tmidas-0.2.2.dist-info → napari_tmidas-0.2.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,76 @@
1
+ """
2
+ Base environment manager for handling virtual environments.
3
+ """
4
+
5
+ import os
6
+ import platform
7
+ import shutil
8
+ import subprocess
9
+ import venv
10
+ from abc import ABC, abstractmethod
11
+
12
+
13
+ class BaseEnvironmentManager(ABC):
14
+ """Base class for managing virtual environments for different packages."""
15
+
16
+ def __init__(self, env_name: str):
17
+ self.env_name = env_name
18
+ self.env_dir = os.path.join(
19
+ os.path.expanduser("~"), ".napari-tmidas", "envs", env_name
20
+ )
21
+
22
+ def is_env_created(self) -> bool:
23
+ """Check if the dedicated environment exists."""
24
+ env_python = self.get_env_python_path()
25
+ return os.path.exists(env_python)
26
+
27
+ def get_env_python_path(self) -> str:
28
+ """Get the path to the Python executable in the environment."""
29
+ if platform.system() == "Windows":
30
+ return os.path.join(self.env_dir, "Scripts", "python.exe")
31
+ else:
32
+ return os.path.join(self.env_dir, "bin", "python")
33
+
34
+ def create_env(self) -> str:
35
+ """Create a dedicated virtual environment."""
36
+ # Ensure the environment directory exists
37
+ os.makedirs(os.path.dirname(self.env_dir), exist_ok=True)
38
+
39
+ # Remove existing environment if it exists
40
+ if os.path.exists(self.env_dir):
41
+ shutil.rmtree(self.env_dir)
42
+
43
+ print(f"Creating {self.env_name} environment at {self.env_dir}...")
44
+
45
+ # Create a new virtual environment
46
+ venv.create(self.env_dir, with_pip=True)
47
+
48
+ # Path to the Python executable in the new environment
49
+ env_python = self.get_env_python_path()
50
+
51
+ # Upgrade pip
52
+ print("Upgrading pip...")
53
+ subprocess.check_call(
54
+ [env_python, "-m", "pip", "install", "--upgrade", "pip"]
55
+ )
56
+
57
+ # Install package-specific dependencies
58
+ self._install_dependencies(env_python)
59
+
60
+ print(f"{self.env_name} environment created successfully.")
61
+ return env_python
62
+
63
+ @abstractmethod
64
+ def _install_dependencies(self, env_python: str) -> None:
65
+ """Install package-specific dependencies."""
66
+
67
+ @abstractmethod
68
+ def is_package_installed(self) -> bool:
69
+ """Check if the package is installed."""
70
+
71
+ def run_in_env(
72
+ self, command: str, **kwargs
73
+ ) -> subprocess.CompletedProcess:
74
+ """Run a command in the environment."""
75
+ env_python = self.get_env_python_path()
76
+ return subprocess.run([env_python, "-c", command], **kwargs)