Single Molecule Reconstructions
Project description
Single Molecule Reconstruction Package
A Python package for creating scale-space reconstructions of single molecule microscopy data, with support for masked regions and uniform distribution modeling.
Features
- Generate 2D Gaussian reconstructions from single molecule localizations
- Support for masked regions of interest
- Flexible pixel size scaling and error handling
- Uniform distribution modeling within masked regions
- Multiple image format support (PNG, JPG, TIF, SVG)
- Coordinate conversion between reconstruction and original space
Installation
pip install smrecon # Package name placeholder
Quick Start
from smrecon import SMReconstruction, ImageFormat
# Initialize reconstruction
reconstructor = SMReconstruction(
img_dims=(512, 512), # Original image dimensions
pixel_size=130, # Original pixel size in nm
rescale_pixel_size=10 # Target pixel size in nm
)
# Create reconstruction from localizations
localizations = np.array([[x1, y1], [x2, y2], ...]) # Your localization data
errors = np.array([e1, e2, ...]) # Localization errors
image = reconstructor.make_reconstruction(
localizations=localizations,
localization_error=errors
)
# Save the result
reconstructor.save_image(
path="output/",
name="reconstruction",
fmt=ImageFormat.TIF
)
Advanced Usage: Masked Reconstruction
from smrecon import SMReconstructionMasked, MaskedReconstructionConfig
# Create custom configuration
config = MaskedReconstructionConfig(
bounding_box_padding=5,
mask_threshold=255,
gaussian_scale_factor=5.0
)
# Initialize masked reconstruction
masked_reconstructor = SMReconstructionMasked(
img_dims=(512, 512),
pixel_size=130,
rescale_pixel_size=10,
config=config
)
# Create masked reconstruction
masked_image = masked_reconstructor.make_reconstruction(
localizations=localizations,
localization_error=errors,
masked_img=your_mask_array,
uniform=False # Set to True for uniform distribution within mask, number of localizations will be placed in the mask region uniformly.
)
API Reference
Main Classes
SMReconstruction
Base class for single molecule reconstruction.
SMReconstructionMasked
Extended class supporting masked regions and uniform distributions.
Configuration Classes
ReconstructionConfig
class ReconstructionConfig:
bounding_box_padding: int = 5
random_seed: int = 666
gaussian_scale_factor: float = 5.0
MaskedReconstructionConfig
class MaskedReconstructionConfig(ReconstructionConfig):
mask_threshold: int = 255
uniform_distribution: bool = False
Enums
ImageFormat
Supported image formats:
- PNG
- JPG
- TIF
- SVG
ConversionType
Converting between the reconstruction space coordinates and the original space (and vice versa).
# Initialize masked reconstruction
masked_reconstructor = SMReconstructionMasked(
img_dims=(512, 512),
pixel_size=130,
rescale_pixel_size=10,
config=config
)
# Create masked reconstruction
masked_image = masked_reconstructor.make_reconstruction(
localizations=localizations,
localization_error=errors,
masked_img=your_mask_array,
uniform=False # Set to True for uniform distribution within mask
)
xycoord, spatialcoord = masked_image.coordinate_conversion([x_i, y_i], r_i, conversion_type)
# x_i, y_i are the spacial coordinates and are affected by bounding box and rescaling
# r_i is a distance and only affected by rescaling.
# first argument is always a spatial coordinate and second is always distance.
Coordinate conversion types:
- RC_TO_ORIGINAL # recon -> original space
- ORIGINAL_TO_RC # original -> recon space
conversion_type takes values of an enum:
class ConversionType(str, Enum):
"""Types of coordinate conversion."""
RC_TO_ORIGINAL = "RC_to_Original"
ORIGINAL_TO_RC = "Original_to_RC"
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smrecon-0.1.0.tar.gz.
File metadata
- Download URL: smrecon-0.1.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fac214efe369b207f0aad08dc6bd51259cfcdd2bf1a032fb53f9780985aad926
|
|
| MD5 |
d32b0c496365da57a2e091191c3051ab
|
|
| BLAKE2b-256 |
409af0bd37d6b687ba3affe0338a4500f3522b8d45bb552ba2e23ddbe463fe53
|
Provenance
The following attestation bundles were made for smrecon-0.1.0.tar.gz:
Publisher:
pypi_publish.yml on joemans3/SMRecon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smrecon-0.1.0.tar.gz -
Subject digest:
fac214efe369b207f0aad08dc6bd51259cfcdd2bf1a032fb53f9780985aad926 - Sigstore transparency entry: 170337420
- Sigstore integration time:
-
Permalink:
joemans3/SMRecon@1c54daa31ee7686018fa9ba877f8e8d00da4a825 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/joemans3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@1c54daa31ee7686018fa9ba877f8e8d00da4a825 -
Trigger Event:
push
-
Statement type:
File details
Details for the file smrecon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: smrecon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14141b7a0809cfa5072567a64936738c4b375f7c6589c25bcf1cba2ccd2626fa
|
|
| MD5 |
b1b019a7f15573c78ed5052a9e493bae
|
|
| BLAKE2b-256 |
2576d7688370bd3354a2499b271892740fad79d6a8c7756c0c7f0df53b7b44f8
|
Provenance
The following attestation bundles were made for smrecon-0.1.0-py3-none-any.whl:
Publisher:
pypi_publish.yml on joemans3/SMRecon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smrecon-0.1.0-py3-none-any.whl -
Subject digest:
14141b7a0809cfa5072567a64936738c4b375f7c6589c25bcf1cba2ccd2626fa - Sigstore transparency entry: 170337422
- Sigstore integration time:
-
Permalink:
joemans3/SMRecon@1c54daa31ee7686018fa9ba877f8e8d00da4a825 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/joemans3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@1c54daa31ee7686018fa9ba877f8e8d00da4a825 -
Trigger Event:
push
-
Statement type: