phenome 1.4.1__tar.gz
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.
- phenome-1.4.1/LICENSE +21 -0
- phenome-1.4.1/PKG-INFO +165 -0
- phenome-1.4.1/README.md +95 -0
- phenome-1.4.1/phenome/__init__.py +180 -0
- phenome-1.4.1/phenome/_logging.py +99 -0
- phenome-1.4.1/phenome/core/__init__.py +107 -0
- phenome-1.4.1/phenome/core/_processing_pipeline_persist.py +112 -0
- phenome-1.4.1/phenome/core/batch_correction.py +384 -0
- phenome-1.4.1/phenome/core/dataframe_contract.py +175 -0
- phenome-1.4.1/phenome/core/math/__init__.py +38 -0
- phenome-1.4.1/phenome/core/math/combined_features.py +99 -0
- phenome-1.4.1/phenome/core/math/correlation.py +496 -0
- phenome-1.4.1/phenome/core/math/dimensionality_reduction.py +489 -0
- phenome-1.4.1/phenome/core/math/interpretability.py +361 -0
- phenome-1.4.1/phenome/core/pipeline_results.py +238 -0
- phenome-1.4.1/phenome/core/processing_pipeline.py +1679 -0
- phenome-1.4.1/phenome/core/property_utils.py +143 -0
- phenome-1.4.1/phenome/core/protocols.py +79 -0
- phenome-1.4.1/phenome/core/results_export.py +142 -0
- phenome-1.4.1/phenome/core/results_metadata.py +451 -0
- phenome-1.4.1/phenome/core/results_validation.py +49 -0
- phenome-1.4.1/phenome/core/run_log.py +227 -0
- phenome-1.4.1/phenome/io/__init__.py +50 -0
- phenome-1.4.1/phenome/io/_checkpoint_ops.py +523 -0
- phenome-1.4.1/phenome/io/_discovery_ops.py +106 -0
- phenome-1.4.1/phenome/io/_path_utils.py +42 -0
- phenome-1.4.1/phenome/io/batch_correction_ops.py +100 -0
- phenome-1.4.1/phenome/io/checkpoint.py +1878 -0
- phenome-1.4.1/phenome/io/checkpoint_alignment.py +502 -0
- phenome-1.4.1/phenome/io/discovery.py +629 -0
- phenome-1.4.1/phenome/mcp/__init__.py +5 -0
- phenome-1.4.1/phenome/mcp/docs_search.py +104 -0
- phenome-1.4.1/phenome/mcp/recipes.py +92 -0
- phenome-1.4.1/phenome/mcp/server.py +137 -0
- phenome-1.4.1/phenome/metadata/__init__.py +50 -0
- phenome-1.4.1/phenome/metadata/base.py +255 -0
- phenome-1.4.1/phenome/metadata/sources.py +247 -0
- phenome-1.4.1/phenome/mixins/__init__.py +79 -0
- phenome-1.4.1/phenome/mixins/_helpers.py +136 -0
- phenome-1.4.1/phenome/mixins/analysis.py +1885 -0
- phenome-1.4.1/phenome/mixins/batch_correction.py +357 -0
- phenome-1.4.1/phenome/mixins/dataset.py +219 -0
- phenome-1.4.1/phenome/mixins/distances.py +400 -0
- phenome-1.4.1/phenome/mixins/embedding_extractor.py +237 -0
- phenome-1.4.1/phenome/mixins/interactive/__init__.py +18 -0
- phenome-1.4.1/phenome/mixins/interactive/_html_components.py +333 -0
- phenome-1.4.1/phenome/mixins/interactive/_protocol.py +54 -0
- phenome-1.4.1/phenome/mixins/interactive/_utils.py +247 -0
- phenome-1.4.1/phenome/mixins/interactive/explorer.py +3500 -0
- phenome-1.4.1/phenome/mixins/properties/__init__.py +10 -0
- phenome-1.4.1/phenome/mixins/properties/_compute.py +1194 -0
- phenome-1.4.1/phenome/mixins/properties/_grouping_table.py +173 -0
- phenome-1.4.1/phenome/mixins/properties/_paths.py +270 -0
- phenome-1.4.1/phenome/mixins/properties/_report.py +157 -0
- phenome-1.4.1/phenome/mixins/properties/_workers.py +303 -0
- phenome-1.4.1/phenome/mixins/properties/grouping.py +516 -0
- phenome-1.4.1/phenome/mixins/properties/main.py +568 -0
- phenome-1.4.1/phenome/mixins/properties/matrix.py +383 -0
- phenome-1.4.1/phenome/mixins/visualization/__init__.py +10 -0
- phenome-1.4.1/phenome/mixins/visualization/_component_correlation_plots.py +254 -0
- phenome-1.4.1/phenome/mixins/visualization/_core.py +167 -0
- phenome-1.4.1/phenome/mixins/visualization/_distance_plots.py +278 -0
- phenome-1.4.1/phenome/mixins/visualization/_dr_plots.py +609 -0
- phenome-1.4.1/phenome/mixins/visualization/_group_enrichment_plots.py +271 -0
- phenome-1.4.1/phenome/mixins/visualization/_helpers.py +224 -0
- phenome-1.4.1/phenome/mixins/visualization/_image_display.py +568 -0
- phenome-1.4.1/phenome/mixins/visualization/_interpretability_plots.py +187 -0
- phenome-1.4.1/phenome/pipeline.py +2832 -0
- phenome-1.4.1/phenome/plotly_display.py +98 -0
- phenome-1.4.1/phenome/plugins/__init__.py +78 -0
- phenome-1.4.1/phenome/plugins/builtin_properties.py +174 -0
- phenome-1.4.1/phenome/plugins/registry.py +104 -0
- phenome-1.4.1/phenome/py.typed +0 -0
- phenome-1.4.1/phenome/report/__init__.py +63 -0
- phenome-1.4.1/phenome/report/_components.py +317 -0
- phenome-1.4.1/phenome/report/_section_helpers.py +127 -0
- phenome-1.4.1/phenome/report/context.py +53 -0
- phenome-1.4.1/phenome/report/generator.py +544 -0
- phenome-1.4.1/phenome/report/helpers.py +223 -0
- phenome-1.4.1/phenome/report/scripts.py +332 -0
- phenome-1.4.1/phenome/report/sections/__init__.py +38 -0
- phenome-1.4.1/phenome/report/sections/clustering.py +449 -0
- phenome-1.4.1/phenome/report/sections/correlation.py +75 -0
- phenome-1.4.1/phenome/report/sections/distance.py +159 -0
- phenome-1.4.1/phenome/report/sections/export.py +96 -0
- phenome-1.4.1/phenome/report/sections/gallery.py +232 -0
- phenome-1.4.1/phenome/report/sections/interpretability.py +125 -0
- phenome-1.4.1/phenome/report/sections/outlier.py +164 -0
- phenome-1.4.1/phenome/report/sections/overview.py +119 -0
- phenome-1.4.1/phenome/report/sections/property_stats.py +160 -0
- phenome-1.4.1/phenome/report/sections/run_settings.py +80 -0
- phenome-1.4.1/phenome/report/sections/visualization.py +121 -0
- phenome-1.4.1/phenome/report/styles.py +928 -0
- phenome-1.4.1/phenome/utils/__init__.py +119 -0
- phenome-1.4.1/phenome/utils/device.py +63 -0
- phenome-1.4.1/phenome/utils/display_names.py +65 -0
- phenome-1.4.1/phenome/utils/metadata.py +206 -0
- phenome-1.4.1/phenome/utils/model_wrapper.py +211 -0
- phenome-1.4.1/phenome/utils/path_utils.py +170 -0
- phenome-1.4.1/phenome/utils/progress.py +35 -0
- phenome-1.4.1/phenome/utils/property_factories.py +671 -0
- phenome-1.4.1/phenome/utils/transforms.py +319 -0
- phenome-1.4.1/phenome.egg-info/PKG-INFO +165 -0
- phenome-1.4.1/phenome.egg-info/SOURCES.txt +110 -0
- phenome-1.4.1/phenome.egg-info/dependency_links.txt +1 -0
- phenome-1.4.1/phenome.egg-info/entry_points.txt +2 -0
- phenome-1.4.1/phenome.egg-info/requires.txt +45 -0
- phenome-1.4.1/phenome.egg-info/top_level.txt +1 -0
- phenome-1.4.1/pyproject.toml +272 -0
- phenome-1.4.1/setup.cfg +4 -0
- phenome-1.4.1/tests/test_core_smoke.py +129 -0
- phenome-1.4.1/tests/test_dependency_compat.py +53 -0
phenome-1.4.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aitor González-Marfil
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
phenome-1.4.1/PKG-INFO
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: phenome
|
|
3
|
+
Version: 1.4.1
|
|
4
|
+
Summary: PhenoMe: dataset-agnostic phenotyping pipeline using deep learning embeddings
|
|
5
|
+
Author: Aitor González-Marfil
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/AAitorG/PhenoMe
|
|
8
|
+
Project-URL: Repository, https://github.com/AAitorG/PhenoMe
|
|
9
|
+
Project-URL: Documentation, https://AAitorG.github.io/PhenoMe/
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/AAitorG/PhenoMe/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/AAitorG/PhenoMe/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: phenotyping,bioimaging,computer vision,deep learning,embeddings,microscopy,cell biology,image analysis,pytorch,drug discovery
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Natural Language :: English
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.12
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: torch>=2.0.0
|
|
30
|
+
Requires-Dist: torchvision>=0.15.0
|
|
31
|
+
Requires-Dist: numpy>=1.24
|
|
32
|
+
Requires-Dist: pandas
|
|
33
|
+
Requires-Dist: matplotlib>=3.7
|
|
34
|
+
Requires-Dist: plotly
|
|
35
|
+
Requires-Dist: kaleido
|
|
36
|
+
Requires-Dist: scikit-learn
|
|
37
|
+
Requires-Dist: joblib
|
|
38
|
+
Requires-Dist: tqdm
|
|
39
|
+
Requires-Dist: opencv-python
|
|
40
|
+
Requires-Dist: tifffile
|
|
41
|
+
Requires-Dist: h5py
|
|
42
|
+
Requires-Dist: scipy
|
|
43
|
+
Requires-Dist: scikit-image>=0.26.0
|
|
44
|
+
Requires-Dist: ipywidgets
|
|
45
|
+
Requires-Dist: anywidget
|
|
46
|
+
Requires-Dist: pillow
|
|
47
|
+
Requires-Dist: umap-learn==0.5.12
|
|
48
|
+
Requires-Dist: nibabel<6,>=5.2.0
|
|
49
|
+
Requires-Dist: dcor==0.7
|
|
50
|
+
Requires-Dist: ipykernel>=6.29
|
|
51
|
+
Requires-Dist: jupyterlab>=4.0
|
|
52
|
+
Requires-Dist: jupyterlab_widgets>=3.0
|
|
53
|
+
Requires-Dist: nbformat>=5.9
|
|
54
|
+
Provides-Extra: full
|
|
55
|
+
Requires-Dist: pykeops==2.3; sys_platform != "win32" and extra == "full"
|
|
56
|
+
Requires-Dist: torchdr<0.6,>=0.1; extra == "full"
|
|
57
|
+
Provides-Extra: mcp
|
|
58
|
+
Requires-Dist: mcp>=2.0; extra == "mcp"
|
|
59
|
+
Provides-Extra: dev
|
|
60
|
+
Requires-Dist: codespell>=2.4; extra == "dev"
|
|
61
|
+
Requires-Dist: interrogate>=1.7.0; extra == "dev"
|
|
62
|
+
Requires-Dist: mypy>=1.19.1; extra == "dev"
|
|
63
|
+
Requires-Dist: pandas-stubs; extra == "dev"
|
|
64
|
+
Requires-Dist: pre-commit>=3.7; extra == "dev"
|
|
65
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
66
|
+
Requires-Dist: ruff>=0.15.4; extra == "dev"
|
|
67
|
+
Requires-Dist: types-requests; extra == "dev"
|
|
68
|
+
Requires-Dist: types-setuptools; extra == "dev"
|
|
69
|
+
Dynamic: license-file
|
|
70
|
+
|
|
71
|
+
<div align="center">
|
|
72
|
+
<img src="docs/assets/logo.png" alt="PhenoMe logo" width="360"/>
|
|
73
|
+
|
|
74
|
+
<p>A modular, <b>dataset-agnostic</b> and <b>model-agnostic</b> framework for phenotyping analysis, combining deep learning embeddings and image properties.</p>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### 🗺️ Navigation
|
|
80
|
+
|
|
81
|
+
**[✨ Features](#-features)** | **[🚀 Quick Start](#-quick-start)** | **[📦 Installation](#-installation)** | **[📖 Documentation](https://AAitorG.github.io/PhenoMe/)** | **[📜 Citation](#-citation)**
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## ✨ Features
|
|
86
|
+
|
|
87
|
+
- 🧠 **Model Agnostic**: Extract embeddings using DINOv2 or any custom vision model (PyTorch, TensorFlow, Keras, etc.) via the modular `ModelWrapper` interface.
|
|
88
|
+
- 📂 **Dataset Agnostic**: Works with any image dataset structure with customizable metadata extraction.
|
|
89
|
+
- 🛠️ **Analysis Toolkit**: Distance quantification, anomaly detection, property extraction, and correlation analysis.
|
|
90
|
+
- 📊 **Interactive Visualizations**: High-performance Plotly-based PCA, t-SNE, and UMAP plots.
|
|
91
|
+
- 📑 **Automated Reporting**: Generate comprehensive standalone HTML reports.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 🚀 Quick Start
|
|
96
|
+
|
|
97
|
+
Try the no-code experience with the **[Interactive Quickstart Notebook](Notebooks/tutorials/01_interactive_quickstart.ipynb)** or launch instantly in Colab:
|
|
98
|
+
|
|
99
|
+
[](https://colab.research.google.com/github/AAitorG/PhenoMe/blob/main/Notebooks/tutorials/01_interactive_quickstart.ipynb)
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 📦 Installation
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pip install phenome
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
PyTorch is included. An NVIDIA GPU is used when CUDA is available; the same install runs on CPU.
|
|
110
|
+
|
|
111
|
+
<details>
|
|
112
|
+
<summary><b>Conda or from source</b></summary>
|
|
113
|
+
|
|
114
|
+
Clone the repository, then create one environment for your hardware. These files pin the scientific stack and install this checkout.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
git clone https://github.com/AAitorG/PhenoMe.git
|
|
118
|
+
cd PhenoMe
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**GPU**
|
|
122
|
+
```bash
|
|
123
|
+
conda env create -f envs/environment-gpu.yml
|
|
124
|
+
conda activate phenome-gpu
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**CPU**
|
|
128
|
+
```bash
|
|
129
|
+
conda env create -f envs/environment-cpu.yml
|
|
130
|
+
conda activate phenome-cpu
|
|
131
|
+
```
|
|
132
|
+
</details>
|
|
133
|
+
|
|
134
|
+
> **💡 Full instructions, verification, and troubleshooting:**
|
|
135
|
+
> See the [Getting started](https://AAitorG.github.io/PhenoMe/getting-started/) guide for install details, verification commands, and first-analysis walkthroughs.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 📖 Documentation
|
|
140
|
+
|
|
141
|
+
**Explore the [Full Documentation](https://AAitorG.github.io/PhenoMe/)** for detailed guides, API references, and tutorials.
|
|
142
|
+
|
|
143
|
+
| Step | Resource |
|
|
144
|
+
| ---- | -------- |
|
|
145
|
+
| 1️⃣ **Install** | [Getting started](https://AAitorG.github.io/PhenoMe/getting-started/) |
|
|
146
|
+
| 2️⃣ **Set up your data** | [Data setup](https://AAitorG.github.io/PhenoMe/guides/data-setup/) · [Experiment details](https://AAitorG.github.io/PhenoMe/guides/experiment-details/) |
|
|
147
|
+
| 3️⃣ **Tutorials** | [Notebooks/tutorials/](Notebooks/tutorials/) |
|
|
148
|
+
| 4️⃣ **Examples** | [Notebooks/examples/](Notebooks/examples/) |
|
|
149
|
+
|
|
150
|
+
**Learn More:** [Core concepts](https://AAitorG.github.io/PhenoMe/concepts/) · [Workflows](https://AAitorG.github.io/PhenoMe/workflows/) · [FAQ](https://AAitorG.github.io/PhenoMe/faq/) · [Glossary](https://AAitorG.github.io/PhenoMe/glossary/)
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 📜 Citation
|
|
155
|
+
|
|
156
|
+
If you use PhenoMe in your research, please cite:
|
|
157
|
+
|
|
158
|
+
```bibtex
|
|
159
|
+
@software{phenome,
|
|
160
|
+
author = {Aitor González-Marfil},
|
|
161
|
+
title = {PhenoMe: Interactive AI framework for image representation analysis},
|
|
162
|
+
year = {2026},
|
|
163
|
+
url = {https://github.com/AAitorG/PhenoMe}
|
|
164
|
+
}
|
|
165
|
+
```
|
phenome-1.4.1/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="docs/assets/logo.png" alt="PhenoMe logo" width="360"/>
|
|
3
|
+
|
|
4
|
+
<p>A modular, <b>dataset-agnostic</b> and <b>model-agnostic</b> framework for phenotyping analysis, combining deep learning embeddings and image properties.</p>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
### 🗺️ Navigation
|
|
10
|
+
|
|
11
|
+
**[✨ Features](#-features)** | **[🚀 Quick Start](#-quick-start)** | **[📦 Installation](#-installation)** | **[📖 Documentation](https://AAitorG.github.io/PhenoMe/)** | **[📜 Citation](#-citation)**
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## ✨ Features
|
|
16
|
+
|
|
17
|
+
- 🧠 **Model Agnostic**: Extract embeddings using DINOv2 or any custom vision model (PyTorch, TensorFlow, Keras, etc.) via the modular `ModelWrapper` interface.
|
|
18
|
+
- 📂 **Dataset Agnostic**: Works with any image dataset structure with customizable metadata extraction.
|
|
19
|
+
- 🛠️ **Analysis Toolkit**: Distance quantification, anomaly detection, property extraction, and correlation analysis.
|
|
20
|
+
- 📊 **Interactive Visualizations**: High-performance Plotly-based PCA, t-SNE, and UMAP plots.
|
|
21
|
+
- 📑 **Automated Reporting**: Generate comprehensive standalone HTML reports.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 🚀 Quick Start
|
|
26
|
+
|
|
27
|
+
Try the no-code experience with the **[Interactive Quickstart Notebook](Notebooks/tutorials/01_interactive_quickstart.ipynb)** or launch instantly in Colab:
|
|
28
|
+
|
|
29
|
+
[](https://colab.research.google.com/github/AAitorG/PhenoMe/blob/main/Notebooks/tutorials/01_interactive_quickstart.ipynb)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 📦 Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install phenome
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
PyTorch is included. An NVIDIA GPU is used when CUDA is available; the same install runs on CPU.
|
|
40
|
+
|
|
41
|
+
<details>
|
|
42
|
+
<summary><b>Conda or from source</b></summary>
|
|
43
|
+
|
|
44
|
+
Clone the repository, then create one environment for your hardware. These files pin the scientific stack and install this checkout.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/AAitorG/PhenoMe.git
|
|
48
|
+
cd PhenoMe
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**GPU**
|
|
52
|
+
```bash
|
|
53
|
+
conda env create -f envs/environment-gpu.yml
|
|
54
|
+
conda activate phenome-gpu
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**CPU**
|
|
58
|
+
```bash
|
|
59
|
+
conda env create -f envs/environment-cpu.yml
|
|
60
|
+
conda activate phenome-cpu
|
|
61
|
+
```
|
|
62
|
+
</details>
|
|
63
|
+
|
|
64
|
+
> **💡 Full instructions, verification, and troubleshooting:**
|
|
65
|
+
> See the [Getting started](https://AAitorG.github.io/PhenoMe/getting-started/) guide for install details, verification commands, and first-analysis walkthroughs.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 📖 Documentation
|
|
70
|
+
|
|
71
|
+
**Explore the [Full Documentation](https://AAitorG.github.io/PhenoMe/)** for detailed guides, API references, and tutorials.
|
|
72
|
+
|
|
73
|
+
| Step | Resource |
|
|
74
|
+
| ---- | -------- |
|
|
75
|
+
| 1️⃣ **Install** | [Getting started](https://AAitorG.github.io/PhenoMe/getting-started/) |
|
|
76
|
+
| 2️⃣ **Set up your data** | [Data setup](https://AAitorG.github.io/PhenoMe/guides/data-setup/) · [Experiment details](https://AAitorG.github.io/PhenoMe/guides/experiment-details/) |
|
|
77
|
+
| 3️⃣ **Tutorials** | [Notebooks/tutorials/](Notebooks/tutorials/) |
|
|
78
|
+
| 4️⃣ **Examples** | [Notebooks/examples/](Notebooks/examples/) |
|
|
79
|
+
|
|
80
|
+
**Learn More:** [Core concepts](https://AAitorG.github.io/PhenoMe/concepts/) · [Workflows](https://AAitorG.github.io/PhenoMe/workflows/) · [FAQ](https://AAitorG.github.io/PhenoMe/faq/) · [Glossary](https://AAitorG.github.io/PhenoMe/glossary/)
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 📜 Citation
|
|
85
|
+
|
|
86
|
+
If you use PhenoMe in your research, please cite:
|
|
87
|
+
|
|
88
|
+
```bibtex
|
|
89
|
+
@software{phenome,
|
|
90
|
+
author = {Aitor González-Marfil},
|
|
91
|
+
title = {PhenoMe: Interactive AI framework for image representation analysis},
|
|
92
|
+
year = {2026},
|
|
93
|
+
url = {https://github.com/AAitorG/PhenoMe}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@section Core Pipeline
|
|
3
|
+
|
|
4
|
+
PhenoMe Package
|
|
5
|
+
|
|
6
|
+
A modular, **dataset-agnostic** and **model-agnostic** pipeline for phenotyping
|
|
7
|
+
analysis using deep learning embeddings.
|
|
8
|
+
|
|
9
|
+
**Overview:**
|
|
10
|
+
PhenoMe orchestrates the full phenotyping workflow: discover images, extract embeddings
|
|
11
|
+
with custom or pretrained models, compute cell/object properties, perform statistical
|
|
12
|
+
analysis, and generate interactive visualizations and reports.
|
|
13
|
+
|
|
14
|
+
**Public API:**
|
|
15
|
+
|
|
16
|
+
Core orchestration:
|
|
17
|
+
- `PhenoMe`: Main pipeline class; find images, process embeddings, compute properties, analyze.
|
|
18
|
+
- `PhenoMeResults`: Container for embeddings, properties, metadata, and analysis results.
|
|
19
|
+
|
|
20
|
+
Metadata helpers:
|
|
21
|
+
- `DefaultMetadata`: Simple key-value metadata.
|
|
22
|
+
- `PathTemplateMetadata`: Extract metadata from file paths using templates.
|
|
23
|
+
- `DataFrameMetadata`: Use a DataFrame as metadata source.
|
|
24
|
+
- `default_metadata_from_path`, `get_metadata_from_path`, `make_dataframe_metadata_fn`:
|
|
25
|
+
Metadata factory functions.
|
|
26
|
+
|
|
27
|
+
Model loading:
|
|
28
|
+
- `load_dinov2_model`: Load pretrained DINOv2 model.
|
|
29
|
+
|
|
30
|
+
Property factories (create custom cell/object properties):
|
|
31
|
+
- `create_regionprops_function`, `create_intensity_function`,
|
|
32
|
+
`create_masked_intensity_function`, `create_texture_function`,
|
|
33
|
+
`create_concentric_ring_function`, `create_blur_effect_function`,
|
|
34
|
+
`create_entropy_function`: Built-in property creators.
|
|
35
|
+
- `get_preset_property_functions`: List all available preset properties.
|
|
36
|
+
|
|
37
|
+
**Data flow:**
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
find_files()
|
|
41
|
+
↓ returns DataFrame of image paths
|
|
42
|
+
set_file_df() or directly via DataFrame
|
|
43
|
+
↓ store file locations
|
|
44
|
+
process_images(model)
|
|
45
|
+
↓ extract embeddings, populate results.embeddings
|
|
46
|
+
compute_properties(property_functions)
|
|
47
|
+
↓ compute morphological/biological features
|
|
48
|
+
compute_clustering() / detect_outliers() / ...
|
|
49
|
+
↓ statistical analysis
|
|
50
|
+
plot_pca() / plot_tsne() / plot_umap() / ...
|
|
51
|
+
↓ visualization
|
|
52
|
+
generate_report()
|
|
53
|
+
↓ HTML report
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Model compatibility:**
|
|
57
|
+
- **DINOv2:** Use `load_dinov2_model()` or wrap with `DinoV2ModelWrapper`.
|
|
58
|
+
- **Custom:** Subclass `ModelWrapper`, implement `_get_embeddings(images) -> (B, D)`.
|
|
59
|
+
|
|
60
|
+
**For advanced usage, import from submodules:**
|
|
61
|
+
- `phenome.core`: Math utilities (DR, correlation, validation, export).
|
|
62
|
+
- `phenome.io`: File I/O (`read_image`, `FileDiscovery`, `CheckpointManager`).
|
|
63
|
+
- `phenome.mixins`: Composition classes (dataset, properties, analysis, visualization).
|
|
64
|
+
- `phenome.plugins`: Property registry and custom property registration.
|
|
65
|
+
- `phenome.report`: HTML report generation.
|
|
66
|
+
- `phenome.utils`: Device management, transforms, metadata and property factories.
|
|
67
|
+
|
|
68
|
+
**Logging:**
|
|
69
|
+
|
|
70
|
+
Progress messages are visible at INFO level by default:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import logging
|
|
74
|
+
logging.getLogger("phenome").setLevel(logging.WARNING) # Suppress
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Example:**
|
|
78
|
+
|
|
79
|
+
Basic phenotyping workflow:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from phenome import PhenoMe, load_dinov2_model
|
|
83
|
+
|
|
84
|
+
# Initialize pipeline
|
|
85
|
+
pm = PhenoMe(device="cuda", seed=42)
|
|
86
|
+
|
|
87
|
+
# Find images
|
|
88
|
+
pm.find_files("path/to/images/")
|
|
89
|
+
|
|
90
|
+
# Extract embeddings
|
|
91
|
+
model = load_dinov2_model(model_name="dinov2_vitb14")
|
|
92
|
+
pm.process_images(model, batch_size=32)
|
|
93
|
+
|
|
94
|
+
# Compute properties
|
|
95
|
+
pm.compute_properties(property_preset="basic")
|
|
96
|
+
|
|
97
|
+
# Analyze
|
|
98
|
+
pm.compute_clustering(method="kmeans", n_clusters=5)
|
|
99
|
+
pm.compute_pca()
|
|
100
|
+
|
|
101
|
+
# Visualize
|
|
102
|
+
pm.plot_pca(color_by="clustering")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**See Also:**
|
|
106
|
+
For architecture, design patterns, and extensibility, see the [Architecture guide](https://AAitorG.github.io/PhenoMe/guides/architecture/).
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
# Initialise notebook-safe logging on first import
|
|
110
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
111
|
+
|
|
112
|
+
from ._logging import get_logger as _get_logger
|
|
113
|
+
from .core import PhenoMeResults
|
|
114
|
+
from .metadata import (
|
|
115
|
+
DataFrameMetadata,
|
|
116
|
+
DefaultMetadata,
|
|
117
|
+
MetadataBase,
|
|
118
|
+
PathTemplateMetadata,
|
|
119
|
+
)
|
|
120
|
+
from .pipeline import PhenoMe
|
|
121
|
+
from .plotly_display import register_plotly_display_defaults
|
|
122
|
+
|
|
123
|
+
# Metadata functions and classes
|
|
124
|
+
from .utils.metadata import (
|
|
125
|
+
default_metadata_from_path,
|
|
126
|
+
get_metadata_from_path,
|
|
127
|
+
make_dataframe_metadata_fn,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
# Core workflow helpers
|
|
131
|
+
from .utils.model_wrapper import load_dinov2_model
|
|
132
|
+
|
|
133
|
+
# Property factories
|
|
134
|
+
from .utils.property_factories import (
|
|
135
|
+
create_blur_effect_function,
|
|
136
|
+
create_concentric_ring_function,
|
|
137
|
+
create_entropy_function,
|
|
138
|
+
create_intensity_function,
|
|
139
|
+
create_masked_intensity_function,
|
|
140
|
+
create_regionprops_function,
|
|
141
|
+
create_texture_function,
|
|
142
|
+
get_preset_property_functions,
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
try:
|
|
146
|
+
__version__ = version("phenome")
|
|
147
|
+
except PackageNotFoundError:
|
|
148
|
+
__version__ = "1.4.1"
|
|
149
|
+
|
|
150
|
+
__all__ = [
|
|
151
|
+
"DataFrameMetadata",
|
|
152
|
+
"DefaultMetadata",
|
|
153
|
+
"MetadataBase",
|
|
154
|
+
"PathTemplateMetadata",
|
|
155
|
+
"PhenoMe",
|
|
156
|
+
"PhenoMeResults",
|
|
157
|
+
"__version__",
|
|
158
|
+
# Property factories
|
|
159
|
+
"create_blur_effect_function",
|
|
160
|
+
"create_concentric_ring_function",
|
|
161
|
+
"create_entropy_function",
|
|
162
|
+
"create_intensity_function",
|
|
163
|
+
"create_masked_intensity_function",
|
|
164
|
+
"create_regionprops_function",
|
|
165
|
+
"create_texture_function",
|
|
166
|
+
# Metadata functions
|
|
167
|
+
"default_metadata_from_path",
|
|
168
|
+
"get_metadata_from_path",
|
|
169
|
+
# Property factories
|
|
170
|
+
"get_preset_property_functions",
|
|
171
|
+
# Default models
|
|
172
|
+
"load_dinov2_model",
|
|
173
|
+
"make_dataframe_metadata_fn",
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
_get_logger(__name__)
|
|
177
|
+
__author__ = "Aitor González-Marfil"
|
|
178
|
+
__author_github__ = "AAitorG"
|
|
179
|
+
|
|
180
|
+
register_plotly_display_defaults()
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Notebook-safe logging configuration for phenome.
|
|
3
|
+
|
|
4
|
+
Problem
|
|
5
|
+
-------
|
|
6
|
+
The standard ``logging.getLogger(__name__)`` pattern silently drops INFO
|
|
7
|
+
messages in Jupyter notebooks because Python's root logger defaults to
|
|
8
|
+
WARNING level and has no handler attached. If the user manually adds a
|
|
9
|
+
handler, duplicate output appears on every cell re-run.
|
|
10
|
+
|
|
11
|
+
Solution
|
|
12
|
+
--------
|
|
13
|
+
We configure a single package-level logger (``phenome``) with:
|
|
14
|
+
|
|
15
|
+
* A ``StreamHandler`` writing to ``sys.stderr`` (rendered by Jupyter as
|
|
16
|
+
plain text below the cell).
|
|
17
|
+
* INFO as default level, so progress messages are always visible.
|
|
18
|
+
* A guard that prevents adding duplicate handlers on module reload
|
|
19
|
+
(``%autoreload`` / repeated imports).
|
|
20
|
+
|
|
21
|
+
All sub-modules should call::
|
|
22
|
+
|
|
23
|
+
from ._logging import get_logger
|
|
24
|
+
logger = get_logger(__name__)
|
|
25
|
+
|
|
26
|
+
instead of ``logging.getLogger(__name__)``.
|
|
27
|
+
|
|
28
|
+
Users who want to silence the output can do::
|
|
29
|
+
|
|
30
|
+
import logging
|
|
31
|
+
logging.getLogger("phenome").setLevel(logging.WARNING)
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
import logging
|
|
35
|
+
import sys
|
|
36
|
+
|
|
37
|
+
# Package-level logger name
|
|
38
|
+
_PKG_LOGGER_NAME = "phenome"
|
|
39
|
+
|
|
40
|
+
# Sentinel attribute on the package logger so we configure at most once.
|
|
41
|
+
_CONFIGURED_ATTR = "_phenome_configured"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def get_logger(name: str) -> logging.Logger:
|
|
45
|
+
"""Return a logger configured for notebook-safe output.
|
|
46
|
+
|
|
47
|
+
Typical usage at the top of each module::
|
|
48
|
+
|
|
49
|
+
from ._logging import get_logger
|
|
50
|
+
logger = get_logger(__name__)
|
|
51
|
+
|
|
52
|
+
Parameters
|
|
53
|
+
----------
|
|
54
|
+
name : str
|
|
55
|
+
Usually ``__name__`` of the calling module.
|
|
56
|
+
"""
|
|
57
|
+
_ensure_configured()
|
|
58
|
+
return logging.getLogger(name)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _ensure_configured() -> None:
|
|
62
|
+
"""Attach a StreamHandler to the package logger if not done already."""
|
|
63
|
+
pkg_logger = logging.getLogger(_PKG_LOGGER_NAME)
|
|
64
|
+
|
|
65
|
+
if getattr(pkg_logger, _CONFIGURED_ATTR, False):
|
|
66
|
+
return
|
|
67
|
+
|
|
68
|
+
# Library best-practice: add NullHandler so that if the user never
|
|
69
|
+
# configures logging at all, nothing breaks.
|
|
70
|
+
pkg_logger.addHandler(logging.NullHandler())
|
|
71
|
+
|
|
72
|
+
# Only add our StreamHandler if the package logger (or its parents)
|
|
73
|
+
# have no *effective* handlers yet. This avoids fighting with a
|
|
74
|
+
# user who already configured logging before importing us.
|
|
75
|
+
if not _has_effective_handler(pkg_logger):
|
|
76
|
+
handler = logging.StreamHandler(sys.stderr)
|
|
77
|
+
handler.setFormatter(logging.Formatter("%(message)s"))
|
|
78
|
+
pkg_logger.addHandler(handler)
|
|
79
|
+
|
|
80
|
+
# Set INFO as the default level for the package tree.
|
|
81
|
+
# Only override if the logger is still at NOTSET (i.e. the user hasn't
|
|
82
|
+
# explicitly set a level).
|
|
83
|
+
if pkg_logger.level == logging.NOTSET:
|
|
84
|
+
pkg_logger.setLevel(logging.INFO)
|
|
85
|
+
|
|
86
|
+
setattr(pkg_logger, _CONFIGURED_ATTR, True)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _has_effective_handler(logger: logging.Logger) -> bool:
|
|
90
|
+
"""Check if *logger* or any ancestor already has a non-NullHandler."""
|
|
91
|
+
current: logging.Logger | None = logger
|
|
92
|
+
while current:
|
|
93
|
+
for h in current.handlers:
|
|
94
|
+
if not isinstance(h, logging.NullHandler):
|
|
95
|
+
return True
|
|
96
|
+
if not current.propagate:
|
|
97
|
+
break
|
|
98
|
+
current = current.parent
|
|
99
|
+
return False
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@section Core Pipeline
|
|
3
|
+
|
|
4
|
+
Core utilities for math, validation, export, and results management.
|
|
5
|
+
|
|
6
|
+
This package provides the mathematical algorithms and data structures that underpin
|
|
7
|
+
the phenotyping pipeline. Key components:
|
|
8
|
+
|
|
9
|
+
**Results container:**
|
|
10
|
+
- `PhenoMeResults`: Typed container for embeddings, properties, metadata, and analysis results.
|
|
11
|
+
|
|
12
|
+
**Mathematical functions:**
|
|
13
|
+
- `run_dimensionality_reduction`: PCA, t-SNE, UMAP.
|
|
14
|
+
- `compute_pearson_correlation`, `compute_spearman_correlation`: Feature correlations.
|
|
15
|
+
- `compute_distance_correlation`: Distance correlation between features.
|
|
16
|
+
- `compute_mutual_info`: Mutual information between features.
|
|
17
|
+
- `compute_entropy`: Entropy of features.
|
|
18
|
+
- `build_combined_features`: Combine multiple features into single representation.
|
|
19
|
+
|
|
20
|
+
**Validation and export:**
|
|
21
|
+
- `validate_results`: Check results integrity (embeddings, properties, shapes).
|
|
22
|
+
- `build_export_dataframe`: Format results for export to CSV/Excel.
|
|
23
|
+
- `prepare_embedding_dataframe`: Prepare embeddings with metadata for analysis.
|
|
24
|
+
|
|
25
|
+
**Metadata handling:**
|
|
26
|
+
- `build_metadata_columns`: Extract and format metadata columns.
|
|
27
|
+
- `filter_indices`: Select rows by metadata criteria.
|
|
28
|
+
- `get_metadata_value`: Retrieve metadata value for a row.
|
|
29
|
+
- `get_all_metadata_keys`: List all available metadata keys.
|
|
30
|
+
- `metadata_to_stable_key`: Convert metadata to file-safe string.
|
|
31
|
+
|
|
32
|
+
**Protocols:**
|
|
33
|
+
- `PhenoMeProtocol`: Protocol (duck-type interface) for objects implementing the phenotyping API.
|
|
34
|
+
|
|
35
|
+
**See Also:**
|
|
36
|
+
For top-level analysis pipeline, see `phenome.PhenoMe`.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
from .dataframe_contract import (
|
|
40
|
+
IMAGE_INDEX,
|
|
41
|
+
IMAGE_NAME,
|
|
42
|
+
IMAGE_PATH,
|
|
43
|
+
TIER_A_EXCLUDE_FROM_PROPERTIES,
|
|
44
|
+
append_property_columns,
|
|
45
|
+
is_per_image_df,
|
|
46
|
+
per_image_dataframe,
|
|
47
|
+
reorder_tier_a_columns,
|
|
48
|
+
)
|
|
49
|
+
from .math import (
|
|
50
|
+
build_combined_features,
|
|
51
|
+
clean_correlation_inputs,
|
|
52
|
+
compute_distance_correlation,
|
|
53
|
+
compute_entropy,
|
|
54
|
+
compute_lasso_interpretability,
|
|
55
|
+
compute_mutual_info,
|
|
56
|
+
compute_pearson_correlation,
|
|
57
|
+
compute_rf_interpretability,
|
|
58
|
+
compute_spearman_correlation,
|
|
59
|
+
run_dimensionality_reduction,
|
|
60
|
+
run_dimensionality_reduction_matrix,
|
|
61
|
+
)
|
|
62
|
+
from .pipeline_results import PhenoMeResults
|
|
63
|
+
from .property_utils import metadata_to_stable_key, optimize_property_types
|
|
64
|
+
from .protocols import PhenoMeProtocol
|
|
65
|
+
from .results_export import build_export_dataframe, prepare_embedding_dataframe
|
|
66
|
+
from .results_metadata import (
|
|
67
|
+
build_metadata_columns,
|
|
68
|
+
filter_indices,
|
|
69
|
+
get_all_metadata_keys,
|
|
70
|
+
get_metadata_value,
|
|
71
|
+
get_metadata_value_from_dict,
|
|
72
|
+
)
|
|
73
|
+
from .results_validation import validate_results
|
|
74
|
+
|
|
75
|
+
__all__ = [
|
|
76
|
+
"IMAGE_INDEX",
|
|
77
|
+
"IMAGE_NAME",
|
|
78
|
+
"IMAGE_PATH",
|
|
79
|
+
"TIER_A_EXCLUDE_FROM_PROPERTIES",
|
|
80
|
+
"PhenoMeProtocol",
|
|
81
|
+
"PhenoMeResults",
|
|
82
|
+
"append_property_columns",
|
|
83
|
+
"build_combined_features",
|
|
84
|
+
"build_export_dataframe",
|
|
85
|
+
"build_metadata_columns",
|
|
86
|
+
"clean_correlation_inputs",
|
|
87
|
+
"compute_distance_correlation",
|
|
88
|
+
"compute_entropy",
|
|
89
|
+
"compute_lasso_interpretability",
|
|
90
|
+
"compute_mutual_info",
|
|
91
|
+
"compute_pearson_correlation",
|
|
92
|
+
"compute_rf_interpretability",
|
|
93
|
+
"compute_spearman_correlation",
|
|
94
|
+
"filter_indices",
|
|
95
|
+
"get_all_metadata_keys",
|
|
96
|
+
"get_metadata_value",
|
|
97
|
+
"get_metadata_value_from_dict",
|
|
98
|
+
"is_per_image_df",
|
|
99
|
+
"metadata_to_stable_key",
|
|
100
|
+
"optimize_property_types",
|
|
101
|
+
"per_image_dataframe",
|
|
102
|
+
"prepare_embedding_dataframe",
|
|
103
|
+
"reorder_tier_a_columns",
|
|
104
|
+
"run_dimensionality_reduction",
|
|
105
|
+
"run_dimensionality_reduction_matrix",
|
|
106
|
+
"validate_results",
|
|
107
|
+
]
|