Differentiable PyTorch port of NF-HEDM preprocessing (CPU/CUDA/MPS): hex grid, tomo filter, diffraction-spot prediction, image processing
Project description
midas-nf-process-images
Differentiable PyTorch port of NF_HEDM/src/ProcessImagesCombined.c for CPU, CUDA, and MPS.
Pipeline
For one layer of a near-field HEDM scan:
- Load
NrFilesPerLayerraw TIFF frames into a[N, Z, Y]tensor. - Temporal median across frames → per-pixel background
[Z, Y]. - Per-frame:
- Subtract median +
BlanketSubtraction, clamp at 0. - Spatial median (3x3 or 5x5).
- LoG response at one or more scales.
- Threshold and label connected components → integer spot labels (detached).
- Sigmoid surrogate → continuous spot-probability map (autograd path).
- Subtract median +
- Accumulate spot pixels into a bit-packed
SpotsInfo.binmmap (drop-in compatible withFitOrientationOMP/simulateNF).
Phases 1, 2, and 3 (filtered, log_response, soft spot probability) are differentiable
end-to-end. Connected components and the binary SpotsInfo.bin output are computed on
detached tensors and do not participate in autograd.
Quickstart
from midas_nf_process_images import ProcessParams, ProcessImagesPipeline
params = ProcessParams.from_paramfile("ps.txt")
pipe = ProcessImagesPipeline(params, device="cuda") # or "mps", "cpu"
spots = pipe.process_layer(layer_nr=1)
spots.write("/path/to/SpotsInfo.bin")
# Or all layers in one call:
spots = pipe.process_all(layers=range(1, params.n_distances + 1))
CLI
midas-nf-process-images <ParameterFile> <LayerNr> [--device cuda] [--dtype fp32] [--n-cpus 8]
Behaves like the C ProcessImagesCombined executable.
Backend selection
Same contract as midas-transforms:
- Default device:
cuda->mps->cpu. - Default dtype:
float64on CPU,float32on CUDA/MPS. - Override with
device=/dtype=kwargs, or env varsMIDAS_NF_PROCESS_IMAGES_DEVICE/MIDAS_NF_PROCESS_IMAGES_DTYPE.
Differentiability
The end-to-end pipeline produces three tensors:
filtered: median-subtracted, spatial-median-filtered image (autograd).log_response: LoG convolution output (autograd).spot_prob: soft, continuous spot-probability map viasigmoid(L / temperature)(autograd).
Plus one detached output:
labels: integer connected-component IDs from hard-thresholded LoG (no gradient).
Optimization through the discrete spot mask uses the soft spot_prob surrogate.
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_nf_preprocess-0.1.0.tar.gz.
File metadata
- Download URL: midas_nf_preprocess-0.1.0.tar.gz
- Upload date:
- Size: 52.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aa5755ce2e61373309a9c6a958f2f9261314c83c2c2c07a8309064d60caf199
|
|
| MD5 |
9e9e2411fea972f7fa784358e282babb
|
|
| BLAKE2b-256 |
cd0c7c34011758b80ecbee54cbb9188a272e52878a17169179c87f52aef48acc
|
Provenance
The following attestation bundles were made for midas_nf_preprocess-0.1.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_nf_preprocess-0.1.0.tar.gz -
Subject digest:
1aa5755ce2e61373309a9c6a958f2f9261314c83c2c2c07a8309064d60caf199 - Sigstore transparency entry: 1438594783
- Sigstore integration time:
-
Permalink:
marinerhemant/MIDAS@04f7fa8dc162588e6db4f09603ed3e7743b91f58 -
Branch / Tag:
refs/tags/midas-nf-preprocess-v0.1.0 - Owner: https://github.com/marinerhemant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-packages.yml@04f7fa8dc162588e6db4f09603ed3e7743b91f58 -
Trigger Event:
release
-
Statement type:
File details
Details for the file midas_nf_preprocess-0.1.0-py3-none-any.whl.
File metadata
- Download URL: midas_nf_preprocess-0.1.0-py3-none-any.whl
- Upload date:
- Size: 67.3 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 |
ca814283edb928ab5b7bd338a0c533aeaa3cfa70a019b15c546fb95fbca1faad
|
|
| MD5 |
72fcd1bd1ee02ef51d6fdbf308661ea5
|
|
| BLAKE2b-256 |
ac0e722b4906240140ef2d8f936f7ff71a416f49ab4e9385257e015e3740d218
|
Provenance
The following attestation bundles were made for midas_nf_preprocess-0.1.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_nf_preprocess-0.1.0-py3-none-any.whl -
Subject digest:
ca814283edb928ab5b7bd338a0c533aeaa3cfa70a019b15c546fb95fbca1faad - Sigstore transparency entry: 1438594807
- Sigstore integration time:
-
Permalink:
marinerhemant/MIDAS@04f7fa8dc162588e6db4f09603ed3e7743b91f58 -
Branch / Tag:
refs/tags/midas-nf-preprocess-v0.1.0 - Owner: https://github.com/marinerhemant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-packages.yml@04f7fa8dc162588e6db4f09603ed3e7743b91f58 -
Trigger Event:
release
-
Statement type: