Metadata-Version: 2.4
Name: ulmtools
Version: 0.2.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Dist: numpy>=2.0,!=2.4.0
Summary: A collection of tools for ultrasound localization microscopy (ULM).
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# ulmtools
A collection of tools for Ultrasound Localization Microscopy (ULM) implemented in Rust.

## Installation
```bash
pip install ulmtools
```

# Examples
## Detect peaks in a 2D image
```python
import matplotlib.pyplot as plt
import numpy as np
from ulmtools import detect_peaks

np.random.seed(0)
shape = (128, 128)
image = np.zeros(shape)

# Create test input
x_grid, y_grid = np.meshgrid(
    np.linspace(-1, 1, shape[0]), np.linspace(-1, 1, shape[1]), indexing="ij"
)
for n in range(32):
    x = 2 * (np.random.rand() - 0.5)
    y = 2 * (np.random.rand() - 0.5)
    d = np.sqrt((x_grid - x) ** 2 + (y_grid - y) ** 2)
    image += np.exp(-(d**2 / 3e-3))

peaks, intensities = detect_peaks(image)

# Plot results
fig, ax = plt.subplots()
ax.imshow(
    np.abs(image.T),
    cmap="hot",
)
ax.scatter(peaks[:, 0], peaks[:, 1], c="blue", s=2)
plt.show()
```

## Draw tracks on a 2D image
```python
import matplotlib.pyplot as plt
import numpy as np
from ulmtools import draw_tracks

np.random.seed(3)
shape = (128, 128)
extent = (-1, 1, -1, 1)
pixel_size = 1e-2

t = np.linspace(0.05, 1, 300)
matrix = np.stack(
    [np.sin(5 * 2 * np.pi * t) * t, np.cos(5 * 2 * np.pi * t) * t, 1 - t], axis=1
)

image_intensity, image_density, extent = draw_tracks(
    matrix,
    track_end_indices=np.array([matrix.shape[0]]),
    pixel_size=pixel_size,
    extent=extent,
)

fig, ax = plt.subplots()
ax.imshow(
    np.abs(image_density.T),
    cmap="hot",
    interpolation="nearest",
)
plt.show()
```

