Rhapso 0.1.92__py3-none-any.whl → 0.1.93__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.
@@ -0,0 +1,404 @@
1
+ Metadata-Version: 2.4
2
+ Name: Rhapso
3
+ Version: 0.1.93
4
+ Summary: A python package for aligning and stitching light sheet fluorescence microscopy images together
5
+ Author: ND
6
+ Author-email: sean.fite@alleninstitute.org
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Natural Language :: English
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.7
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: pandas
20
+ Requires-Dist: dask[array]==2024.12.1
21
+ Requires-Dist: zarr==2.18.3
22
+ Requires-Dist: scipy==1.13.1
23
+ Requires-Dist: scikit-image
24
+ Requires-Dist: bioio==1.3.0
25
+ Requires-Dist: bioio-tifffile==1.0.0
26
+ Requires-Dist: tifffile==2025.1.10
27
+ Requires-Dist: dask-image==2024.5.3
28
+ Requires-Dist: boto3==1.35.92
29
+ Requires-Dist: numcodecs==0.13.1
30
+ Requires-Dist: matplotlib==3.10.0
31
+ Requires-Dist: memory-profiler==0.61.0
32
+ Requires-Dist: s3fs==2024.12.0
33
+ Requires-Dist: scikit-learn
34
+ Dynamic: author
35
+ Dynamic: author-email
36
+ Dynamic: classifier
37
+ Dynamic: description
38
+ Dynamic: description-content-type
39
+ Dynamic: license-file
40
+ Dynamic: requires-dist
41
+ Dynamic: requires-python
42
+ Dynamic: summary
43
+
44
+ # Rhapso
45
+
46
+ **Rhapso** is a modular Python toolkit for interest point based registration, alignment, and fusing of large-scale microscopy datasets.
47
+
48
+ [![License](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
49
+ [![Python Version](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3110/)
50
+ [![Documentation](https://img.shields.io/badge/docs-wiki-blue)](https://github.com/AllenNeuralDynamics/Rhapso/wiki)
51
+
52
+ <!-- ## Example Usage Media Content Coming Soon....
53
+ -- -->
54
+
55
+ <br>
56
+
57
+ ## Table of Contents
58
+ - [Summary](#summary)
59
+ - [Contact](#contact)
60
+ - [Features](#features)
61
+ - [Performance](#performance)
62
+ - [Layout](#layout)
63
+ - [Installation](#installation)
64
+ - [Ray](#ray)
65
+ - [Run Locally w/ Ray](#run-locally-with-ray)
66
+ - [Run on AWS Cluster w/ Ray](#run-on-aws-cluster-with-ray)
67
+ - [Access Ray Dashboard](#access-ray-dashboard)
68
+ - [Parameters](#parameters)
69
+ - [Tuning Guide](#tuning-guide)
70
+ - [Build Package](#build-package)
71
+ - [Using the Built `.whl` File](#using-the-built-whl-file)
72
+
73
+ ---
74
+
75
+ <br>
76
+
77
+ **Update 11/26/25**
78
+ --------
79
+ Rhapso is still loading... and while we wrap up development, a couple things to know if you are outside the Allen Institute:
80
+ - This process requires a very specific XML structure to work.
81
+ - Fusion/Mutliscale is included but still under testing and development
82
+
83
+ <br>
84
+
85
+ ## Summary
86
+ Rhapso is a set of Python components for registration, alignment, and stitching of large-scale, 3D, overlapping tile-based, multiscale microscopy datasets.
87
+
88
+ Rhapso was developed by the Allen Institute for Neural Dynamics. Rhapso is comprised of stateless components. You can call these components using a pipeline script, with the option to run on a single machine or scale out with Ray to cloud based (currently only supporting AWS) clusters.
89
+
90
+ Current data loaders support Zarr and Tiff.
91
+
92
+ <br>
93
+
94
+ ## Contact
95
+ Questions or want to contribute? Please open an issue..
96
+
97
+ <br>
98
+
99
+ ## Features
100
+ - **Interest Point Detection** - using DOG based feature detection
101
+ - **Interest Point Matching** - using descriptor based RANSAC to match feature points
102
+ - **Global Optimization** - aligning matched features per tile, globally
103
+ - **Validation and Visualization Tools** - validate component specific results for the best output
104
+
105
+ ---
106
+
107
+ <br>
108
+
109
+ ## High Level Approach to Registration, Alignment, and Fusion
110
+
111
+ We first run **interest point detection** to capture feature points in the dataset, focusing on overlapping regions between tiles. These points drive all downstream alignment.
112
+
113
+ Next, we perform **alignment** in two-three stages, with regularized models:
114
+
115
+ 1. **Rigid matching + solver** – Match interest points with a rigid model and solve for globally consistent rigid transforms between all tiles.
116
+ 2. **Affine matching + solver** – Starting from the rigid solution, repeat matching with an affine model to recover more precise tile transforms.
117
+ 3. **Split affine matching + solver** – For very large z-stacks, we recommend first running the split dataset component to chunk tiles into smaller Z-bounds, then repeating affine matching and solving in “split affine” mode to refine local alignment.
118
+
119
+ All resulting transforms are written back into the input XML.
120
+
121
+ Whether you split or not, once the XML contains your final transforms, you are ready for **fusion**. We recommend viewing the aligned XML in FIJI/BDV to visually confirm alignment quality before running fusion.
122
+
123
+
124
+ ---
125
+
126
+ <br>
127
+
128
+ ## Performance
129
+
130
+ **Interest Point Detection Performance Example (130TB Zarr dataset)**
131
+
132
+ | Environment | Resources | Avg runtime |
133
+ |:----------------------|:---------------------|:-----------:|
134
+ | Local single machine | 10 CPU, 10 GB RAM | ~120 min |
135
+ | AWS Ray cluster | 560 CPU, 4.4 TB RAM | ~30 min |
136
+
137
+ <br>
138
+ *Actual times vary by pipeline components, dataset size, tiling, and parameter choices.*
139
+
140
+ ---
141
+
142
+ <br>
143
+
144
+ ## Layout
145
+
146
+ ```
147
+ Rhapso/
148
+ └── Rhapso/
149
+ ├── data_prep/ # Custom data loaders
150
+ ├── detection/
151
+ ├── evaluation/
152
+ ├── fusion/
153
+ ├── image_split/
154
+ ├── matching/
155
+ ├── pipelines/
156
+ │ └── ray/
157
+ │ ├── aws/
158
+ │ │ ├── config/ # Cluster templates (edit for your account)
159
+ │ │ └── alignment_pipeline.py # AWS Ray pipeline entry point
160
+ │ ├── local/
161
+ │ │ └── alignment_pipeline.py # Local Ray pipeline entry point
162
+ │ ├── param/ # Run parameter files (customize per run)
163
+ │ ├── interest_point_detection.py # Detection pipeline script
164
+ │ ├── interest_point_matching.py # Matching pipeline script
165
+ │ └── solver.py # Global solver script
166
+ ├── solver/
167
+ └── visualization/ # Validation tools
168
+ ```
169
+
170
+ ---
171
+
172
+ <br>
173
+
174
+
175
+ ## Installation
176
+
177
+ ```sh
178
+ # clone the repo
179
+ git clone https://github.com/AllenNeuralDynamics/Rhapso.git
180
+
181
+ # create and activate a virtual environment
182
+ python -m venv .venv && source .venv/bin/activate
183
+ # or: conda create -n rhapso python=3.11 && conda activate rhapso
184
+
185
+ # install deps
186
+ pip install -r requirements.txt
187
+ ```
188
+ ---
189
+
190
+ <br>
191
+
192
+ ## Ray
193
+
194
+ **Ray** is a Python framework for parallel and distributed computing. It lets you run regular Python functions in parallel on a single machine **or** scale them out to a cluster (e.g., AWS) with minimal code changes. In Rhapso, we use Ray to process large scale datasets.
195
+
196
+ - Convert a function into a distributed task with `@ray.remote`
197
+ - Control scheduling with resource hints (CPUs, memory)
198
+
199
+ <br>
200
+
201
+ > [!TIP]
202
+ > Ray schedules **greedily** by default and each task reserves **1 CPU**, so if you fire many tasks, Ray will try to run as many as your machine advertises—often too much for a laptop. Throttle concurrency explicitly so you don’t overload your system. Use your machine's activity monitor to track this or the Ray dashboard to monitor this on your cluster:
203
+ >
204
+ > - **Cap by CPUs**:
205
+ > ```python
206
+ > @ray.remote(num_cpus=3) # Ray will schedule each time 3 cpus are available
207
+ > ```
208
+ > - **Cap by Memory and CPU** if Tasks are RAM-Heavy (bytes):
209
+ > ```python
210
+ > @ray.remote(num_cpus=2, memory=4 * 1024**3) # 4 GiB and 2 CPU per task>
211
+ > ```
212
+ > - **No Cap** on Resources:
213
+ > ```python
214
+ > @ray.remote
215
+ > ```
216
+ > - **Good Local Default:**
217
+ > ```python
218
+ > @ray.remote(num_cpus=2)
219
+ > ```
220
+
221
+ ---
222
+
223
+ <br>
224
+
225
+
226
+ ## Run Locally with Ray
227
+
228
+ ### 1. Edit or create param file (templates in codebase)
229
+ ```python
230
+ Rhapso/Rhapso/pipelines/param/
231
+ ```
232
+
233
+ ### 2. Update alignment pipeline script to point to param file
234
+ ```python
235
+ with open("Rhapso/pipelines/ray/param/your_param_file.yml", "r") as file:
236
+ config = yaml.safe_load(file)
237
+ ```
238
+
239
+ ### 3. Run local alignment pipeline script
240
+ ```python
241
+ python Rhapso/pipelines/ray/local/alignment_pipeline.py
242
+
243
+ ```
244
+
245
+ ---
246
+
247
+ <br>
248
+
249
+
250
+ ## Run on AWS Cluster with Ray
251
+
252
+ ### 1. Edit/create param file (templates in codebase)
253
+ ```python
254
+ Rhapso/pipelines/ray/param/
255
+ ```
256
+
257
+ ### 2. Update alignment pipeline script to point to param file
258
+ ```python
259
+ with open("Rhapso/pipelines/ray/param/your_param_file.yml", "r") as file:
260
+ config = yaml.safe_load(file)
261
+ ```
262
+
263
+ ### 3. Edit/create config file (templates in codebase)
264
+ ```python
265
+ Rhapso/pipelines/ray/aws/config/
266
+ ```
267
+
268
+ ### 4. Update config file to point to whl location in setup_commands
269
+ ```python
270
+ - aws s3 cp s3://rhapso-whl-v2/Rhapso-0.1.8-py3-none-any.whl /tmp/Rhapso-0.1.8-py3-none-any.whl
271
+ ```
272
+
273
+ ### 5. Update alignment pipeline script to point to config file
274
+ ```python
275
+ unified_yml = "your_cluster_config_file_name.yml"
276
+ ```
277
+
278
+ ### 6. Create whl file and upload to s3
279
+ ```python
280
+ python setup.py sdist bdist_wheel
281
+ ```
282
+
283
+ ### 7. Run AWS alignment pipeline script
284
+ ```python
285
+ python Rhapso/pipelines/ray/aws/alignment_pipeline.py
286
+ ```
287
+
288
+ > [!TIP]
289
+ > - The pipeline script is set to always spin the cluster down, it is a good practice to double check in AWS.
290
+ > - If you experience a sticky cache on run params, you may have forgotten to spin your old cluster down.
291
+
292
+ <br>
293
+
294
+ ## Access Ray Dashboard
295
+
296
+ **This is a great place to tune your cluster's performance.**
297
+ 1. Find public IP of head node.
298
+ 2. Replace the ip address and PEM file location to ssh into head node.
299
+ ```
300
+ ssh -i /You/path/to/ssh/key.pem -L port:localhost:port ubuntu@public.ip.address
301
+ ```
302
+ 4. Go to dashboard.
303
+ ```
304
+ http://localhost:8265
305
+ ```
306
+
307
+ ---
308
+
309
+ <br>
310
+
311
+ ## Parameters
312
+
313
+ ### Detection
314
+ ```
315
+ | Parameter | Feature / step | What it does | Typical range\* |
316
+ | :----------------- | :--------------------- | :-------------------------------------------------------------------------------------------- | :-------------------------------- |
317
+ | `dsxy` | Downsampling (XY) | Reduces XY resolution before detection; speeds up & denoises, but raises minimum feature size | 16 |
318
+ | `dsz` | Downsampling (Z) | Reduces Z resolution; often lower than XY due to anisotropy | 16 |
319
+ | `min_intensity` | Normalization | Lower bound for intensity normalization prior to DoG | 1 |
320
+ | `max_intensity` | Normalization | Upper bound for intensity normalization prior to DoG | 5 |
321
+ | `sigma` | DoG blur | Gaussian blur scale (sets feature size); higher = smoother, fewer peaks | 1.5 - 2.5 |
322
+ | `threshold` | Peak detection (DoG) | Peak threshold (initial min peak ≈ `threshold / 3`); higher = fewer, stronger peaks | 0.0008 - .05 |
323
+ | `median_filter` | Pre-filter (XY) | Median filter size to suppress speckle/isolated noise before DoG | 1-10 |
324
+ | `combine_distance` | Post-merge (DoG peaks) | Merge radius (voxels) to de-duplicate nearby detections | 0.5 |
325
+ | `chunks_per_bound` | Tiling/parallelism | Sub-partitions per tile/bound; higher improves parallelism but adds overhead | 12-18 |
326
+ | `max_spots` | Post-cap | Maximum detections per bound to prevent domination by dense regions | 8,0000 - 10,000 |
327
+ ```
328
+ <br>
329
+
330
+ ### Matching
331
+ ```
332
+ # Candidate Selection
333
+ | Parameter | Feature / step | What it does | Typical range |
334
+ | :----------------------------- | :------------------ | :---------------------------------------------------------------- | :------------- |
335
+ | `num_neighbors` | Candidate search | Number of nearest neighbors to consider per point | 3 |
336
+ | `redundancy` | Candidate search | Extra neighbors added for robustness beyond `num_neighbors` | 0 - 1 |
337
+ | `significance` | Ratio test | Strictness of descriptor ratio test; larger = stricter acceptance | 3 |
338
+ | `search_radius` | Spatial gating | Max spatial distance for candidate matches (in downsampled units) | 100 - 300 |
339
+ | `num_required_neighbors` | Candidate filtering | Minimum neighbors required to keep a candidate point | 3 |
340
+
341
+ # Ransac
342
+ | Parameter | Feature / step | What it does | Typical range |
343
+ | :---------------------------- | :------------------- | :---------------------------------------------------------------- | :------------- |
344
+ | `model_min_matches` | RANSAC | Minimum correspondences to estimate a rigid transform | 18 – 32 |
345
+ | `inlier_factor` | RANSAC | Inlier tolerance scaling; larger = looser inlier threshold | 30 – 100 |
346
+ | `lambda_value` | RANSAC | Regularization strength during model fitting | 0.1 – 0.05 |
347
+ | `num_iterations` | RANSAC | Number of RANSAC trials; higher = more robust, slower | 10,0000 |
348
+ | `regularization_weight` | RANSAC | Weight applied to the regularization term | 1.0 |
349
+
350
+ ```
351
+ <br>
352
+
353
+ ### Solver
354
+ ```
355
+ | Parameter | Feature / step | What it does | Typical range |
356
+ | :------------------- | :------------- | :----------------------------------------------------------------- | :------------------ |
357
+ | `relative_threshold` | Graph pruning | Reject edges with residuals above dataset-relative cutoff | 3.5 |
358
+ | `absolute_threshold` | Graph pruning | Reject edges above an absolute error bound (detection-space units) | 7.0 |
359
+ | `min_matches` | Graph pruning | Minimum matches required to retain an edge between tiles | 3 |
360
+ | `damp` | Optimization | Damping for iterative solver; higher can stabilize tough cases | 1.0 |
361
+ | `max_iterations` | Optimization | Upper bound on solver iterations | 10,0000 |
362
+ | `max_allowed_error` | Optimization | Overall error cap; `inf` disables hard stop by error | `inf` |
363
+ | `max_plateauwidth` | Early stopping | Stagnation window before stopping on no improvement | 200 |
364
+
365
+ ```
366
+
367
+ ---
368
+
369
+ <br>
370
+
371
+ ## Tuning Guide
372
+
373
+ - **Start with Detection.** The quality and density of interest points strongly determine alignment outcomes.
374
+
375
+ - **Target Counts (exaSPIM):** ~25–35k points per tile in dense regions; ~10k for sparser tiles. Going much higher usually increases runtime without meaningful accuracy gains.
376
+
377
+ - **Inspect Early.** After detection, run the visualization script and verify that peaks form **clustered shapes/lines** with a **good spatial spread**—a good sign for robust rigid matches.
378
+
379
+ - **Rigid → Affine Dependency.** Weak rigid matches produce poor rigid transforms, which then degrade affine matching (points don’t land close enough). If tiles fail to align:
380
+ - Check **match counts** for the problem tile and its neighbors.
381
+ - Adjust high-impact detection knobs—`sigma`, `threshold`, and `median_filter`—within sensible ranges.
382
+ - Revisit `max_spots` and `combine_distance` to balance density vs. duplicate detections.
383
+
384
+ ---
385
+
386
+ <br>
387
+
388
+ ## Build Package
389
+
390
+ ### Using the Built `.whl` File
391
+
392
+ 1. **Build the `.whl` File in the root of this repo:**
393
+ ```sh
394
+ cd /path/to/Rhapso
395
+ pip install setuptools wheel
396
+ python setup.py sdist bdist_wheel
397
+ ```
398
+ The `.whl` file will appear in the `dist` directory. Do not rename it to ensure compatibility (e.g., `rhapso-0.1-py3-none-any.whl`).
399
+
400
+ ---
401
+
402
+ <br>
403
+ <br>
404
+ <br>
@@ -90,12 +90,12 @@ Rhapso/split_dataset/save_points.py,sha256=k-jH-slmxkbrxDl-uJvDkwOedi6cg7md3kg_a
90
90
  Rhapso/split_dataset/save_xml.py,sha256=Iq1UdFa8sdnWGygfIpDi4F5In-SCWggpl7lnuDTxkHE,14280
91
91
  Rhapso/split_dataset/split_images.py,sha256=2RzAi0btV1tmh4le9QotRif1IYUU6_4pLcGGpFBM9zk,22434
92
92
  Rhapso/split_dataset/xml_to_dataframe_split.py,sha256=ByaLzJ4sqT417UiCQU31_CS_V4Jms7pjMbBl0ZdSNNA,8570
93
- rhapso-0.1.92.dist-info/licenses/LICENSE,sha256=U0Y7B3gZJHXpjJVLgTQjM8e_c8w4JJpLgGhIdsoFR1Y,1092
93
+ rhapso-0.1.93.dist-info/licenses/LICENSE,sha256=U0Y7B3gZJHXpjJVLgTQjM8e_c8w4JJpLgGhIdsoFR1Y,1092
94
94
  tests/__init__.py,sha256=LYf6ZGyYRcduFFSaOLmnw3rTyfS3XLib0dsTHDWH0jo,37
95
95
  tests/test_detection.py,sha256=NtFYR_du9cbKrclQcNiJYsKzyqly6ivF61pw6_NICcM,440
96
96
  tests/test_matching.py,sha256=QX0ekSdyIkPpAsXHfSMqJUUlNZg09caSlhhUM63MduM,697
97
97
  tests/test_solving.py,sha256=t8I9XPV_4ZFM-DJpgvdYXxkG2_4DQgqs-FFyE5w8Nfg,695
98
- rhapso-0.1.92.dist-info/METADATA,sha256=ZcBZ0BjZxEyzWTv8K3WhzF5McBOpBmPVNePX3VM2bgQ,1300
99
- rhapso-0.1.92.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
100
- rhapso-0.1.92.dist-info/top_level.txt,sha256=NXvsrsTfdowWbM7MxEjkDZE2Jo74lmq7ruWkp70JjSw,13
101
- rhapso-0.1.92.dist-info/RECORD,,
98
+ rhapso-0.1.93.dist-info/METADATA,sha256=_exarxbXQL4-UWym9tIP_5IBdoT6xKiA4CXZfbvkMBU,16667
99
+ rhapso-0.1.93.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
100
+ rhapso-0.1.93.dist-info/top_level.txt,sha256=NXvsrsTfdowWbM7MxEjkDZE2Jo74lmq7ruWkp70JjSw,13
101
+ rhapso-0.1.93.dist-info/RECORD,,
@@ -1,39 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: Rhapso
3
- Version: 0.1.92
4
- Summary: A python package for aligning and stitching light sheet fluorescence microscopy images together
5
- Author: ND
6
- Author-email: sean.fite@alleninstitute.org
7
- Classifier: Development Status :: 3 - Alpha
8
- Classifier: Intended Audience :: Developers
9
- Classifier: Natural Language :: English
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.7
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Operating System :: OS Independent
16
- Requires-Python: >=3.7
17
- License-File: LICENSE
18
- Requires-Dist: pandas
19
- Requires-Dist: dask[array]==2024.12.1
20
- Requires-Dist: zarr==2.18.3
21
- Requires-Dist: scipy==1.13.1
22
- Requires-Dist: scikit-image
23
- Requires-Dist: bioio==1.3.0
24
- Requires-Dist: bioio-tifffile==1.0.0
25
- Requires-Dist: tifffile==2025.1.10
26
- Requires-Dist: dask-image==2024.5.3
27
- Requires-Dist: boto3==1.35.92
28
- Requires-Dist: numcodecs==0.13.1
29
- Requires-Dist: matplotlib==3.10.0
30
- Requires-Dist: memory-profiler==0.61.0
31
- Requires-Dist: s3fs==2024.12.0
32
- Requires-Dist: scikit-learn
33
- Dynamic: author
34
- Dynamic: author-email
35
- Dynamic: classifier
36
- Dynamic: license-file
37
- Dynamic: requires-dist
38
- Dynamic: requires-python
39
- Dynamic: summary