Pure-Python/PyTorch FF-HEDM transforms (drop-in for MergeOverlappingPeaksAllZarr / CalcRadiusAllZarr / FitSetupZarr / SaveBinData)
Project description
midas-transforms
Pure-Python / PyTorch FF-HEDM intermediate transforms — the four stages between peak-fitting and indexing in the MIDAS workflow.
Drop-in replacement for these C binaries:
| C binary | Python entry point |
|---|---|
MergeOverlappingPeaksAllZarr |
midas-merge-peaks |
CalcRadiusAllZarr |
midas-calc-radius |
FitSetupZarr |
midas-fit-setup |
SaveBinData |
midas-bin-data |
Plus an end-to-end midas-transforms pipeline <zarr> that runs all four on
GPU with no CSV / binary disk round-trips between stages.
Why
- Speed. Vectorised PyTorch kernels target ≥ 1× C on CPU and 5–50× on GPU at production scale. Binning and merge are the workflow's longest tails; both are now broadcast + scatter operations.
- Bit-matching with C. Every deterministic stage targets byte-exact
output at float64. The geometry refine (
DoFit==1) targets physics-meaningful tolerance viamidas-calibrate.refine_geometry(LM with ADAM fallback — no NLopt, no Nelder-Mead). - Differentiable. All geometry parameters that flow through detector
projection (
Lsd,BC_y,BC_z,tx/ty/tz,p0..p14,wedge,dLsd,dP2, residual-correction map values) carry full autograd throughapply_tilt_distortion— useful for joint calibration with downstream grain mapping. - CPU/GPU portable. Single
device=switch (cpu / cuda / mps). No separate.cucodebase. No C extensions, nocibuildwheel.
Install
pip install -e packages/midas_transforms
(Until uploaded to PyPI; once released, pip install midas-transforms.)
Quick start
Per-stage CLI (drop-in for the C binaries)
midas-merge-peaks scan.zip
midas-calc-radius scan.zip
midas-fit-setup scan.zip
midas-bin-data --result-folder .
End-to-end Pipeline (intermediates stay on GPU)
midas-transforms pipeline scan.zip --device cuda --out-dir /scratch/run42
Library
from midas_transforms import Pipeline
pipe = Pipeline.from_zarr("scan.zip", device="cuda")
result = pipe.run()
result.merge # (N, 17) on GPU
result.radius # (N, 24) on GPU
result.fit_setup # InputAll/Extra tensors on GPU
result.bins # Spots/ExtraInfo/Data/nData tensors on GPU
pipe.dump("/scratch/run42")
Or use stages individually:
from midas_transforms import merge_overlapping_peaks, calc_radius, fit_setup, bin_data
merge_overlapping_peaks(zarr_path="scan.zip", device="cuda")
calc_radius(result_folder=".", zarr_params=..., device="cuda")
fit_setup(result_folder=".", zarr_params=..., device="cuda")
bin_data(result_folder=".", device="cuda")
Wiring into ff_MIDAS.py
ff_MIDAS.py accepts a --useTorchTransforms 1 flag (mirrors the
existing --useTorchIndexer / --peakFitGPU flags). When set, the
workflow's merge_overlaps, calc_radius, data_transform, and
binning stages dispatch to the Python entry points instead of the C
binaries. Outputs are byte-compatible (or numerically equivalent for
the DoFit geometry refine).
Limits
- Scanning workflows (
SaveBinDataScanning,MergeMultipleScans) are out of scope here; they belong with the broader scanning pipeline. - ResidualCorrectionMap filename is parsed from Zarr but the per-pixel
ΔR map isn't yet sampled in
apply_tilt_distortion(the bilinear sampler exists; thenp.fromfile(...).reshape(NrPixelsZ, NrPixelsY)load is a TODO infit_setup/core.py).
See also
dev/implementation_plan.md— full design, scope, and risk register.midas-peakfit— upstream peak-fitting (writes the consolidated HDF5).midas-index— downstream indexer (consumesSpots.bin/Data.bin).midas-calibrate— providesgeometry_torch.pixel_to_REta_torchandrefine_geometry(LM solver) used byfit_setup.midas-hkls— upstreamhkls.csvgeneration.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file midas_transforms-0.2.0.tar.gz.
File metadata
- Download URL: midas_transforms-0.2.0.tar.gz
- Upload date:
- Size: 57.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d076531723803c667cf9203e4d7849ab36895777550e0c4df598046cafc38e42
|
|
| MD5 |
7608aea80c03ea6c2b831a7fbd30a30b
|
|
| BLAKE2b-256 |
1de9efc4b1bf49cc549a9654a83506044b1945b098a916860ea8844b49a44541
|
Provenance
The following attestation bundles were made for midas_transforms-0.2.0.tar.gz:
Publisher:
python-packages.yml on marinerhemant/MIDAS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midas_transforms-0.2.0.tar.gz -
Subject digest:
d076531723803c667cf9203e4d7849ab36895777550e0c4df598046cafc38e42 - Sigstore transparency entry: 1422403743
- Sigstore integration time:
-
Permalink:
marinerhemant/MIDAS@1c5f93bbc9f13e2b83bef442f3f9f6c86c3526ea -
Branch / Tag:
refs/tags/midas-transforms-v0.2.0 - Owner: https://github.com/marinerhemant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-packages.yml@1c5f93bbc9f13e2b83bef442f3f9f6c86c3526ea -
Trigger Event:
release
-
Statement type:
File details
Details for the file midas_transforms-0.2.0-py3-none-any.whl.
File metadata
- Download URL: midas_transforms-0.2.0-py3-none-any.whl
- Upload date:
- Size: 53.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b52afc4c0b98534e6a2c61bcacdb836541a89d8d243ce62debcc8ea855add2c
|
|
| MD5 |
b332ea510b7f93bf89bed0bd38a50ab5
|
|
| BLAKE2b-256 |
a8b4b027fad10669b0b2a17c094845853f5513b3bbdcb0662addca7ab951ef66
|
Provenance
The following attestation bundles were made for midas_transforms-0.2.0-py3-none-any.whl:
Publisher:
python-packages.yml on marinerhemant/MIDAS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midas_transforms-0.2.0-py3-none-any.whl -
Subject digest:
7b52afc4c0b98534e6a2c61bcacdb836541a89d8d243ce62debcc8ea855add2c - Sigstore transparency entry: 1422403822
- Sigstore integration time:
-
Permalink:
marinerhemant/MIDAS@1c5f93bbc9f13e2b83bef442f3f9f6c86c3526ea -
Branch / Tag:
refs/tags/midas-transforms-v0.2.0 - Owner: https://github.com/marinerhemant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-packages.yml@1c5f93bbc9f13e2b83bef442f3f9f6c86c3526ea -
Trigger Event:
release
-
Statement type: