Skip to main content

Fast utility functions useful for Fourier Ring/Shell Correlation: binom_split, pois_gen, square_abs.

Project description

rustfrc

GitHub release License

rustfrc is a Python package with some fast Rust functions that are useful when performing Fourier Ring Correlation (FRC) computations for resolution determination in microscopy (specifically optical nanoscopy). It was originally developed for use in a Bachelor end project for the TU Delft in the period 2021-2022. See the Python package frc for examples of its usage. The test_split.py file in the tests directory also holds some examples.

Since rustfrc contains compiled (Rust) extensions and is not pure Python, it is not available for all platforms, but only for those with available compiled wheels or a Rust toolchain and maturin support (see below). They are available for Windows (x86_64), macOS (x86_64 and universal2, which includes Apple Silicon) and Linux (x86_64). However, since Rust and Python are supported on many platforms, it is not difficult to compile for other platforms (see below).

Features

rustfrc has only a few features. The primary one is binom_split(x: ndarray) -> ndarray which samples binomial (n, 0.5) with n as the array element value. The operation is fully parallelized and somewhere between 3-10x faster than sampling using NumPy.

Furthermore, there are also (since version 1.1) sqr_abs(a: ndarray) -> ndarray and pois_gen(lam: float, shape: tuple[int, ...]) -> ndarray.

sqr_abs computes the element-wise norm and square of a complex array, while pois_gen generates an array of the specified size using the Poisson distribution and a single parameter λ.

Requirements

  • Python 3.8-3.12
  • NumPy 1.18+ (exact version might depend on Python version, e.g. Python 3.12 requires NumPy 1.26)

Performance

On an i7-8750H, a decently high performance 6-core chip from 2017, I measured the following speeds:

  • binom_split: ~210 ms on a 4000x4000 array, with each element Poisson-generated with a mean of 200
  • pois_gen: ~420 ms to generate a 4000x4000 array with mean 200
  • sqr_abs: ~40 ms on a 4000x4000 array, where each element is a complex number with both the real and imaginary parts having a mean of 200

Take this with a grain of salt, but it should provide a decent order of magnitude for larger images.

Installation

You can most easily install rustfrc as follows:

pip install rustfrc

However, for an optimal Python experience, use poetry and install it using poetry add rustfrc.

From source (using maturin)

rustfrc uses poetry as its Python dependency manager. For best results, create a poetry virtualenv (be sure to install virtualenv as a systems package) with the pyproject.toml and run poetry update to install the required packages. I recommend installing maturin as a global tool (e.g. with cargo binstall).

Build a wheel file like this (if using poetry, append poetry run before the command) from the project directory:

maturin build --release

If you want to choose which versions of Python to build for, you can write e.g. maturin build --release -i python3.9 python3.8 python3.7. Here, for example 'python3.7' should be an available Python command installed on your computer.

This generates .whl files in /target/wheels. Then, create a Python environment of your choosing (with numpy ^1.18 and python ^3.7), drop the .whl file in it and run pip install <.whl filename>, for example: pip install rustfrc-0.1.0-cp39-none-win_amd64.whl. Then, use import rustfrc in your Python script to be able to use the Rust functions. This should be generally valid for all platforms. The only real requirement is the availability of a Rust toolchain and Python for your platform.

Take a look at PyO3 for other installation options as the only true requirement for building is using a tool that understands PyO3 bindings, as those are used in the Rust code.

Manylinux

If you want to build .whl files that are compatible with a wide range of Linux distributions and can be uploaded to PyPI, take a look at the GitHub Actions files and pyo3/maturin-action.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

rustfrc-1.1.5-cp312-none-win_amd64.whl (223.5 kB view details)

Uploaded CPython 3.12 Windows x86-64

rustfrc-1.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

rustfrc-1.1.5-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (675.8 kB view details)

Uploaded CPython 3.12 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

rustfrc-1.1.5-cp311-none-win_amd64.whl (226.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

rustfrc-1.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

rustfrc-1.1.5-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (684.2 kB view details)

Uploaded CPython 3.11 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

rustfrc-1.1.5-cp310-none-win_amd64.whl (225.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

rustfrc-1.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

rustfrc-1.1.5-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (688.2 kB view details)

Uploaded CPython 3.10 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

rustfrc-1.1.5-cp39-none-win_amd64.whl (226.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

rustfrc-1.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

rustfrc-1.1.5-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (686.5 kB view details)

Uploaded CPython 3.9 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

rustfrc-1.1.5-cp38-none-win_amd64.whl (225.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

rustfrc-1.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

rustfrc-1.1.5-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (686.6 kB view details)

Uploaded CPython 3.8 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

File details

Details for the file rustfrc-1.1.5-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 2113155e544ee498dcf51a14188dfb6e5d445d7e8ae2136535f64e1e489aaf45
MD5 6637212a876995e55741d421e254e633
BLAKE2b-256 e7cff2859514a3e72a671225c38b46a380b1a2d2b4918c3a6c7dd8a6f0c56424

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a53b3eb1d35c0d161ae657b566481da499558fcf808dae268300a1717bcff73
MD5 2a9e3cc4ed81a68fe0cbac6fe8446090
BLAKE2b-256 b1c900c38c190da1730c62dbc8131f98e30172a0983472d17ba83675743eab66

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 424d9e299c1ace18fb739daa3ecea5f34e8b5cf8a795f77627ea6c2115ae4e43
MD5 58eb06dc391cdc3cd73a60b9e778f367
BLAKE2b-256 edc64bda3badd41d05889fc23db16698510b8b5426f1da9ed65c78ec80ee1deb

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 d50c42e8d905a1ffaccd2d97e00ad20db5c44ab9cc615b3915c648a7d6612997
MD5 fb92d7bd9de34ff512d76fdc627cd48a
BLAKE2b-256 54954be5549d349786c7f7900dda46a5a9cb965a343861ddb36f5eb7c77e60a6

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3078eef7f415816b7423da57038b66d4742ab1ebbf1890038ea4c7dd376ed688
MD5 3aca9ca2d71c38983358148b496ba6fb
BLAKE2b-256 835b326c9d894220c116cbbd829ffbd4dfb20ef7b75043cdfb751e56ca6526c3

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 fa910109c2043adc44331ec70418366d978d9bff6d4552d0ffca2f5374f48a40
MD5 e7479e4bac1c34c051982af25793f78f
BLAKE2b-256 cdc11125b163ebca8b3f0a49a81d296a3c4f7f754b0e2a3a96aa197d9a8fe4d2

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 0cc9685f1a5bded9ebe7624029544169dd72fc7f493892eea785578dfbb51c9f
MD5 3b9c90bf8db590328c3cab33b06105f7
BLAKE2b-256 ce634cd0e829adc4b2778a7330308ac4fac1764f387640aeb7ea087aa0d9682e

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a03e2b1d660e7c5c63f962712899a522a79ee8b38114affb86139ded0971e06d
MD5 f99e8e0ef1ab2be0a75eef07e4bac0ee
BLAKE2b-256 2123c0e9d419d6ff4642a1fc3e6692fa6f695f6c2144babdd87584edf2f557f2

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 3773073d196ab2b4008eeeb81aaa2e89fe1ed2244425e7f40c489c1e06baaa26
MD5 2d79c24150429503678d36d42b9d3c28
BLAKE2b-256 fc319a85b981b2e6f825b9a5a2b7015d8e3d338a37359b23c55d437dff8a1326

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 86b30f4dd94112ee50c7aa4cefc174678ccad7582943bec62f7a51e6f4e2cc58
MD5 65540282d46b6dede42a77b49261e500
BLAKE2b-256 db5591659f9639df6090090c087d6595f3b8820271bdd410dddf32496219e995

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 65dbbef19f6d4f5d86c66310bdbd1c01e49ce094943a5b047100f15c3e1d798f
MD5 786b3432ff29234e3b3829c2fbaacae6
BLAKE2b-256 1731e5a6fda67529e1241cba0c766d59edacd314c22cee8cb44d7e41c6b6984a

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 824d6e8a6d69ee6946d5e95593f1711e265f628951127629a93ba08c7461b090
MD5 b83c1422e8925e165bd720a654b41812
BLAKE2b-256 447f254ef7b747003e580911db7d00152c22c8dd30202cb3a2f5145b6521ce90

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 2c6709c731000603951e9f8882106e7d91e46af4601d26e3da1acf66e06965b8
MD5 a377234ca9661b09e917fa9500300d53
BLAKE2b-256 84014d3423d59609dbb6476c6d60a8f94df1ee9eeb9d327f51ff2c116d970614

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e175c0680d3921bf9f1f0ac75585782e1aaa76cb0c3163537e2bdf9f248f093
MD5 f3e481b09a4950606aada561326b0b42
BLAKE2b-256 c7361f3b482f5b2a9362af706fae36c67a96779db7917cdcd4d266b815b94ebb

See more details on using hashes here.

File details

Details for the file rustfrc-1.1.5-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rustfrc-1.1.5-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 e39b32adf705b4df5a91d107367d1464d3519b9c9f65d31855ddd816b3cc6a1b
MD5 a23d4d99da522e36e61d86df88cc51ba
BLAKE2b-256 97e6c55f64cc7c058ac42d140b0686bc3bd80882ad7d0fb8bf20d4e89e0c5f5d

See more details on using hashes here.

Supported by

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