Reconstruction API
Reconstructor
- class cryoPARES.reconstruction.reconstructor.Reconstructor(symmetry, correct_ctf=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, eps=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, min_denominator_value=None, weight_with_confidence=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, *args, **kwargs)[source]
Bases:
Module
- Parameters:
- __init__(symmetry, correct_ctf=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, eps=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, min_denominator_value=None, weight_with_confidence=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, *args, **kwargs)[source]
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- set_metadata_from_particles(particlesDataset)[source]
- Parameters:
particlesDataset (ReconstructionParticlesDataset)
- backproject_particles(particles_star_fname, particles_dir=None, batch_size=1, num_dataworkers=0, use_only_n_first_batches=None, subset_idxs=None, halfmap_subset=None)[source]
- static get_sincsq(shape, device, eps=0.001)[source]
Separable de-apodization for trilinear gridding: PSF(z,y,x) = sinc^2(z) * sinc^2(y) * sinc^2(x), evaluated on the voxel grid.
torch.sinc(x) = sin(pi*x)/(pi*x). We use centered voxel coordinates normalized by the length in each axis so the arguments live roughly in [-0.5, 0.5]; add a floor to avoid division blow-ups.
- class cryoPARES.reconstruction.reconstructor.ReconstructionParticlesDataset(particles_star_fname, particles_dir=None, correct_ctf=True, subset_idxs=None, halfmap_subset=None, return_confidence=False)[source]
Bases:
Dataset
- Parameters:
- __init__(particles_star_fname, particles_dir=None, correct_ctf=True, subset_idxs=None, halfmap_subset=None, return_confidence=False)[source]
- property sampling_rate
- property particle_shape
- property particles
- cryoPARES.reconstruction.reconstructor.reconstruct_starfile(particles_star_fname, symmetry, output_fname, particles_dir=None, num_dataworkers=1, batch_size=128, use_cuda=True, correct_ctf=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, eps=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, min_denominator_value=None, use_only_n_first_batches=None, float32_matmul_precision=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, weight_with_confidence=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, halfmap_subset=None)[source]
- Parameters:
particles_star_fname (
str
) – The particles to reconstructsymmetry (
str
) – The symmetry of the volume (e.g. C1, D2, …)output_fname (
str
) – The name of the output filename (star)particles_dir (
Optional
[str
]) – The particles directory (root of the starfile fnames)num_dataworkers (
int
) – Num workers for data loadingbatch_size (
int
) – The number of particles to be simultaneously backprojecteduse_cuda (
bool
) – if NOT, it will not use cuda devicescorrect_ctf (
bool
) – if NOT, it will not correct CTFeps (
float
) – The regularization constant (ideally, this is 1/SNR)min_denominator_value (
Optional
[float
]) – Used to prevent division by 0. By default is 0.1*epsuse_only_n_first_batches (
Optional
[int
]) – Use only the n first batches to reconstructfloat32_matmul_precision (
Optional
[str
]) – Set it to high or medium for speed up at a precision costweight_with_confidence (
bool
) – If True, read and apply per-particle confidence. If False (default), do NOT fetch/pass confidence (zero overhead).halfmap_subset (
Optional
[Literal
['1'
,'2'
]]) – The random subset of particles to use
Reconstructor Class
- class cryoPARES.reconstruction.reconstructor.Reconstructor(symmetry, correct_ctf=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, eps=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, min_denominator_value=None, weight_with_confidence=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, *args, **kwargs)[source]
Bases:
Module
- Parameters:
- __init__(symmetry, correct_ctf=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, eps=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, min_denominator_value=None, weight_with_confidence=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, *args, **kwargs)[source]
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- set_metadata_from_particles(particlesDataset)[source]
- Parameters:
particlesDataset (ReconstructionParticlesDataset)
- backproject_particles(particles_star_fname, particles_dir=None, batch_size=1, num_dataworkers=0, use_only_n_first_batches=None, subset_idxs=None, halfmap_subset=None)[source]
- static get_sincsq(shape, device, eps=0.001)[source]
Separable de-apodization for trilinear gridding: PSF(z,y,x) = sinc^2(z) * sinc^2(y) * sinc^2(x), evaluated on the voxel grid.
torch.sinc(x) = sin(pi*x)/(pi*x). We use centered voxel coordinates normalized by the length in each axis so the arguments live roughly in [-0.5, 0.5]; add a floor to avoid division blow-ups.
Command-Line Interface
Create a shared memory tensor
- cryoPARES.reconstruction.reconstruct.reconstruct_starfile(particles_star_fname, symmetry, output_fname, particles_dir=None, n_jobs=1, num_dataworkers=1, batch_size=128, use_cuda=True, correct_ctf=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, eps=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, min_denominator_value=None, use_only_n_first_batches=None, float32_matmul_precision=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, weight_with_confidence=<cryoPARES.configManager.inject_defaults.CONFIG_PARAM object>, halfmap_subset=None)[source]
Reconstruct a 3D volume from particle images with known poses.
- Parameters:
particles_star_fname (
str
) – Path to input STAR file with particle metadata and poses to reconstructsymmetry (
str
) – Point group symmetry of the volume for reconstruction (e.g., C1, D2, I, O, T)output_fname (
str
) – Path for output reconstructed 3D volume (.mrc file)particles_dir (
Optional
[str
]) – Root directory for particle image paths. If provided, overrides paths in the .star filen_jobs (
int
) – Number of parallel worker processes for distributed reconstructionnum_dataworkers (
int
) – Number of CPU workers per PyTorch DataLoader for data loadingbatch_size (
int
) – Number of particles to backproject simultaneously per jobuse_cuda (
bool
) – Enable GPU acceleration for reconstruction. If False, runs on CPU onlycorrect_ctf (
bool
) – Apply CTF correction during reconstructioneps (
float
) – Regularization constant for reconstruction (ideally set to 1/SNR). Prevents division by zero and stabilizes reconstructionmin_denominator_value (
Optional
[float
]) – Minimum value for denominator to prevent numerical instabilities during reconstructionuse_only_n_first_batches (
Optional
[int
]) – Reconstruct using only first N batches (for testing or quick validation)float32_matmul_precision (
Optional
[str
]) – PyTorch float32 matrix multiplication precision mode (“highest”, “high”, or “medium”)weight_with_confidence (
bool
) – Apply per-particle confidence weighting during backprojection. If True, particles with higher confidence contribute more to reconstruction. It reads the confidence from the metadata label “rlnParticleFigureOfMerit”halfmap_subset (
Optional
[Literal
['1'
,'2'
]]) – Select half-map subset (1 or 2) for half-map reconstruction and validation