Skip to main content

A collection of tools for ultrasound localization microscopy (ULM).

Project description

ulmtools

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

Installation

pip install ulmtools

Examples

Detect peaks in a 2D image

import matplotlib.pyplot as plt
import numpy as np
from ulmtools import detect_peaks

shape = (128, 128)
extent = (0, shape[0] - 1, 0, shape[1] - 1)
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, extent, 0, 0)

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

Draw tracks on a 2D image

import matplotlib.pyplot as plt
import numpy as np
from ulmtools import draw_tracks

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, extent = draw_tracks(
    matrix,
    track_end_indices=np.array([matrix.shape[0]]),
    extent=extent,
    pixel_size=pixel_size,
    divide_by_pixel_counts=False,
)

fig, ax = plt.subplots()
ax.imshow(
    np.abs(image.T),
    extent=(
        extent[0] - 0.5 * pixel_size,
        extent[1] + 0.5 * pixel_size,
        extent[2] - 0.5 * pixel_size,
        extent[3] + 0.5 * pixel_size,
    ),
    origin="lower",
    cmap="hot",
    interpolation="nearest",
)
plt.show()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ulmtools-0.1.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ulmtools-0.1.1-cp37-abi3-win_amd64.whl (233.0 kB view details)

Uploaded CPython 3.7+Windows x86-64

ulmtools-0.1.1-cp37-abi3-manylinux_2_34_x86_64.whl (405.7 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.34+ x86-64

ulmtools-0.1.1-cp37-abi3-macosx_11_0_arm64.whl (347.9 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

File details

Details for the file ulmtools-0.1.1.tar.gz.

File metadata

  • Download URL: ulmtools-0.1.1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ulmtools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b5b28d280836e11e6f42008cab4933b2d6ac7f826e72495e86379aae02e681fd
MD5 f26bd802c7dc27d0fc65137c320a0877
BLAKE2b-256 c5fc957c4d7d2e98006e85dc175f7fc655ebaad2b8a3c036ffb30c38279c9ec0

See more details on using hashes here.

File details

Details for the file ulmtools-0.1.1-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: ulmtools-0.1.1-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 233.0 kB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ulmtools-0.1.1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6c64e2eda8e9908fbf7e31e805c481555f20e8b57e0b3266d1fac3564e312035
MD5 47c7fd7c326cee0119c3d5f72a9552b1
BLAKE2b-256 0c4dcb37bfb22478783aa44b27bb249649f71ff7d598808fe973862d560e179e

See more details on using hashes here.

File details

Details for the file ulmtools-0.1.1-cp37-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ulmtools-0.1.1-cp37-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8cfe3c81f6bd9459fe3899f6871467257073395c3b80ef5bd22a60043a1b6e71
MD5 1bd5bf1cffcd439a9cf105efb3f227f6
BLAKE2b-256 13f9d6360d9114ebb3dd541b6af5c82b0979e4c2b5ef8f985af862864b632970

See more details on using hashes here.

File details

Details for the file ulmtools-0.1.1-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ulmtools-0.1.1-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b276eb848c93efed85715097288a0699ef16b8951d90873b300d0620c3427cc9
MD5 fa050e8c207c2985e93be78b0468e4ae
BLAKE2b-256 941fce5314f59f2cfde956623cfc3c47f747c558819cc6a270c2394bda811bb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page