![]() |
Bsoft 2.1.4
Bernard's software package
|
Functions to manage tomographic series of images. More...
#include "mg_processing.h"
#include "mg_tomography.h"
#include "mg_select.h"
#include "mg_img_proc.h"
#include "rwimg.h"
#include "matrix_linear.h"
#include "simplex.h"
#include "linked_list.h"
#include "utilities.h"
#include "timer.h"
Functions | |
int | mg_marker_init (Bmicrograph *mg, Bmarker *model) |
Initializes markers from the reference. More... | |
int | mg_marker_update (Bmicrograph *mg, Bmarker *model, Vector3< double > oriref, int update_location) |
Calculates the predicted positions of markers from the reference. More... | |
Vector3< double > | mg_3D_location_from_marker (Vector3< double > loc, Vector3< double > ori3D, Matrix3 mat, Vector3< double > ori) |
int | mg_update_model (Bmicrograph *mg, Bmarker *model, Vector3< double > oriref) |
Fills in missing markers in the 3D model from micrograph markers. More... | |
Vector3< double > | mg_location_from_3D_model (Vector3< double > loc3D, Matrix3 mat, Vector3< double > ori) |
Calculates the 2D location of a marker from a 3D model. More... | |
Vector3< double > | mg_location_from_3D_model (Vector3< double > loc3D, Matrix3 mat, Vector3< double > ori, Vector3< double > scale) |
Vector3< double > | mg_location_from_3D_model (Vector3< double > loc3D, Vector3< double > ori3D, Matrix3 mat, Vector3< double > ori) |
Vector3< double > | mg_location_from_3D_model (Vector3< double > loc3D, Vector3< double > ori3D, Matrix3 mat, Vector3< double > ori, Vector3< double > scale) |
Bimage * | img_gold_particle (Vector3< long > size, double radius) |
Generates an image representing a gold particle. More... | |
Bmarker * | img_find_gold_particles (Bimage *p, int img_select, double radius, long edge, double cutoff) |
Finds gold particles in micrograph images. More... | |
int | project_mass_normalize (Bproject *project, double avg, double std, int norm_type, DataType datatype, int setinputZslices, int setoutputZslices, double cutmin, double cutmax, double replace_threshold) |
Normalizes a set of images in a project to a desired average and standard deviation. More... | |
double | lambda_R (Bsimplex &simp) |
vector< double > | simplex_fit_tilt_intensities (vector< double > &a, vector< double > &I) |
Bplot * | project_intensity_plot (Bproject *project) |
Transfers the micrograph intensities for a field into a plot. More... | |
double | project_fit_intensities (Bproject *project, Bplot *plot, int flag) |
Determines the thickness to mean free path ratio from a tilt series. More... | |
double | project_thickness_to_lambda_ratio (Bproject *project) |
Determines the thickness to mean free path ratio from a tilt series. More... | |
double | project_lambda (Bproject *project, double thickness) |
Determines the mean free path from a tilt series and thickness. More... | |
double | project_thickness (Bproject *project, double lambda) |
Determines the thickness from a tilt series and mean free path. More... | |
int | project_sort_markers_by_id (Bproject *project) |
Sorts markers for each micrograph by ID number. More... | |
double | project_tomo_residuals (Bproject *project, int show) |
Calculates the residuals for an alignment solution. More... | |
double | mg_tomo_residuals (Bmicrograph *mg, Bmarker *model, Vector3< double > oriref) |
Calculates the residuals for an alignment solution of one micrograph. More... | |
double | project_tomo_errors (Bproject *project) |
Analyzes marker errors. More... | |
int | project_calculate_model (Bproject *project) |
Calculates the z-coordinates of the marker model. More... | |
int | project_generate_markers (Bproject *project) |
Generates missing micrograph and model markers. More... | |
long | img_erase_markers (Bimage *p, Bmarker *mark, double marker_radius) |
Erases or paints markers in an image. More... | |
Bimage * | mg_erase_markers (Bmicrograph *mg, double marker_radius) |
Erases or paints markers in micrographs. More... | |
int | project_erase_markers (Bproject *project, double marker_radius) |
Erases or paints markers in micrographs. More... | |
int | mg_reset_model (Bmicrograph *mg, Bmarker *model) |
Resets the model x and y coordinates from the zero-tilt micrograph. More... | |
long | project_find_markers (Bproject *project, long edge, int add) |
Finds all markers in a project. More... | |
long | mg_find_markers (Bmicrograph *mg, long edge, int add) |
Finds markers in a micrograph. More... | |
Bimage * | mg_composite_particle (Bmicrograph *mg, Vector3< long > size) |
Generates an average particle image from a micrograph. More... | |
long | project_count_markers (Bproject *project) |
Counts the markers in a project hierarchy. More... | |
long | project_show_markers (Bproject *project) |
Shows the markers in a project hierarchy. More... | |
long | project_show_errors (Bproject *project, double error_cutoff) |
Shows the errors in marker coordinates in a project hierarchy. More... | |
long | project_deselect_markers (Bproject *project, Bstring &deselect_list) |
Deletes selected markers in a project hierarchy. More... | |
long | project_delete_markers (Bproject *project, Bstring &delete_list) |
Deletes selected markers in a project hierarchy. More... | |
long | project_renumber_markers (Bproject *project) |
Renumbers the markers in a project hierarchy. More... | |
long | project_mg_select (Bproject *project, Bstring &mg_select) |
Selects micrographs in a project hierarchy. More... | |
long | project_mg_exclude (Bproject *project, Bstring &mg_exclude) |
Deselects micrographs in a project hierarchy. More... | |
int | project_set_tilt_axis (Bproject *project, double tilt_axis) |
Sets the tilt axis angle in a project parameter structure. More... | |
int | project_invert_tilt_axis (Bproject *project) |
Inverts the tilt axis in a project parameter structure. More... | |
int | project_set_tilt_angles (Bproject *project, double tilt_start, double tilt_step) |
Sets the tilt and tilt axis angles in a project parameter structure. More... | |
int | project_mg_tilt_to_matrix (Bproject *project) |
Sets the matrix from the tilt and axis angles for each micrograph. More... | |
int | project_calculate_angles (Bproject *project) |
Calculates tilt and tilt axis angles from matrices in a project parameter structure. More... | |
int | project_invert_matrices (Bproject *project) |
Inverts the micrograph matrices in a project parameter structure. More... | |
int | project_mg_marker_select (Bproject *project, double fom) |
Selects markers. More... | |
int | project_set_marker_radius (Bproject *project, double mark_radius) |
Sets the marker radius in a project parameter structure. More... | |
int | project_check_markers (Bproject *project, int flags) |
Checks if the markers in a project parameter structure fall within micrographs. More... | |
int | project_fix_markers (Bproject *project) |
Checks if the markers in a project parameter structure fall within micrographs. More... | |
int | img_clear_extraneous_areas (Bimage *p, double tilt_axis, double tilt_angle, long thickness, double width) |
Clears extraneous areas from a micrograph. More... | |
int | micrograph_clear_extraneous_areas (Bmicrograph *mg, Bimage *p, long thickness, double width) |
Clears extraneous areas from a micrograph. More... | |
int | project_clear_extraneous_areas (Bproject *project, long thickness, double width) |
Clears areas from a tilt series not used in a reconstruction. More... | |
double | project_marker_rotation_axis (Bproject *project) |
Determines the most likely rotation axis location for a tilt series. More... | |
int | project_merge_rec_markers (Bproject *project) |
Merges the markers for two reconstructions. More... | |
Variables | |
int | verbose |
Functions to manage tomographic series of images.
int img_clear_extraneous_areas | ( | Bimage * | p, |
double | tilt_axis, | ||
double | tilt_angle, | ||
long | thickness, | ||
double | width | ||
) |
Clears extraneous areas from a micrograph.
*p | micrograph image. |
tilt_axis | tilt axis angle (radians). |
tilt_angle | tilt angle (radians). |
thickness | intended thickness of reconstruction. |
width | edge smoothing width. |
Erases or paints markers in an image.
*p | image parameter structure. |
*mark | linked list of markers. |
marker_radius | radius to mask out markers. |
Markers can be either erased to a background value or painted in with a set value.
Bmarker * img_find_gold_particles | ( | Bimage * | p, |
int | img_select, | ||
double | radius, | ||
long | edge, | ||
double | cutoff | ||
) |
Finds gold particles in micrograph images.
*p | image. |
img_select | selected subimage, -1 if all. |
radius | gold particle radius in voxel units. |
edge | edge width to eliminate particles. |
cutoff | FOM cutoff, if 0 then half of maximum FOM. |
An image of the size of an input sub-image is generated with a gold particle (black or negative density) at its center. Each sub-image is cross-correlated with the gold particle image and the position within the image reported. The FOM cutoff is used to select cross-correlation peaks, except it is reset for the following: cutoff == 0 ==> cutoff = FOMavg + FOMstd cutoff < 0 ==> cutoff = FOMmax/2
Generates an image representing a gold particle.
size | size of image to generate. |
radius | gold particle radius in voxel units. |
An image of the size of an input sub-image is generated with a gold particle (black or negative density) at its center.
double lambda_R | ( | Bsimplex & | simp | ) |
Vector3< double > mg_3D_location_from_marker | ( | Vector3< double > | loc, |
Vector3< double > | ori3D, | ||
Matrix3 | mat, | ||
Vector3< double > | ori | ||
) |
Bimage * mg_composite_particle | ( | Bmicrograph * | mg, |
Vector3< long > | size | ||
) |
Generates an average particle image from a micrograph.
*mg | micrograph to extract marker images from. |
size | size of image. |
Bimage * mg_erase_markers | ( | Bmicrograph * | mg, |
double | marker_radius | ||
) |
Erases or paints markers in micrographs.
*mg | micrograph parameter structure. |
marker_radius | radius to mask out markers. |
Markers can be either erased to a background value or painted in with a set value.
long mg_find_markers | ( | Bmicrograph * | mg, |
long | edge, | ||
int | add | ||
) |
Finds markers in a micrograph.
*mg | project parameter structure. |
edge | edge to exclude. |
add | flag to add rather than replace the markers. |
The markers are located by cross-correlation with a synthetic reference whose size is defined by the marker radius. Markers close to the edge are eliminated using the given edge size. The main intent is to find the seed for a 3D marker model in a zero degree tilt micrograph.
Vector3< double > mg_location_from_3D_model | ( | Vector3< double > | loc3D, |
Matrix3 | mat, | ||
Vector3< double > | ori | ||
) |
Calculates the 2D location of a marker from a 3D model.
loc3D | 3D marker location. |
mat | micrograph view matrix. |
ori | micrograph origin. |
Vector3< double > mg_location_from_3D_model | ( | Vector3< double > | loc3D, |
Matrix3 | mat, | ||
Vector3< double > | ori, | ||
Vector3< double > | scale | ||
) |
Vector3< double > mg_location_from_3D_model | ( | Vector3< double > | loc3D, |
Vector3< double > | ori3D, | ||
Matrix3 | mat, | ||
Vector3< double > | ori | ||
) |
Vector3< double > mg_location_from_3D_model | ( | Vector3< double > | loc3D, |
Vector3< double > | ori3D, | ||
Matrix3 | mat, | ||
Vector3< double > | ori, | ||
Vector3< double > | scale | ||
) |
int mg_marker_init | ( | Bmicrograph * | mg, |
Bmarker * | model | ||
) |
Initializes markers from the reference.
*mg | micrograph to initialize. |
*model | marker model. |
int mg_marker_update | ( | Bmicrograph * | mg, |
Bmarker * | model, | ||
Vector3< double > | oriref, | ||
int | update_location | ||
) |
Calculates the predicted positions of markers from the reference.
*mg | micrograph to update. |
*model | marker model. |
oriref | reference origin. |
update_location | flag to update location based on marker model. |
If the marker does not exist in the micrograph, a new one is generated.
int mg_reset_model | ( | Bmicrograph * | mg, |
Bmarker * | model | ||
) |
Resets the model x and y coordinates from the zero-tilt micrograph.
*mg | reference micrograph parameter structure. |
*model | model marker list. |
Missing model markers are added in and excessive model markers deleted.
double mg_tomo_residuals | ( | Bmicrograph * | mg, |
Bmarker * | model, | ||
Vector3< double > | oriref | ||
) |
Calculates the residuals for an alignment solution of one micrograph.
*mg | micrograph. |
*model | model marker list. |
oriref | reference origin. |
Requires the matrices in the micrograph structures to be defined.
int mg_update_model | ( | Bmicrograph * | mg, |
Bmarker * | model, | ||
Vector3< double > | oriref | ||
) |
Fills in missing markers in the 3D model from micrograph markers.
*mg | micrograph to update. |
*model | marker model. |
oriref | reference origin. |
If the marker does not exist in the model, a new one is generated.
int micrograph_clear_extraneous_areas | ( | Bmicrograph * | mg, |
Bimage * | p, | ||
long | thickness, | ||
double | width | ||
) |
Clears extraneous areas from a micrograph.
*mg | micrograph parameter structure. |
*p | micrograph image. |
thickness | intended thickness of reconstruction. |
width | edge smoothing width. |
int project_calculate_angles | ( | Bproject * | project | ) |
Calculates tilt and tilt axis angles from matrices in a project parameter structure.
*project | project parameter structure. |
From each matrix, a quaternion is calculated, giving the tilt axis and rotation angle. The level angle is calculated as the arcsin of the z-coordinate of the axis.
int project_calculate_model | ( | Bproject * | project | ) |
Calculates the z-coordinates of the marker model.
*project | project parameter structure. |
If the project does not have markers, it returns without any change. If the reconstruction model is not defined, it is created.
int project_check_markers | ( | Bproject * | project, |
int | flags | ||
) |
Checks if the markers in a project parameter structure fall within micrographs.
*project | project parameter structure. |
flags | flags to modify actions. |
Markers outside the boundaries are dealt with based on the flags variable: 1 show markers outside the image boundaries. 2 set marker selections to zero. 4 set marker fom's to zero. 8 set marker errors to zero.
int project_clear_extraneous_areas | ( | Bproject * | project, |
long | thickness, | ||
double | width | ||
) |
Clears areas from a tilt series not used in a reconstruction.
*project | project parameter structure. |
thickness | intended thickness of reconstruction. |
width | edge smoothing width. |
long project_count_markers | ( | Bproject * | project | ) |
Counts the markers in a project hierarchy.
*project | project parameter structure. |
Deletes selected markers in a project hierarchy.
*project | project parameter structure. |
&delete_list | list of markers to deselect. |
All the occurrences of selected markers in the tilt series are deleted.
Deletes selected markers in a project hierarchy.
*project | project parameter structure. |
&deselect_list | list of markers to deselect. |
All the occurrences of selected markers in the tilt series are deleted.
int project_erase_markers | ( | Bproject * | project, |
double | marker_radius | ||
) |
Erases or paints markers in micrographs.
*project | project parameter structure. |
marker_radius | radius to mask out markers. |
Markers can be either erased to a background value or painted in with a set value.
long project_find_markers | ( | Bproject * | project, |
long | edge, | ||
int | add | ||
) |
Finds all markers in a project.
*project | project parameter structure. |
edge | edge to exclude. |
add | flag to add rather than replace the markers. |
Markers are located in each micrograph by cross-correlation.
Determines the thickness to mean free path ratio from a tilt series.
*project | project structure. |
*plot | plot structure with intensity-tilt data. |
flag | flag to apply tilt angle adjustment. |
The micrographs should be unmodified gain-corrected images obtained from the detector.
int project_fix_markers | ( | Bproject * | project | ) |
Checks if the markers in a project parameter structure fall within micrographs.
*project | project parameter structure. |
int project_generate_markers | ( | Bproject * | project | ) |
Generates missing micrograph and model markers.
*project | project parameter structure. |
First the 3D model is updated to represent all markers from all micrographs. Then the missing markers in the micrographs are generated from the updated model.
Transfers the micrograph intensities for a field into a plot.
*project | project structure. |
The micrographs should be unmodified gain-corrected images obtained from the detector.
int project_invert_matrices | ( | Bproject * | project | ) |
Inverts the micrograph matrices in a project parameter structure.
*project | project parameter structure. |
The tilt axis angle for all the micrographs are set to the same value.
int project_invert_tilt_axis | ( | Bproject * | project | ) |
Inverts the tilt axis in a project parameter structure.
*project | project parameter structure. |
The tilt axis angle for all the micrographs are set to the same value.
double project_lambda | ( | Bproject * | project, |
double | thickness | ||
) |
Determines the mean free path from a tilt series and thickness.
*project | project structure. |
thickness | tomogram thickness (in angstrom). |
The micrographs should be unmodified gain-corrected images obtained from the detector.
double project_marker_rotation_axis | ( | Bproject * | project | ) |
Determines the most likely rotation axis location for a tilt series.
*project | project parameter structure. |
All micrographs must have associated markers.
int project_mass_normalize | ( | Bproject * | project, |
double | avg, | ||
double | std, | ||
int | norm_type, | ||
DataType | datatype, | ||
int | setinputZslices, | ||
int | setoutputZslices, | ||
double | cutmin, | ||
double | cutmax, | ||
double | replace_threshold | ||
) |
Normalizes a set of images in a project to a desired average and standard deviation.
*project | project structure. |
avg | desired average. |
std | desired standard deviation (if 0, use defaults). |
norm_type | type of determining the effective average and standard deviation: 0=simple, 1=Gaussian, 2=Poisson. |
datatype | data type for normalized images. |
setinputZslices | convert z-slices in the input to 2D images. |
setoutputZslices | convert output image back to z-slices. |
cutmin | truncate to minimum. |
cutmax | truncate to maximum. |
replace_threshold | replace maxima above this threshold. |
The effective average and standard deviation for each image is obtained in one of three ways: 0. The simple avergae and standard devaition for the image. 1. Gaussian fit of the histogram. 2. Poisson fit of the histogram. A histogram of an image is calculated with a given number of bins. The histogram is fit to a Gaussian or Poisson function with exclusion of a small number of bins in the histogram (defined as outliers). The effective average and standard deviation are used to rescale the data for each image.
int project_merge_rec_markers | ( | Bproject * | project | ) |
Merges the markers for two reconstructions.
*project | project parameter structure. |
The reconstructions must have corresponding markers. The marker locations are set to the average of the two. The second reconstruction is removed.
Deselects micrographs in a project hierarchy.
*project | project parameter structure. |
&mg_exclude | list of micrograph numbers. |
int project_mg_marker_select | ( | Bproject * | project, |
double | fom | ||
) |
Selects markers.
*project | project parameter structure. |
fom | fom cutoff. |
Selects all micrograph markers above the given fom cutoff.
Selects micrographs in a project hierarchy.
*project | project parameter structure. |
&mg_select | list of micrograph numbers. |
A micrograph is only selected when it has its selection already set and it is in the list of numbers.
int project_mg_tilt_to_matrix | ( | Bproject * | project | ) |
Sets the matrix from the tilt and axis angles for each micrograph.
*project | project parameter structure. |
This is in preparation for reconstruction.
long project_renumber_markers | ( | Bproject * | project | ) |
Renumbers the markers in a project hierarchy.
*project | project parameter structure. |
The markers are assumed to correspond across micrographs and reconstructions. The existing marker ids are mapped to an array, and new marker ids generated.
int project_set_marker_radius | ( | Bproject * | project, |
double | mark_radius | ||
) |
Sets the marker radius in a project parameter structure.
*project | project parameter structure. |
mark_radius | gold fiducial marker radius (voxels). |
int project_set_tilt_angles | ( | Bproject * | project, |
double | tilt_start, | ||
double | tilt_step | ||
) |
Sets the tilt and tilt axis angles in a project parameter structure.
*project | project parameter structure. |
tilt_start | starting tilt angle (usually negative). |
tilt_step | tilt increment angle. |
The single tilt series is defined by a starting tilt angle and a tilt increment angle, as well as the tilt axis angle.
int project_set_tilt_axis | ( | Bproject * | project, |
double | tilt_axis | ||
) |
Sets the tilt axis angle in a project parameter structure.
*project | project parameter structure. |
tilt_axis | tilt axis angle (wrt x-axis). |
The tilt axis angle for all the micrographs are set to the same value.
long project_show_errors | ( | Bproject * | project, |
double | error_cutoff | ||
) |
Shows the errors in marker coordinates in a project hierarchy.
*project | project parameter structure. |
error_cutoff | threshold to show errors (distance in pixels). |
long project_show_markers | ( | Bproject * | project | ) |
Shows the markers in a project hierarchy.
*project | project parameter structure. |
int project_sort_markers_by_id | ( | Bproject * | project | ) |
Sorts markers for each micrograph by ID number.
*project | micrograph project. |
Requires the matrices in the micrograph structures to be defined.
double project_thickness | ( | Bproject * | project, |
double | lambda | ||
) |
Determines the thickness from a tilt series and mean free path.
*project | project structure. |
lambda | proportionality parameter (in angstrom). |
The micrographs should be unmodified gain-corrected images obtained from the detector.
double project_thickness_to_lambda_ratio | ( | Bproject * | project | ) |
Determines the thickness to mean free path ratio from a tilt series.
*project | project structure. |
The micrographs should be unmodified gain-corrected images obtained from the detector.
double project_tomo_errors | ( | Bproject * | project | ) |
Analyzes marker errors.
*project | micrograph project. |
Requires the marker errors to be calculated.
double project_tomo_residuals | ( | Bproject * | project, |
int | show | ||
) |
Calculates the residuals for an alignment solution.
*project | micrograph project. |
show | flag to indicate showing lists. |
Requires the matrices in the micrograph structures to be defined.
vector< double > simplex_fit_tilt_intensities | ( | vector< double > & | a, |
vector< double > & | I | ||
) |
|
extern |