Model Module
The model module manages 3D/2D volume models for reconstruction.
Model Types
MODEL_3D- Full 3D volume reconstructionMODEL_2D- 2D slice reconstructionMODEL_RZ- Cylindrical (R-Z) reconstruction
Usage Example
from dragonfly.model import Model
model = Model(size=64, num_modes=2, model_type='3d')
model.allocate('starting_model.h5', model_mean=100.0)
view = model.slice_gen(quaternion, detector, mode=0)
- class dragonfly.model.Model(long size=0, int num_modes=1, model_type='3d')
Bases:
objectModel class for 3D/2D volume reconstruction.
- Parameters:
- allocate(self, fname, double model_mean=1., int rank=0, bool fixed_seed=False)
Allocate and optionally load model from file.
- center
Center coordinate of the model.
- free(self)
Free allocated model memory.
- inter_weight
Interpolation weights, shape (num_modes, size, …).
- static make_rot_quat(double[:] quaternion)
Convert quaternion to rotation matrix.
- Parameters:
quaternion (
numpy.ndarray) – 4-component quaternion.- Returns:
3x3 rotation matrix.
- Return type:
- model1
Current model intensities, shape (num_modes, size, …).
- model2
Accumulated model from current iteration, shape (num_modes, size, …).
- mtype
Returns the model type (MODEL_3D, MODEL_2D, or MODEL_RZ).
- ndim
Number of dimensions (3 for 3D, 2 for 2D/RZ).
- num_modes
Number of modes.
- static rotate_model(double[:, :, :] model, double[:, :] rot, int max_r=0, rotmodel=None)
Apply rotation matrix to model.
- Parameters:
model (
numpy.ndarray) – Model array to rotate.rot (
numpy.ndarray) – 3x3 rotation matrix.max_r (int) – Maximum radius for masking. Default 0.
rotmodel (
numpy.ndarray) – Pre-allocated output array. Default None.
- Returns:
Rotated model.
- Return type:
- size
Size of the model grid.
- slice_gen(self, double[:] quat, CDetector det, int mode=0, view=None)
Generate a 2D slice from the model.
- Parameters:
quat (
numpy.ndarray) – Quaternion defining the orientation.det (CDetector) – Detector to project onto.
mode (int) – Mode index. Default 0.
view (
numpy.ndarray) – Pre-allocated output array. Default None.
- Returns:
2D slice values.
- Return type:
- slice_merge(self, double[:] quat, double[:] view, CDetector det, int mode=0)
Merge a 2D slice back into the model.
- Parameters:
quat (
numpy.ndarray) – Quaternion defining the orientation.view (
numpy.ndarray) – 2D slice values to merge.det (CDetector) – Detector for projection.
mode (int) – Mode index. Default 0.
- static symmetrize_axial(double[:, :, :] model, double[:, :, :] weights, int order)
Apply N-fold axial symmetry.
- Parameters:
model (
numpy.ndarray) – Model array to symmetrize.weights (
numpy.ndarray) – Weight array.order (int) – Order of rotational symmetry.
- static symmetrize_friedel(double[:, :, :] model, double[:, :, :] weights)
Apply Friedel (point inversion) symmetry.
- Parameters:
model (
numpy.ndarray) – Model array to symmetrize.weights (
numpy.ndarray) – Weight array.
- static symmetrize_friedel2d(double[:, :, :] model2d, double[:, :, :] weights2d)
Apply Friedel symmetry to 2D slices.
- Parameters:
model2d (
numpy.ndarray) – 2D model array.weights2d (
numpy.ndarray) – 2D weight array.
- static symmetrize_icosahedral(double[:, :, :] model, double[:, :, :] weights)
Apply icosahedral point group symmetry.
- Parameters:
model (
numpy.ndarray) – Model array to symmetrize.weights (
numpy.ndarray) – Weight array.
- static symmetrize_octahedral(double[:, :, :] model, double[:, :, :] weights)
Apply octahedral point group symmetry.
- Parameters:
model (
numpy.ndarray) – Model array to symmetrize.weights (
numpy.ndarray) – Weight array.
- vol
Total volume (number of voxels).