Library for computing Fourier Ring Correlation (FRC) curves and using them to determine image resolution.
Project description
frc
frc
is a Python library for calculating Fourier Ring Correlation (FRC) curves and their associated resolution.
This is particularly useful for determining the resolution of images taken with super-resolution microscopy techniques.
Its most computationally intensive functions are all implemented either in NumPy or Rust, making this library very fast.
Fourier Ring Correlation
Introduced in 1982, Fourier Ring Correlation compares two 2D images, which are assumed to be noise-independent. In Fourier space, mage structure dominates the lower spatial frequencies (in the Fourier domain), while noise dominates at the higher frequencies.
In Fourier space, there are rings of constant spatial frequency around the origin. By calculating the correlation between the rings in the two images, you get the FRC curve:
See the accompanying FRC.pdf
for additional details.
At some spatial frequency, the signal cannot be separated from the noise. What spatial frequency exactly depends on what threshold function is used. The standard 0.143 and 1/2-bit thresholds are both available, as well as an algorithm to compute the intersection and resulting resolution.
Installation
You can download this library from PyPI:
pip install frc
This library depends on tmtenbrink/rustfrc, DIPlib, scipy and of course, numpy.
Usage
The code snippet below (which for illustration purposes assumes you have a numpy array or DIP image representing your input, its associated scale and also matplotlib to plot the result) will calculate the FRC curve and the associated resolution using the standard 1/7 threshold.
import frc
import numpy as np
import matplotlib.pyplot as plt
... # get an image and scale
img = np.array(img)
# Input can be a numpy array or DIP image
img = frc.util.square_image(img, add_padding=False)
img = frc.util.apply_tukey(img)
# Apply 1FRC technique
frc_curve = frc.one_frc(img)
img_size = img.shape[0]
xs_pix = np.arange(len(frc_curve)) / img_size
# scale has units [pixels <length unit>^-1] corresponding to original image
xs_nm_freq = xs_pix * scale
frc_res, res_y, thres = frc.frc_res(xs_nm_freq, frc_curve, img_size)
plt.plot(xs_nm_freq, thres(xs_nm_freq))
plt.plot(xs_nm_freq, frc_curve)
plt.show()
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
File details
Details for the file frc-0.1.0.tar.gz
.
File metadata
- Download URL: frc-0.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.5 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac1007c24ed57166a99b8d630c2d89cb0de3e682c2dee3e43f9a6bc685ac925d |
|
MD5 | 58d899187b2779f1b9ede456ce89852d |
|
BLAKE2b-256 | 815184f67f60bc6b5f027cf724093bd4bb54a7f8158e315756c05eb248a85fea |
File details
Details for the file frc-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: frc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.5 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4f1de2982b5a9d34de843cc55cfcbb600019700d43c6bcec30ecc2041d0fc1a |
|
MD5 | 66ceede8b69d6d0bd0c533cf4e334c0e |
|
BLAKE2b-256 | a73ef9a880b7e6000f002db86c85bcd7e5caf059fa1a60f5d177f8f982f76e45 |