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:
  • symmetry (str)

  • correct_ctf (bool)

  • eps (float)

  • min_denominator_value (float | None)

  • weight_with_confidence (bool)

__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.

Parameters:
  • symmetry (str)

  • correct_ctf (bool)

  • eps (float)

  • min_denominator_value (float | None)

  • weight_with_confidence (bool)

get_device()[source]
move_buffers_to_share_mem()[source]
get_buffers()[source]
zero_buffers()[source]
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]
Parameters:
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.

generate_volume(fname=None, overwrite_fname=True, device='cpu')[source]
Parameters:
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]
Parameters:
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 reconstruct

  • symmetry (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 loading

  • batch_size (int) – The number of particles to be simultaneously backprojected

  • use_cuda (bool) – if NOT, it will not use cuda devices

  • correct_ctf (bool) – if NOT, it will not correct CTF

  • eps (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*eps

  • use_only_n_first_batches (Optional[int]) – Use only the n first batches to reconstruct

  • float32_matmul_precision (Optional[str]) – Set it to high or medium for speed up at a precision cost

  • weight_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:
  • symmetry (str)

  • correct_ctf (bool)

  • eps (float)

  • min_denominator_value (float | None)

  • weight_with_confidence (bool)

__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.

Parameters:
  • symmetry (str)

  • correct_ctf (bool)

  • eps (float)

  • min_denominator_value (float | None)

  • weight_with_confidence (bool)

get_device()[source]
move_buffers_to_share_mem()[source]
get_buffers()[source]
zero_buffers()[source]
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]
Parameters:
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.

generate_volume(fname=None, overwrite_fname=True, device='cpu')[source]
Parameters:

Command-Line Interface

cryoPARES.reconstruction.reconstruct.worker(worker_id, *args, **kwargs)[source]
cryoPARES.reconstruction.reconstruct.create_shared_tensor(shape, dtype=torch.float32, ctx=None)[source]

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 reconstruct

  • symmetry (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 file

  • n_jobs (int) – Number of parallel worker processes for distributed reconstruction

  • num_dataworkers (int) – Number of CPU workers per PyTorch DataLoader for data loading

  • batch_size (int) – Number of particles to backproject simultaneously per job

  • use_cuda (bool) – Enable GPU acceleration for reconstruction. If False, runs on CPU only

  • correct_ctf (bool) – Apply CTF correction during reconstruction

  • eps (float) – Regularization constant for reconstruction (ideally set to 1/SNR). Prevents division by zero and stabilizes reconstruction

  • min_denominator_value (Optional[float]) – Minimum value for denominator to prevent numerical instabilities during reconstruction

  • use_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

cryoPARES.reconstruction.reconstruct.main()[source]