Bsoft 2.1.4
Bernard's software package
mg_orient.cpp File Reference

Determines orientation angles and x,y origins of single particle images. More...

#include "mg_orient.h"
#include "mg_processing.h"
#include "rwmg.h"
#include "mg_particle_select.h"
#include "mg_ctf.h"
#include "symmetry.h"
#include "linked_list.h"
#include "rwimg.h"
#include "ps_views.h"
#include "utilities.h"
#include <fstream>
#include <sys/stat.h>
#include <fcntl.h>

Functions

int part_determine_orientation (Bparticle *part, Bimage *proj, Bimage *part_mask, Bimage *prs_mask, Bsymmetry &sym, int bin, double res_lo, double res_hi, double res_polar, int ann_min, int ann_max, double shift_limit, double angle_limit, double edge_radius, int flags, fft_plan planf_1D, fft_plan planb_1D, fft_plan planf_2D, fft_plan planb_2D)
 
double correlation_coefficient_adjust (double cc, double std)
 
Bimageproject_prepare_2D_references (Bproject *project, long first, long number, int bin, int ctf_action, double wiener)
 Prepare reference images from particles. More...
 
Bimageimg_prepare_projections (Bstring &filename, Bstring &mask_file, int bin, Bsymmetry &sym, double theta_step, double phi_step, double side_ang)
 Generate projections if a 3D file, otherwise clean projections. More...
 
Bimageimg_read_projection (Bstring &proj_file, int multi_file, int proj_num)
 
int project_determine_orientations (Bproject *project, Bimage *proj, Bstring &mask_file, int bin, Bsymmetry &sym, int part_select, vector< double > &band, double res_lo, double res_hi, double res_polar, int ann_min, int ann_max, double shift_limit, double angle_limit, double edge_radius, int flags)
 Find the orientation and origin of every image in a project. More...
 
Bparticle part_compare (Bimage *p, Bimage *proj, Bimage *prs_mask, long k, int bin, CTFparam *ctf, double res_lo, double res_hi, double res_polar, long ann_min, long ann_max, double shift_limit, double angle_limit, double edge_radius, int flags, fft_plan planf_1D, fft_plan planb_1D, fft_plan planf_2D, fft_plan planb_2D)
 
int part_determine_orientation2 (Bparticle *part, Bimage *proj, Bimage *part_mask, Bimage *prs_mask, Bsymmetry &sym, int bin, double res_lo, double res_hi, double res_polar, int ann_min, int ann_max, double shift_limit, double angle_limit, double edge_radius, int flags, fft_plan planf_1D, fft_plan planb_1D, fft_plan planf_2D, fft_plan planb_2D)
 
int project_determine_orientations2 (Bproject *project, Bimage *proj, Bstring &mask_file, int bin, Bsymmetry &sym, int part_select, vector< double > &band, double res_lo, double res_hi, double res_polar, int ann_min, int ann_max, double shift_limit, double angle_limit, double edge_radius, int flags)
 Find the orientation and origin of every image in a project. More...
 
int project_determine_origins (Bproject *project, Bimage *proj, int bin, Bsymmetry &sym, int part_select, double res_lo, double res_hi, double shift_limit, int flags)
 Find the origin of every image in a project. More...
 
double img_cross_validate (Bimage *p, Bimage *pref, Bimage *prs_mask, fft_plan planf)
 Rotates and shifts a reference image and calculates a cross-validation coefficient. More...
 

Variables

int verbose
 

Detailed Description

Determines orientation angles and x,y origins of single particle images.

Author
Bernard Heymann and David M. Belnap
Date
Created: 20010403
Modified: 20220813 (BH)

Function Documentation

◆ correlation_coefficient_adjust()

double correlation_coefficient_adjust ( double  cc,
double  std 
)

◆ img_cross_validate()

double img_cross_validate ( Bimage p,
Bimage pref,
Bimage prs_mask,
fft_plan  planf 
)

Rotates and shifts a reference image and calculates a cross-validation coefficient.

Parameters
*p2D image.
*prefreference 2D image.
*prs_maskdual mask.
planfFFT forward plan.
Returns
double cross-validation coefficient.
The reference image is first rotated by the difference in the angles
between the image and the reference, then shifted to the same origin
as the image. Both are then Fourier transformed, the negative values in
the mask used to select reciprocal space areas, and the complex product
calculated. The sum of the zeroeth pixel then gives the cross-validation
coefficient.
The input images must be equal-sized square 2D images.

◆ img_prepare_projections()

Bimage * img_prepare_projections ( Bstring filename,
Bstring mask_file,
int  bin,
Bsymmetry sym,
double  theta_step,
double  phi_step,
double  side_ang 
)

Generate projections if a 3D file, otherwise clean projections.

Parameters
&filenamefile containing reference map or projections.
&mask_filemask to apply to projections.
bindata compression by binning.
*sympoint group symmetry structure.
theta_stepangular step size from primary symmetry axis (radians).
phi_stepangular step size around primary symmetry axis (radians).
side_angangular devaition from eqautor (radians).
Returns
Bimage* projection images, NULL on error.
If the input file is a 3D map, a set of projections are generated
given the point group symmetry.
Flags:
    FULL_ASU    projections for full asymmetric unit
    MULTI_FILE  projections in multiple files   

◆ img_read_projection()

Bimage * img_read_projection ( Bstring proj_file,
int  multi_file,
int  proj_num 
)

◆ part_compare()

Bparticle part_compare ( Bimage p,
Bimage proj,
Bimage prs_mask,
long  k,
int  bin,
CTFparam ctf,
double  res_lo,
double  res_hi,
double  res_polar,
long  ann_min,
long  ann_max,
double  shift_limit,
double  angle_limit,
double  edge_radius,
int  flags,
fft_plan  planf_1D,
fft_plan  planb_1D,
fft_plan  planf_2D,
fft_plan  planb_2D 
)

◆ part_determine_orientation()

int part_determine_orientation ( Bparticle part,
Bimage proj,
Bimage part_mask,
Bimage prs_mask,
Bsymmetry sym,
int  bin,
double  res_lo,
double  res_hi,
double  res_polar,
int  ann_min,
int  ann_max,
double  shift_limit,
double  angle_limit,
double  edge_radius,
int  flags,
fft_plan  planf_1D,
fft_plan  planb_1D,
fft_plan  planf_2D,
fft_plan  planb_2D 
)

◆ part_determine_orientation2()

int part_determine_orientation2 ( Bparticle part,
Bimage proj,
Bimage part_mask,
Bimage prs_mask,
Bsymmetry sym,
int  bin,
double  res_lo,
double  res_hi,
double  res_polar,
int  ann_min,
int  ann_max,
double  shift_limit,
double  angle_limit,
double  edge_radius,
int  flags,
fft_plan  planf_1D,
fft_plan  planb_1D,
fft_plan  planf_2D,
fft_plan  planb_2D 
)

◆ project_determine_orientations()

int project_determine_orientations ( Bproject project,
Bimage proj,
Bstring mask_file,
int  bin,
Bsymmetry sym,
int  part_select,
vector< double > &  band,
double  res_lo,
double  res_hi,
double  res_polar,
int  ann_min,
int  ann_max,
double  shift_limit,
double  angle_limit,
double  edge_radius,
int  flags 
)

Find the orientation and origin of every image in a project.

Parameters
*projectimage processing parameter structure.
*projreference projections.
&mask_filemask to apply to particles.
bindata compression by binning.
*sympoint group symmetry structure.
part_selectparticle selection for processing.
*bandarray of reciprocal space bands.
res_lolow resolution limit (angstrom).
res_hihigh resolution limit (angstrom).
res_polarresolution limit for in-plane angular alignment (angstrom).
ann_minminimum annulus (>=0).
ann_maxmaximum annulus (< image radius).
shift_limitmaximum shift from nominal origin of box.
angle_limitmaximum rotation from original in-plane rotation angle.
edge_radiusedge radius to mask background using previous origin.
flagsoption flags.
Returns
int error code.
The polar power spectrum (pps) of the reference projection is cross correlated
with that of the image in order to find the angle of rotation.  The image
is transformed using this angle and the shift found by cross correlation (cc).
A  second iterative comparison is done with real space polar images
to find the angle followed by cross correlation to find the shift.
How much of this second comparison is done depends on the mode flag:
    mode=0  pps     projection selected only based on pps comparison
    mode=1  scc     several projections selected based on cutoff for pps cc's
    mode=2  ccc     all projections selected
The angle and the x and y values are stored in the view_angle, and ox and oy 
arrays of the micrograph parameter structure.
The projections must already be binned.
Flags:
    MODE        projection matching mode
    APPLY_CTF   apply CTF to projections
    PART_LOG    write log files in log directory

◆ project_determine_orientations2()

int project_determine_orientations2 ( Bproject project,
Bimage proj,
Bstring mask_file,
int  bin,
Bsymmetry sym,
int  part_select,
vector< double > &  band,
double  res_lo,
double  res_hi,
double  res_polar,
int  ann_min,
int  ann_max,
double  shift_limit,
double  angle_limit,
double  edge_radius,
int  flags 
)

Find the orientation and origin of every image in a project.

Parameters
*projectimage processing parameter structure.
*projreference projections.
&mask_filemask to apply to particles.
bindata compression by binning.
*sympoint group symmetry structure.
part_selectparticle selection for processing.
*bandarray of reciprocal space bands.
res_lolow resolution limit (angstrom).
res_hihigh resolution limit (angstrom).
res_polarresolution limit for in-plane angular alignment (angstrom).
ann_minminimum annulus (>=0).
ann_maxmaximum annulus (< image radius).
shift_limitmaximum shift from nominal origin of box.
angle_limitmaximum rotation from original in-plane rotation angle.
edge_radiusedge radius to mask background using previous origin.
flagsoption flags.
Returns
int error code.
The polar power spectrum (pps) of the reference projection is cross correlated
with that of the image in order to find the angle of rotation.  The image
is transformed using this angle and the shift found by cross correlation (cc).
A  second iterative comparison is done with real space polar images
to find the angle followed by cross correlation to find the shift.
How much of this second comparison is done depends on the mode flag:
    mode=0  pps     projection selected only based on pps comparison
    mode=1  scc     several projections selected based on cutoff for pps cc's
    mode=2  ccc     all projections selected
The angle and the x and y values are stored in the view_angle, and ox and oy
arrays of the micrograph parameter structure.
The projections must already be binned.
Flags:
    MODE        projection matching mode
    APPLY_CTF   apply CTF to projections
    PART_LOG    write log files in log directory

◆ project_determine_origins()

int project_determine_origins ( Bproject project,
Bimage proj,
int  bin,
Bsymmetry sym,
int  part_select,
double  res_lo,
double  res_hi,
double  shift_limit,
int  flags 
)

Find the origin of every image in a project.

Parameters
*projectimage processing parameter structure.
*projreference projections.
bindata compression by binning.
sympoint group symmetry structure.
part_selectparticle selection for processing.
res_lolow resolution limit (angstrom).
res_hihigh resolution limit (angstrom).
shift_limitmaximum shift from nominal origin of box.
flagsoption flags.
Returns
int error code.
The input view is used to find the corresponding reference projection.
This projection is then rotated by the input view angle and cross-correlated 
with the image to find the shift.
Flags:
    PART_LOG    write log files in log directory

◆ project_prepare_2D_references()

Bimage * project_prepare_2D_references ( Bproject project,
long  first,
long  number,
int  bin,
int  ctf_action,
double  wiener 
)

Prepare reference images from particles.

Parameters
projectmicrograph project structure.
firstfirst particle image to use.
numbernumber of particle images to use.
bindata compression by binning.
ctf_actionflag to apply CTF to projections.
wienerWiener factor.
Returns
Bimage* reference images, NULL on error.
The particle images are shifted to center their origins.

Variable Documentation

◆ verbose

int verbose
extern