Getting Started#
Installation#
Install from PyPI (recommended):
pip install ultrasound-metrics
For development installation:
git clone https://github.com/Forest-Neurotech/ultrasound-metrics.git
cd ultrasound-metrics
make install
Quick Start#
Basic usage with NumPy arrays:
import numpy as np
import ultrasound_metrics as um
# Generate example beamformed channel data
n_elements, height, width = 64, 100, 150
channel_data = np.random.complex128((n_elements, height, width))
# Compute coherence factor
coherence = um.coherence_factor(channel_data)
print(f"Coherence shape: {coherence.shape}") # (100, 150)
print(f"Coherence range: [{coherence.min():.3f}, {coherence.max():.3f}]")
# Compute image sharpness
bmode_image = np.abs(channel_data.sum(axis=0))
sharpness = um.tenengrad(bmode_image)
print(f"Tenengrad sharpness: {sharpness:.2f}")
Multi-Backend Usage#
The same API works with different array libraries:
import jax.numpy as jnp
import torch
import ultrasound_metrics as um
# JAX example with JIT compilation
data_jax = jnp.ones((64, 100, 100), dtype=jnp.complex64)
compute_coherence_jit = jax.jit(um.coherence_factor)
coherence_jax = compute_coherence_jit(data_jax)
# PyTorch example
data_torch = torch.randn(64, 100, 100, dtype=torch.complex64)
coherence_torch = um.coherence_factor(data_torch)
Next Steps#
Explore the Concepts to learn about ultrasound metrics
Browse the Examples for practical workflows and inspiration
Check the API Reference for complete function documentation
See Contributing if you’d like to contribute to the project