![]() |
Bsoft 2.1.4
Bernard's software package
|
Functions for micrograph processing. More...
#include "mg_processing.h"
#include "mg_select.h"
#include "mg_tags.h"
#include "qsort_functions.h"
#include "linked_list.h"
#include "math_util.h"
#include "random_numbers.h"
#include "utilities.h"
#include <fstream>
Functions | |
Bproject * | project_create (int nmg, int nrec) |
Creates a micrograph processing project parameter structure. More... | |
int | project_equal_mg_part_files (Bproject *project) |
Sets micrograph and particle files to be the same. More... | |
Bfield * | field_add (Bfield **field, Bstring &field_id) |
Adds a field-of-view parameter structure to a linked list. More... | |
Bmicrograph * | micrograph_add (Bmicrograph **mg, Bstring &mg_id) |
Adds a micrograph parameter structure to a linked list. More... | |
Bframe * | frame_add (Bframe **frame, int pid) |
Adds a movie frame parameter structure to a linked list. More... | |
Bparticle * | particle_add (Bparticle **part, int pid) |
Adds a particle parameter structure to a linked list. More... | |
int | mg_part_links (Bmicrograph *mg) |
Sets the links from particles to micrographs. More... | |
int | rec_part_links (Breconstruction *rec) |
Sets the links from particles to reconstructions. More... | |
Bparticle * | part_find_first (Bproject *project) |
Finds the first particle in a project. More... | |
Bfilament * | filament_add (Bfilament **fil, int pid) |
Adds a filament parameter structure to a linked list. More... | |
Bfilnode * | filament_node_add (Bfilnode **fnode, int pid) |
Adds a filament node parameter structure to a linked list. More... | |
double | filament_length (Bfilament *fil) |
Calculates the length of a filament. More... | |
Breconstruction * | reconstruction_add (Breconstruction **rec, Bstring &rec_id) |
Adds a reconstruction parameter structure to a linked list. More... | |
int | project_kill (Bproject *project) |
Frees a whole project. More... | |
int | field_kill (Bfield *field) |
Frees a whole field-of-view structure. More... | |
int | micrograph_kill (Bmicrograph *mg) |
Frees a whole micrograph parameter structure. More... | |
int | particle_kill (Bparticle *part) |
Frees a list of particles. More... | |
int | filament_kill (Bfilament *fil) |
Frees a list of filaments. More... | |
int | reconstruction_kill (Breconstruction *rec) |
Frees a whole reconstruction parameter structure. More... | |
Bparticle * | particle_copy (Bparticle **partlist, Bparticle *part) |
Adds one particle onto a list of particle parameters. More... | |
Bparticle * | particle_copy (Bparticle *partlist) |
Copies a list of particle parameters to a new list. More... | |
Bbadarea * | particle_bad_copy (Bbadarea *badlist) |
Bfilament * | filament_copy (Bfilament *fillist) |
Bstrucfac * | structurefactor_copy (Bstrucfac *sflist) |
Blayerline * | layerline_copy (Blayerline *layerlist) |
Bmicrograph * | micrograph_copy (Bmicrograph *mg) |
Copies a micrograph. More... | |
int | project_update (Bproject *project, Bproject *proj_new, int fom_index) |
Updates an existing project with new information. More... | |
int | micrograph_update (Bmicrograph *mg, Bmicrograph *nu_mg, int fom_index, int flags) |
Updates an existing micrograph with new information. More... | |
int | reconstruction_update (Breconstruction *rec, Breconstruction *nu_rec, int fom_index, int flags) |
Updates an existing reconstruction with new information. More... | |
int | particle_update (Bparticle *part, Bparticle *nu_part) |
Updates one existing particle with new information. More... | |
int | particle_update (Bparticle **pnt_part, Bparticle *nu_part, int fom_index) |
Updates an existing particle list with new information. More... | |
int | project_merge_part_parameters (Bproject *project, Bproject *partproject) |
Puts particle parameters from one project into another. More... | |
long | project_set_part_links (Bproject *project) |
Sets the links from particles back to the micrographs and reconstructions. More... | |
long | micrograph_set_part_links (Bmicrograph *mg) |
Sets the links from particles back to the micrograph. More... | |
long | reconstruction_set_part_links (Breconstruction *rec) |
Sets the links from particles back to the reconstruction. More... | |
long | project_divide (Bproject *project, long n) |
Divides a project into a number of micrograph subsets. More... | |
Bmicrograph ** | project_micrograph_array (Bproject *project, long &nmg) |
Sets up an array of selected micrograph pointers. More... | |
Bparticle ** | project_mg_particle_array (Bproject *project, int part_select, long &npart) |
Sets up an array of selected particle pointers. More... | |
Bparticle ** | project_rec_particle_array (Bproject *project, int part_select, long &npart) |
Sets up an array of selected particle pointers. More... | |
Bparticle ** | particle_array (Bparticle *partlist, int part_select, long &npart) |
Sets up an array of selected particle pointers. More... | |
int | project_revert_filenames (Bproject *project, Bproject *project_old, int flag) |
Reverts file names to what it was in an old project. More... | |
int | project_set_field_id (Bproject *project, int nseries, Bstring &field_id) |
Sets the field id's according to a regular series. More... | |
long | project_show_hierarchy (Bproject *project) |
Shows the project hierarchy. More... | |
long | project_show_class_averages (Bproject *project) |
Shows the class averages in a project. More... | |
long | project_dump (Bproject *project, Bstring &filename) |
Dumps particle info in the project hierarchy. More... | |
Bstring | path_update (Bstring &filename, Bstring &path) |
int | project_set_micrograph_path (Bproject *project, Bstring &path) |
Sets the path to micrograph files for all the micrographs. More... | |
int | project_set_frame_path (Bproject *project, Bstring &path) |
Sets the path to micrograph frames files for all the micrographs. More... | |
int | project_set_powerspectrum_path (Bproject *project, Bstring &path) |
Sets the path to powerspectrum files for all the micrographs. More... | |
int | project_set_particle_path (Bproject *project, Bstring &path) |
Sets the path to particle files for all the micrographs. More... | |
int | project_set_filament_path (Bproject *project, Bstring &path) |
Sets the path to filament files for all the micrographs. More... | |
int | project_set_magnification (Bproject *project, double mag) |
Sets the magnification for all the micrographs. More... | |
int | project_set_scan_sampling (Bproject *project, double sampling) |
Sets the scan sampling for all the micrographs. More... | |
int | project_set_mg_pixel_size (Bproject *project, Vector3< double > pixel_size) |
Sets the pixel size for all the micrographs. More... | |
int | project_set_frame_pixel_size (Bproject *project, Vector3< double > pixel_size) |
Sets the pixel size for all the micrograph frames. More... | |
int | project_set_rec_voxel_size (Bproject *project, Vector3< double > pixel_size) |
Sets the pixel size for all the reconstructions. More... | |
int | project_set_part_pixel_size (Bproject *project, Vector3< double > pixel_size) |
Sets the pixel size for all the particles. More... | |
int | project_set_tilt (Bproject *project, double tilt_axis, double tilt_angle) |
Sets the tilt parameters for all the micrographs. More... | |
int | project_set_exposure (Bproject *project, double exposure) |
Sets the aquisition time of all the micrographs. More... | |
int | project_set_dose (Bproject *project, double dose) |
Sets the electron dose of all the micrographs. More... | |
int | project_set_dose (Bproject *project, JSvalue &dose_frac) |
Sets the dose fractionation scheme of all the micrographs. More... | |
int | project_set_micrograph_origins (Bproject *project, Vector3< double > origin) |
Sets micrograph origins to the given origin. More... | |
int | project_add_origins_to_coords (Bproject *project) |
Adds the particle origins to the micrograph coordinates. More... | |
int | project_flip_origins (Bproject *project, int flip) |
Flip origin coordinates. More... | |
long | project_renumber_particles (Bproject *project) |
Renumbers particles. More... | |
int | project_set_particle_box_size (Bproject *project, Vector3< long > box_size) |
Sets particle box size to the given value. More... | |
int | project_set_particle_box_size (Bproject *project, long box_size) |
Sets particle box size to the given value. More... | |
int | project_set_particle_origins (Bproject *project, Vector3< double > origin) |
Sets particle origins to given values. More... | |
int | project_set_particle_asu_views (Bproject *project, Bstring &symmetry_asu) |
Sets particle views within the asymmetric unit. More... | |
int | project_set_particle_asu_views (Bproject *project, Bsymmetry &sym) |
int | project_rotate_particle_views (Bproject *project, View view) |
Rotates particle views with respect to a reference view. More... | |
int | project_apply_map_magnifications (Bproject *project, int mag_num, float *mag) |
Change particle pixel sizes for particles based on map magnifications. More... | |
long | project_reset (Bproject *project, Bstring &reset) |
Reset a particle parameter from its micrograph. More... | |
View * | views_from_project (Bproject *project, int selection) |
Retrieves the particle views from a project. More... | |
Bstring | get_fom_tag (FOMType fom_type) |
Returns the tag associated with a particular FOM. More... | |
Variables | |
int | verbose |
Functions for micrograph processing.
Adds a field-of-view parameter structure to a linked list.
**field | pointer to any field-of-view in the list. |
field_id | field identifier. |
The function allocates memory for a new field-of-view structure. If the content of the pointer is null, the new structure is the first in the list. Otherwise, the end of the list is found and the new structure added to it.
int field_kill | ( | Bfield * | field | ) |
Frees a whole field-of-view structure.
Frees all the structures down the hierarchy.
*field | field-of-view parameter structure. |
Adds a filament parameter structure to a linked list.
**fil | pointer to any filament in the list. |
pid | filament number in file (starts at 1). |
The function allocates memory for a new filament structure. If the content of the pointer is null, the new structure is the first in the list. Otherwise, the end of the list is found and the new structure added to it.
int filament_kill | ( | Bfilament * | fil | ) |
Frees a list of filaments.
Frees all the structures down the hierarchy.
*fil | filament parameter structure. |
double filament_length | ( | Bfilament * | fil | ) |
Calculates the length of a filament.
*fil | pointer to a filament. |
The length is defined as the sum of the link lengths connecting the nodes.
Adds a filament node parameter structure to a linked list.
**fnode | pointer to any filament node in the list. |
pid | filament node number in file (starts at 1). |
The function allocates memory for a new filament node structure. If the content of the pointer is null, the new structure is the first in the list. Otherwise, the end of the list is found and the new structure added to it.
Adds a movie frame parameter structure to a linked list.
**frame | pointer to any frame in the list. |
pid | particle number in file (starts at 1). |
The function allocates memory for a new frame structure. If the content of the pointer is null, the new structure is the first in the list. Otherwise, the end of the list is found and the new structure added to it.
Returns the tag associated with a particular FOM.
fom_type | type of FOM. |
Blayerline * layerline_copy | ( | Blayerline * | layerlist | ) |
int mg_part_links | ( | Bmicrograph * | mg | ) |
Sets the links from particles to micrographs.
*mg | pointer to micrograph. |
Bmicrograph * micrograph_add | ( | Bmicrograph ** | mg, |
Bstring & | mg_id | ||
) |
Adds a micrograph parameter structure to a linked list.
**mg | pointer to any micrograph in the list. |
mg_id | micrograph identifier. |
The function allocates memory for a new micrograph structure. If the content of the pointer is null, the new structure is the first in the list. Otherwise, the end of the list is found and the new structure added to it.
Bmicrograph * micrograph_copy | ( | Bmicrograph * | mg | ) |
Copies a micrograph.
*mg | micrograph structure to be copied. |
int micrograph_kill | ( | Bmicrograph * | mg | ) |
Frees a whole micrograph parameter structure.
Frees all the structures down the hierarchy.
*mg | micrograph parameter structure. |
long micrograph_set_part_links | ( | Bmicrograph * | mg | ) |
Sets the links from particles back to the micrograph.
*mg | micrograph parameter structure. |
int micrograph_update | ( | Bmicrograph * | mg, |
Bmicrograph * | nu_mg, | ||
int | fom_index, | ||
int | flags | ||
) |
Updates an existing micrograph with new information.
*mg | micrograph structure to be updated. |
*nu_mg | micrograph structure with new information. |
fom_index | index of FOM to select on. |
flags | flags indicating which parts to update. |
The new information is encoded as a micrograph structure. All fields are updated if the new fields contain non-default data. Defaults are defined here as zero-length strings or zeroes. The particles in the original micrograph are matched by ID with those in the new micrograph and updated, with any new particles added from the new micrograph. The bad area and marker coordinates are replaced if they exist in the new structure. The new micrograph structure is not modified, except for deletion of bad areas and markers. Flags: 1 particles 2 bad areas 4 filaments 8 structure factors 16 layer lines 32 markers
Finds the first particle in a project.
*project | pointer to project. |
The function searches for the first particle with a filename.
Adds a particle parameter structure to a linked list.
**part | pointer to any particle in the list. |
pid | particle number in file (starts at 1). |
The function allocates memory for a new particle structure. If the content of the pointer is null, the new structure is the first in the list. Otherwise, the end of the list is found and the new structure added to it.
Sets up an array of selected particle pointers.
*partlist | particle linked list. |
part_select | particle selection (-1 if none). |
&npart | array length (modified). |
FOM's of non-selected particles are zeroed.
Adds one particle onto a list of particle parameters.
**partlist | destination particle list. |
*part | particle. |
Copies a list of particle parameters to a new list.
*partlist | source particle list. |
int particle_kill | ( | Bparticle * | part | ) |
Frees a list of particles.
Frees all the structures down the hierarchy.
*part | particle parameter structure. |
Updates an existing particle list with new information.
**pnt_part | particle structure list to be updated. |
*nu_part | particle structure list with new information. |
fom_index | index of FOM to select on. |
The new information is encoded as a particle structure. All fields are updated if the new fields contain non-default data. Defaults are defined here as zeroes. The new particle structure is not modified.
Updates one existing particle with new information.
*part | particle structure to be updated. |
*nu_part | particle structure with new information. |
The new information is encoded as a particle structure. All fields are updated if the new fields contain non-default data. Defaults are defined here as zeroes. The new particle structure is not modified.
int project_add_origins_to_coords | ( | Bproject * | project | ) |
Adds the particle origins to the micrograph coordinates.
*project | project parameter structure. |
The coordinates of particles from a micrograph and particle origins in an image processing parameter structure are added. The old micrograph coordinates are overwritten with the results. Requirement: The box radius for picked particles must be specified.
int project_apply_map_magnifications | ( | Bproject * | project, |
int | mag_num, | ||
float * | mag | ||
) |
Change particle pixel sizes for particles based on map magnifications.
*project | project parameter structure. |
mag_num | number of maps; |
*mag | array of map magnifications. |
Bproject * project_create | ( | int | nmg, |
int | nrec | ||
) |
Creates a micrograph processing project parameter structure.
nmg | number of micrograph structures. |
nrec | number of reconstruction structures. |
The function allocates memory for the project structure, a field-of-view structure, and the requested number of micrographs and reconstructions.
long project_divide | ( | Bproject * | project, |
long | n | ||
) |
Divides a project into a number of micrograph subsets.
*project | project parameter structure. |
n | number of subsets. |
Only selected micrographs are considered in the subdivision.
Dumps particle info in the project hierarchy.
*project | project parameter structure. |
&filename | output file name. |
int project_equal_mg_part_files | ( | Bproject * | project | ) |
Sets micrograph and particle files to be the same.
*project | project parameter structure. |
If the micrograph file name exists, that is used, otherwise the particle file name is used.
int project_flip_origins | ( | Bproject * | project, |
int | flip | ||
) |
Flip origin coordinates.
*project | project parameter structure. |
flip | axes to flip. |
The particle origins are reversed. The specification of axes to flip is embedded in the flip number: first bit - x second bit - y third bit - z
int project_kill | ( | Bproject * | project | ) |
Frees a whole project.
Frees all the structures down the hierarchy.
*project | project parameter structure. |
Puts particle parameters from one project into another.
*project | project parameter structure with all parameters. |
*partproject | project parameter structure with particle parameters. |
Sets up an array of selected particle pointers.
*project | project parameter structure. |
part_select | particle selection (-1 if none). |
&npart | array length (modified). |
FOM's of non-selected particles are zeroed.
Bmicrograph ** project_micrograph_array | ( | Bproject * | project, |
long & | nmg | ||
) |
Sets up an array of selected micrograph pointers.
*project | project parameter structure. |
&nmg | array length (modified). |
FOM's of non-selected micrographs are zeroed.
Sets up an array of selected particle pointers.
*project | project parameter structure. |
part_select | particle selection (-1 if none). |
&npart | array length (modified). |
FOM's of non-selected particles are zeroed.
long project_renumber_particles | ( | Bproject * | project | ) |
Renumbers particles.
*project | project parameter structure. |
For each micrograph the particles are renumbered starting from 1.
Reset a particle parameter from its micrograph.
*project | project parameter structure. |
&reset | a string specifying the parameter. |
Reverts file names to what it was in an old project.
*project | project parameter structure. |
*project_old | project parameter structure with old file names. |
flag | 1=mg, 2=ps, 4=rec, 8=part, 16=frames. |
Rotates particle views with respect to a reference view.
*project | project parameter structure. |
view | reference view. |
int project_set_dose | ( | Bproject * | project, |
double | dose | ||
) |
Sets the electron dose of all the micrographs.
*project | project parameter structure. |
dose | electron dose (e/A2). |
Sets the dose fractionation scheme of all the micrographs.
*project | project parameter structure. |
dose_frac | electron dose fractionation scheme. |
int project_set_exposure | ( | Bproject * | project, |
double | exposure | ||
) |
Sets the aquisition time of all the micrographs.
*project | project parameter structure. |
exposure | aquisition time (seconds). |
Sets the field id's according to a regular series.
The micrograph data blocks must be arranged in a regular order with every nseries micrographs from the same field-of-view. The field id's are taken from the first micrograph id in a series.
*project | project parameter structure. |
nseries | number of micrographs per field-of-view. |
&field_id | a user-specified field ID. |
Sets the path to filament files for all the micrographs.
*project | project parameter structure. |
&path | path to filament files. |
If the requested path is "." or "./", the path is completely removed.
Sets the path to micrograph frames files for all the micrographs.
*project | project parameter structure. |
&path | path to micrograph frames files. |
If the requested path is "." or "./", the path is completely removed.
Sets the pixel size for all the micrograph frames.
*project | project parameter structure. |
pixel_size | pixel size. |
int project_set_magnification | ( | Bproject * | project, |
double | mag | ||
) |
Sets the magnification for all the micrographs.
*project | project parameter structure. |
mag | magnification. |
Sets the pixel size for all the micrographs.
*project | project parameter structure. |
pixel_size | pixel size. |
Sets micrograph origins to the given origin.
*project | project parameter structure. |
origin | particle origin. |
For each micrograph the micrograph origin is set to the given origin.
Sets the path to micrograph files for all the micrographs.
*project | project parameter structure. |
&path | path to micrograph files. |
If the requested path is "." or "./", the path is completely removed.
long project_set_part_links | ( | Bproject * | project | ) |
Sets the links from particles back to the micrographs and reconstructions.
*project | project parameter structure. |
Sets the pixel size for all the particles.
*project | project parameter structure. |
pixel_size | pixel size. |
Sets particle views within the asymmetric unit.
*project | project parameter structure. |
&symmetry_asu | point group string. |
For each micrograph or reconstruction the particle view is set to within the asymmetric unit.
int project_set_particle_box_size | ( | Bproject * | project, |
long | box_size | ||
) |
Sets particle box size to the given value.
*project | project parameter structure. |
box_size | particle box size. |
For each micrograph or reconstruction the particle box size is set to the given radius and the particle origins are adjusted as well.
Sets particle box size to the given value.
*project | project parameter structure. |
box_size | particle box size. |
For each micrograph or reconstruction the particle box size is set to the given radius and the particle origins are adjusted as well.
Sets particle origins to given values.
*project | project parameter structure. |
origin | particle origin. |
For each micrograph or reconstruction the particle origin is set to the given origin.
Sets the path to particle files for all the micrographs.
*project | project parameter structure. |
&path | path to particle files. |
If the requested path is "." or "./", the path is completely removed.
Sets the path to powerspectrum files for all the micrographs.
*project | project parameter structure. |
&path | path to powerspectrum files. |
If the requested path is "." or "./", the path is completely removed.
Sets the pixel size for all the reconstructions.
*project | project parameter structure. |
pixel_size | pixel size. |
int project_set_scan_sampling | ( | Bproject * | project, |
double | sampling | ||
) |
Sets the scan sampling for all the micrographs.
*project | project parameter structure. |
sampling | sampling. |
Sampling is isotropic.
int project_set_tilt | ( | Bproject * | project, |
double | tilt_axis, | ||
double | tilt_angle | ||
) |
Sets the tilt parameters for all the micrographs.
*project | project parameter structure. |
tilt_axis | micrograph tilt axis angle. |
tilt_angle | micrograph tilt angle. |
long project_show_class_averages | ( | Bproject * | project | ) |
Shows the class averages in a project.
*project | project parameter structure. |
long project_show_hierarchy | ( | Bproject * | project | ) |
Shows the project hierarchy.
*project | project parameter structure. |
Updates an existing project with new information.
*project | project parameter structure to be updated. |
*proj_new | project parameter structure with new information. |
fom_index | index of FOM to select on. |
The new information is encoded as a project hierarchy. The original project hierarchy is searched for the micrograph ID tags that correspond to the original project hierarchy and those micrograph parameters are updated. Because the micrograph ID tags should be unique in themselves, the field ID tags are ignored and the two project hierarchies may have different field designations. If a micrograph ID from the new project hierarchy is not found in the original project hierarchy, it is added. The new project hierarchy is not modified.
int rec_part_links | ( | Breconstruction * | rec | ) |
Sets the links from particles to reconstructions.
*rec | pointer to reconstruction. |
Breconstruction * reconstruction_add | ( | Breconstruction ** | rec, |
Bstring & | rec_id | ||
) |
Adds a reconstruction parameter structure to a linked list.
**rec | pointer to any reconstruction in the list. |
&rec_id | reconstruction identifier. |
The function allocates memory for a new micrograph structure. If the content of the pointer is null, the new structure is the first in the list. Otherwise, the end of the list is found and the new structure added to it.
int reconstruction_kill | ( | Breconstruction * | rec | ) |
Frees a whole reconstruction parameter structure.
Frees all the structures down the hierarchy.
*rec | reconstruction parameter structure. |
long reconstruction_set_part_links | ( | Breconstruction * | rec | ) |
Sets the links from particles back to the reconstruction.
*rec | reconstruction parameter structure. |
int reconstruction_update | ( | Breconstruction * | rec, |
Breconstruction * | nu_rec, | ||
int | fom_index, | ||
int | flags | ||
) |
Updates an existing reconstruction with new information.
*rec | reconstruction structure to be updated. |
*nu_rec | reconstruction structure with new information. |
fom_index | index of FOM to select on. |
flags | flags indicating which parts to update. |
The new information is encoded as a reconstruction structure. The update is only done if the FOM of the new reconstruction is better. All fields are updated if the new fields contain non-default data. Defaults are defined here as zero-length strings or zeroes. The particles in the original reconstruction are matched by ID with those in the new reconstruction and updated, with any new particles added from the new reconstruction. The bad area and marker coordinates are replaced if they exist in the new structure. The new reconstruction structure is not modified, except for deletion of bad areas and markers.
Retrieves the particle views from a project.
*project | project parameter structure. |
selection | selection number (-1 selects positives, 0 selects all). |
|
extern |