Bsoft 2.1.4
Bernard's software package
mg_img_proc.h File Reference

Header file for image processing from micrograph structures. More...

#include "mg_processing.h"
#include "rwimg.h"

Functions

Bstring image_type (Bstring type)
 Converts an image type string to a standard form. More...
 
Bprojectproject_create_from_image (Bimage *p, Bstring type)
 Creates a project structure using image file names. More...
 
Bprojectproject_create_from_images (Bstring *file_list, Bstring type)
 Creates a project structure using image file names. More...
 
double micrograph_intensity (Bmicrograph *mg, Bimage *p, int flag)
 Gets the average of a micrograph and sets the dose. More...
 
double micrograph_intensity (Bmicrograph *mg, int flag=0)
 Gets the average of a micrograph and sets the dose. More...
 
int project_mg_avg_intensities (Bproject *project)
 Retrieves the average micrograph intensities. More...
 
int project_catenate_micrographs (Bproject *project)
 Concatenates all micrograph image files into one file. More...
 
Bimageparticle_read_img (Bparticle *part, int readflag)
 Reads a particle image file. More...
 
int particle_write_img (Bparticle *part, Bimage *p, int compression)
 Writes a particle image file. More...
 
int project_check_particles (Bproject *project)
 Checks particle numbers and box sizes. More...
 
Vector3< long > micrograph_get_size (Bmicrograph *mg)
 Gets the size of a micrograph. More...
 
Vector3< double > micrograph_get_nominal_origin (Bmicrograph *mg)
 Gets the nominal origin for a micrograph. More...
 
int project_set_nominal_mg_origins (Bproject *project)
 Sets micrograph origins to the centers of the micrographs. More...
 
int project_reset_origins (Bproject *project)
 Resets particle origins to nominal values. More...
 
int project_set_part_img_origins (Bproject *project)
 Writes particle origins into particle image files. More...
 
long project_delesect_edge_particles (Bproject *project)
 Deselects particles that are too close to the image edges. More...
 
int project_get_part_box_size (Bproject *project)
 Gets the box size from particle image files. More...
 
Vector3< long > particle_get_box_size (Bparticle *part)
 Gets the box size from particle image file. More...
 
int project_write_particle_classes (Bproject *project)
 Writes particles to different stacks based on class. More...
 
int project_trim_class_averages (Bproject *project, Bstring &list)
 Deletes selected class averages from the project.. More...
 
int project_flip_particle_coordinates (Bproject *project, int flip)
 Reverses one or more particle coordinates. More...
 
int project_set_views_from_images (Bproject *project)
 Gets views from particle images. More...
 
int project_set_views_in_images (Bproject *project)
 Sets views in particle images from the project parameter structure. More...
 
int project_bin_micrographs (Bproject *project, int bin, Bstring mgpath, Bstring partpath)
 Bins all micrographs a project. More...
 
int project_change_pixel_size (Bproject *project, Vector3< double > new_pixel_size, Bstring mgpath, Bstring partpath)
 Changes all the micrograph fields linked to the pixel size. More...
 

Detailed Description

Header file for image processing from micrograph structures.

Author
Bernard Heymann
Date
Created: 20000426
Modified: 20210722

Function Documentation

◆ image_type()

Bstring image_type ( Bstring  type)

Converts an image type string to a standard form.

Parameters
typea string with a type definition.
Returns
Bstring standard type definition.
The input string is converted to the following strings:
mg      micrograph
frame   micrograph frames
rec     reconstruction
part    particle
fil     filament
ps      power spectrum
ft      Fourier transform

◆ micrograph_get_nominal_origin()

Vector3< double > micrograph_get_nominal_origin ( Bmicrograph mg)

Gets the nominal origin for a micrograph.

Parameters
*mgmicrograph parameter structure.
Returns
Vector3<double> nominal origin.
The nominal origin is defined as the center of the micrograph.

◆ micrograph_get_size()

Vector3< long > micrograph_get_size ( Bmicrograph mg)

Gets the size of a micrograph.

Parameters
*mgmicrograph parameter structure.
Returns
Vector3<long> size.
The micrograph image header is read.

◆ micrograph_intensity() [1/2]

double micrograph_intensity ( Bmicrograph mg,
Bimage p,
int  flag 
)

Gets the average of a micrograph and sets the dose.

Parameters
*mgmicrograph parameter structure.
*pimage.
flag1=force calculation of statistics of not available; 2=check Poisson
Returns
double intensity.
The micrograph image header is read.

◆ micrograph_intensity() [2/2]

double micrograph_intensity ( Bmicrograph mg,
int  flag 
)

Gets the average of a micrograph and sets the dose.

Parameters
*mgmicrograph parameter structure.
flagflag to force calculation of statistics of not available.
Returns
double intensity.
The micrograph image header is read.

◆ particle_get_box_size()

Vector3< long > particle_get_box_size ( Bparticle part)

Gets the box size from particle image file.

Parameters
*partparticle.
Returns
Vector3<long> box size (0 if image does not exist).
Reads the particle file header and returns the box size.

◆ particle_read_img()

Bimage * particle_read_img ( Bparticle part,
int  readflag 
)

Reads a particle image file.

Parameters
*partparticle.
readflagflag to indicate reading the data.
Returns
Bimage* image (NULL means failure).
The file name is taken from the particle record by preference,
otherwise from the micrograph record.

◆ particle_write_img()

int particle_write_img ( Bparticle part,
Bimage p,
int  compression 
)

Writes a particle image file.

Parameters
*partparticle.
*pimage to be written.
compressionflag to indicate compression.
Returns
int images written.
The file name is taken from the particle record by preference,
otherwise from the micrograph record.

◆ project_bin_micrographs()

int project_bin_micrographs ( Bproject project,
int  bin,
Bstring  mgpath,
Bstring  partpath 
)

Bins all micrographs a project.

Parameters
*projectproject parameter structure.
binbinning value.
mgpathbinned micrograph path (must be allocated).
partpathbinned particle path (must be allocated).
Returns
int 0.
All micrographs in a project are binned by the indicated value.
New micrograph file names are generated with a "_b<n>" insert,
where the n indicates the bin value.
The path to the binned micrograph can be specified.

◆ project_catenate_micrographs()

int project_catenate_micrographs ( Bproject project)

Concatenates all micrograph image files into one file.

Parameters
*projectproject structure.
Returns
int 0.
The new file name is the common part of the original
micrograph file names.

◆ project_change_pixel_size()

int project_change_pixel_size ( Bproject project,
Vector3< double >  new_pixel_size,
Bstring  mgpath,
Bstring  partpath 
)

Changes all the micrograph fields linked to the pixel size.

Parameters
*projectproject parameter structure.
new_pixel_sizenew pixel size.
mgpathbinned micrograph path (must be allocated).
partpathbinned particle path (must be allocated).
Returns
int 0.
The fields linked to pixel size are:
    pixel_size
    shift
    box, bad and marker radii
    particle origins and locations
    bad area and marker locations

◆ project_check_particles()

int project_check_particles ( Bproject project)

Checks particle numbers and box sizes.

Parameters
*projectproject.
Returns
int error code (<0 means failure).
Reads each particle file header, checks the number of particles
and sets the box size for the micrograph.

◆ project_create_from_image()

Bproject * project_create_from_image ( Bimage p,
Bstring  type 
)

Creates a project structure using image file names.

Parameters
*pimage.
typetype of images: mg, frame, rec, part, fil.
Returns
Bproject* new project parameter structure.
The function sets up the project hierarchy from one image base on the type.
If the type is not specified, it is guessed based on the following rules:
    #sub-images = 1
        z=1 => micrograph
        z>1 => reconstruction
    #sub-images > 1
        z=1 => frames
        z>1
            x=y => particles
            x≠y => filaments

◆ project_create_from_images()

Bproject * project_create_from_images ( Bstring file_list,
Bstring  type 
)

Creates a project structure using image file names.

Parameters
*file_listlist of file names.
typetype of images: mg, frame, rec, part, fil.
Returns
Bproject* new project parameter structure.
The function sets up the project hierarchy from a list of file names.
Each file may represent a micrograph or a picked particle file.
If the image is equal or larger than 1024x1024, it is assumed to be
a micrograph, its name will be assigned as a micrograph
file name, and no particle tags will be added.
If the image is smaller than 1024x1024 or the make_part flag is set,
it is taken to be picked particles and the file name will
be assigned as a particle file name.

◆ project_delesect_edge_particles()

long project_delesect_edge_particles ( Bproject project)

Deselects particles that are too close to the image edges.

Parameters
*projectproject.
Returns
long number of particles selected.

◆ project_flip_particle_coordinates()

int project_flip_particle_coordinates ( Bproject project,
int  flip 
)

Reverses one or more particle coordinates.

Parameters
*projectproject parameter structure.
flipaxes to flip.
Returns
int 0.
The specification of axes to flip is embedded in the flip number:
    first bit  - x
    second bit - y
    third bit  - z

◆ project_get_part_box_size()

int project_get_part_box_size ( Bproject project)

Gets the box size from particle image files.

Parameters
*projectproject.
Returns
int error code (<0 means failure).
Reads each particle file header and sets the box size for the micrograph. 

◆ project_mg_avg_intensities()

int project_mg_avg_intensities ( Bproject project)

Retrieves the average micrograph intensities.

Parameters
*projectproject parameter structure.
Returns
int 0.
For each micrograph the FOM is set to the micrograph average.

◆ project_reset_origins()

int project_reset_origins ( Bproject project)

Resets particle origins to nominal values.

Parameters
*projectproject parameter structure.
Returns
int 0.
For each micrograph a particle image header is read and the origin
is set to to the middle of the image.

◆ project_set_nominal_mg_origins()

int project_set_nominal_mg_origins ( Bproject project)

Sets micrograph origins to the centers of the micrographs.

Parameters
*projectproject parameter structure.
Returns
int 0.
For each micrograph the micrograph origin is set to the center.

◆ project_set_part_img_origins()

int project_set_part_img_origins ( Bproject project)

Writes particle origins into particle image files.

Author
D. Belnap
Parameters
*projectproject.
Returns
int error code (<0 means failure).
Sets the origins (offsets from the first voxel) in an image header to
values set within a project.  Rewrites image to file. 

◆ project_set_views_from_images()

int project_set_views_from_images ( Bproject project)

Gets views from particle images.

Parameters
*projectproject parameter structure.
Returns
int 0.

◆ project_set_views_in_images()

int project_set_views_in_images ( Bproject project)

Sets views in particle images from the project parameter structure.

Parameters
*projectproject parameter structure.
Returns
int 0.

◆ project_trim_class_averages()

int project_trim_class_averages ( Bproject project,
Bstring list 
)

Deletes selected class averages from the project..

Parameters
*projectproject parameter structure.
&listselection list.
Returns
int 0.
The new class average file name has an insert of "_del".

◆ project_write_particle_classes()

int project_write_particle_classes ( Bproject project)

Writes particles to different stacks based on class.

Parameters
*projectproject.
Returns
int error code (<0 means failure).
Writes new particle image files, numbered by the selection number.