IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform

Class for sampling a density map from particles. More...

#include <IMP/em/SampledDensityMap.h>

Inheritance diagram for IMP::em::SampledDensityMap:

Detailed Description

Class for sampling a density map from particles.

Definition at line 31 of file SampledDensityMap.h.

Public Member Functions

 SampledDensityMap (const DensityHeader &header, KernelType kt=GAUSSIAN)
 The size of the map is determined by the header and the data is allocated.
 SampledDensityMap (const ParticlesTemp &ps, double resolution, double voxel_size, IMP::FloatKey mass_key=IMP::atom::Mass::get_mass_key(), int sig_cutoff=3, KernelType kt=GAUSSIAN)
 Generate a sampled density map from the particles.
 SampledDensityMap (KernelType kt=GAUSSIAN)
 Creates a new density map for sampled map.
KernelParameters * get_kernel_params ()
float get_minimum_resampled_value ()
 Get minimum density value between voxels that correspond to particles.
const Particles & get_sampled_particles () const
FloatKey get_weight_key () const
const core::XYZRs & get_xyzr_particles () const
void project (const ParticlesTemp &ps, int x_margin, int y_margin, int z_margin, algebra::Vector3D shift=algebra::Vector3D(0., 0., 0.), FloatKey mass_key=atom::Mass::get_mass_key())
 Project particles on the grid by their mass value.
virtual void resample ()
 Resample beads on an EM grid.
void set_particles (const ParticlesTemp &ps, IMP::FloatKey mass_key=IMP::atom::Mass::get_mass_key())
 setting particles in case they were not set by the constructor
void update_resolution (Float res)
 Update the simulation resolution.
Public Member Functions inherited from IMP::em::DensityMap
 DensityMap (const DensityHeader &header, std::string name="DensityMap%1%")
 Construct a density map as instructed in the input header.
 DensityMap (std::string name="DensityMap%1%")
void add (const DensityMap *other)
 Sums two grids; the result is kept in the map.
void add (Float d)
 Add a number to every voxel in the map.
void calc_all_voxel2loc ()
 Calculates the coordinates that correspond to all voxels.
double calcRMS ()
 Calculates RMSD and mean of a map values as stored in the header.
void copy_map (const DensityMap *other)
 Copy map into this map.
algebra::Vector3D get_centroid (double threshold=0.0) const
 Get the centroid of all voxels with density above a given threshold.
DensityMap * get_cropped (const algebra::BoundingBox3D &bb)
 Create and return a new cropped map with the given bounding box extent.
DensityMap * get_cropped (float threshold)
 Create and return a new cropped map.
DensityMap * get_cropped (Particles ps, double distance, bool inverse=false, bool keep_map_dimensions=false)
 Create and return a new cropped map based on particles.
int get_dim_index_by_location (const algebra::Vector3D &v, int ind) const
 Calculate dimension index of a given location.
int get_dim_index_by_location (float loc_val, int ind) const
const DensityHeader * get_header () const
 Returns a read-only pointer to the header of the map.
DensityHeader * get_header_writable ()
 Returns a pointer to the header of the map in a writable version.
algebra::Vector3D get_location_by_voxel (long index) const
 Calculate the location of a given voxel.
float get_location_in_dim_by_voxel (long index, int dim) const
 Calculate the location of a given voxel in a given dimension.
std::string get_locations_string (float t)
 Print the locations of all voxels with value above a given threshold.
double get_max_value () const
 Returns the value of the voxel with the highest density.
float get_maximum_value_in_xy_plane (int z_ind)
 Get the maximum value in a XY plane indicated by a Z index.
float get_maximum_value_in_xz_plane (int y_ind)
 Get the maximum value in a XZ plane indicated by a Y index.
float get_maximum_value_in_yz_plane (int x_ind)
 Get the maximum value in a YZ plane indicated by a X index.
double get_min_value () const
 Returns the value of the voxel with the lowest density.
long get_number_of_voxels () const
 Get the number of map voxels.
algebra::Vector3D get_origin () const
bool get_rms_calculated () const
Float get_spacing () const
 Get the voxel size of the map.
algebra::Vector3D get_top () const
virtual std::string get_type_name () const override
double get_value (const algebra::Vector3D &point) const
double get_value (float x, float y, float z) const
 Gets the value of the voxel located at (x,y,z).
double get_value (long index) const
 Gets the value of the voxel at a given index.
virtual ::IMP::VersionInfo get_version_info () const override
 Get information about the module and version of the object.
long get_voxel_by_location (const algebra::Vector3D &v) const
 Calculate the voxel of a given location.
long get_voxel_by_location (float x, float y, float z) const
 Calculate the voxel of a given location.
bool is_normalized () const
bool is_part_of_volume (const algebra::Vector3D &v) const
 Checks whether a given point is in the grid.
bool is_part_of_volume (float x, float y, float z) const
 Checks whether a given point is in the grid.
bool is_xyz_ind_part_of_volume (int ix, int iy, int iz) const
int lower_voxel_shift (double loc, double kdist, double orig, int ndim) const
void multiply (float factor)
 Multiply in place each voxel in the map by the input factor.
void pad (int nx, int ny, int nz, float val=0.0)
 Increase the dimension of the map.
DensityMap * pad_margin (int mrg_x, int mrg_y, int mrg_z, float val=0.0)
 Create a new padded map.
void pick_max (const DensityMap *other)
 Pick the max value between two corresponding voxels between two maps.
void reset_data (float value=0.0)
 Set the density voxels to some value and reset the management flags.
bool same_dimensions (const DensityMap *other) const
 Checks if two maps have the same dimensions.
bool same_origin (const DensityMap *other) const
 Checks if two maps have the same origin.
bool same_voxel_size (const DensityMap *other) const
 Checks if two maps have the same voxel size.
void set_origin (const IMP::algebra::Vector3D &v)
void set_origin (float x, float y, float z)
 Sets the origin of the header.
void set_value (float x, float y, float z, double value)
 Set the value of the voxel at given coordinates.
void set_value (long index, double value)
 Set the value of the voxel at a given index.
void set_void_map (int nx, int ny, int nz)
 Set the map dimension and reset all voxels to 0.
void std_normalize ()
 Normalize the density voxels according to standard deviation (stdv).
void update_voxel_size (float new_apix)
 Update the voxel size of the map.
int upper_voxel_shift (double loc, double kdist, double orig, int ndim) const
long xyz_ind2voxel (int x, int y, int z) const
 Calculate the voxel of a given xyz index.
Public Member Functions inherited from IMP::Object
CheckLevel get_check_level () const
 get_derived_object (self)
 Return this object cast to the most derived subclass.
LogLevel get_log_level () const
void set_check_level (CheckLevel l)
void set_log_level (LogLevel l)
 Set the logging level used in this object.
const std::string & get_name () const
 Get the (not necessarily unique) name of this object.
void set_name (std::string name)
void set_was_used (bool tf) const
void show (std::ostream &out=std::cout) const
virtual void clear_caches ()

Protected Member Functions

IMP::algebra::BoundingBoxD< 3 > calculate_particles_bounding_box (const Particles &ps)
 Calculate the parameters of the particles bounding box.
void determine_grid_size (double resolution, double voxel_size, int sig_cutoff)
void set_header (const algebra::Vector3D &lower_bound, const algebra::Vector3D &upper_bound, double maxradius, double resolution, double voxel_size, int sig_offset)
void set_neighbor_mask (float radius)
Protected Member Functions inherited from IMP::em::DensityMap
void allocated_data ()
void float2real (float *f_data, boost::scoped_array< double > &r_data)
void real2float (double *r_data, boost::scoped_array< float > &f_data)
void reset_all_voxel2loc ()
void update_header ()
 update the header values – still in work
Protected Member Functions inherited from IMP::Object
 Object (std::string name)
 Construct an object with the given name.
virtual void do_destroy ()

Protected Attributes

KernelParameters kernel_params_
 kernel handling
KernelType kt_
Particles ps_
FloatKey weight_key_
FloatKey x_key_
core::XYZRs xyzr_
FloatKey y_key_
FloatKey z_key_
Protected Attributes inherited from IMP::em::DensityMap
boost::scoped_array< double > data_
bool data_allocated_
DensityHeader header_
bool loc_calculated_
 true if the locations have already been computed
bool normalized_
bool rms_calculated_
boost::scoped_array< float > x_loc_
boost::scoped_array< float > y_loc_
boost::scoped_array< float > z_loc_

Additional Inherited Members

Constructor & Destructor Documentation

◆ SampledDensityMap() [1/3]

IMP::em::SampledDensityMap::SampledDensityMap ( KernelType kt = GAUSSIAN)

Creates a new density map for sampled map.

The header of the map is not determined and no data is being allocated

Definition at line 37 of file SampledDensityMap.h.

◆ SampledDensityMap() [2/3]

IMP::em::SampledDensityMap::SampledDensityMap ( const DensityHeader & header,
KernelType kt = GAUSSIAN )

The size of the map is determined by the header and the data is allocated.

◆ SampledDensityMap() [3/3]

IMP::em::SampledDensityMap::SampledDensityMap ( const ParticlesTemp & ps,
double resolution,
double voxel_size,
IMP::FloatKey mass_key = IMP::atom::Mass::get_mass_key(),
int sig_cutoff = 3,
KernelType kt = GAUSSIAN )

Generate a sampled density map from the particles.

Parameters
[in]psparticles with XYZ, radius and weight attributes
[in]resolutionhalf width the Gaussian
[in]voxel_sizevoxel size in angstroms
[in]mass_keykey to use to weight particles
[in]sig_cutoffChoose what should be the sigma cutoff for accurate sampling. It is used in two functions; (i) to determine the size of the grid dimensions (ii) to determine the voxels around the coords participating in the sampling procedure.
[in]ktType of kernel to use.
Here is the call graph for this function:

Member Function Documentation

◆ calculate_particles_bounding_box()

IMP::algebra::BoundingBoxD< 3 > IMP::em::SampledDensityMap::calculate_particles_bounding_box ( const Particles & ps)
protected

Calculate the parameters of the particles bounding box.

Parameters
[in]psparticles with XYZ, radius and weight attributes
Returns
the particles bounding box

◆ determine_grid_size()

void IMP::em::SampledDensityMap::determine_grid_size ( double resolution,
double voxel_size,
int sig_cutoff )
protected

Determine the size of the grid as a function of the particles and the resolution.

◆ get_kernel_params()

KernelParameters * IMP::em::SampledDensityMap::get_kernel_params ( )

Definition at line 91 of file SampledDensityMap.h.

◆ get_minimum_resampled_value()

float IMP::em::SampledDensityMap::get_minimum_resampled_value ( )

Get minimum density value between voxels that correspond to particles.

◆ get_sampled_particles()

const Particles & IMP::em::SampledDensityMap::get_sampled_particles ( ) const

Definition at line 96 of file SampledDensityMap.h.

◆ get_weight_key()

FloatKey IMP::em::SampledDensityMap::get_weight_key ( ) const

Definition at line 97 of file SampledDensityMap.h.

◆ get_xyzr_particles()

const core::XYZRs & IMP::em::SampledDensityMap::get_xyzr_particles ( ) const

Definition at line 94 of file SampledDensityMap.h.

◆ project()

void IMP::em::SampledDensityMap::project ( const ParticlesTemp & ps,
int x_margin,
int y_margin,
int z_margin,
algebra::Vector3D shift = algebra::Vector3D(0., 0., 0.),
FloatKey mass_key = atom::Mass::get_mass_key() )

Project particles on the grid by their mass value.

Parameters
psthe particles to project
[in]x_marginsampling is restricted to [x_margin,nx-x_margin]
[in]y_marginsampling is restricted to [y_margin,ny-y_margin]
[in]z_marginsampling is restricted to [z_margin,nz-z_margin]
[in]shiftthe positions of all particles are shifted by this value before projection
[in]mass_keykey to obtain particle mass
Here is the call graph for this function:

◆ resample()

virtual void IMP::em::SampledDensityMap::resample ( )
virtual

Resample beads on an EM grid.

Note
The density of a particle p centered at pl at position gl is: \(\frac{{Z}e^{\frac{{-0.5}({p_l}-{g_l})}{\sigma}}}{\sqrt{{2}{\pi}\sigma}}\) , such that \({Z}\) is the weight of the particle and \({\sigma}\) is defined to be \({0.425}\) times the resolution, to follow the 'full width at half maxima' criterion. For more details please refer to Topf et al, Structure, 2008.

Reimplemented in IMP::em::SurfaceShellDensityMap.

◆ set_particles()

void IMP::em::SampledDensityMap::set_particles ( const ParticlesTemp & ps,
IMP::FloatKey mass_key = IMP::atom::Mass::get_mass_key() )

setting particles in case they were not set by the constructor

Here is the call graph for this function:

◆ update_resolution()

void IMP::em::SampledDensityMap::update_resolution ( Float res)

Update the simulation resolution.

Here is the call graph for this function:

Member Data Documentation

◆ kernel_params_

KernelParameters IMP::em::SampledDensityMap::kernel_params_
protected

kernel handling

Definition at line 128 of file SampledDensityMap.h.

◆ kt_

KernelType IMP::em::SampledDensityMap::kt_
protected

Definition at line 134 of file SampledDensityMap.h.

◆ ps_

Particles IMP::em::SampledDensityMap::ps_
protected

Definition at line 130 of file SampledDensityMap.h.

◆ weight_key_

FloatKey IMP::em::SampledDensityMap::weight_key_
protected

Definition at line 132 of file SampledDensityMap.h.

◆ x_key_

FloatKey IMP::em::SampledDensityMap::x_key_
protected

Definition at line 133 of file SampledDensityMap.h.

◆ xyzr_

core::XYZRs IMP::em::SampledDensityMap::xyzr_
protected

Definition at line 131 of file SampledDensityMap.h.

◆ y_key_

FloatKey IMP::em::SampledDensityMap::y_key_
protected

Definition at line 133 of file SampledDensityMap.h.

◆ z_key_

FloatKey IMP::em::SampledDensityMap::z_key_
protected

Definition at line 133 of file SampledDensityMap.h.


The documentation for this class was generated from the following file: