IMP Reference Guide
develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
|
Class to search path on grids. More...
#include <IMP/bff/PathMap.h>
Public Member Functions | |
PathMap (PathMapHeader &header, std::string name="PathMap%1%", IMP::em::KernelType kt=IMP::em::BINARIZED_SPHERE, float resolution=-1.0) | |
Constructs a PathMap object. More... | |
void | fill_sphere (IMP::algebra::Vector3D r0, double radius, double value, bool inverse=true) |
Change the value of a density inside or outside of a sphere. More... | |
void | find_path (long path_begin_idx, long path_end_idx=-1, int heuristic_mode=0) |
Finds a path between two indices in the path map. More... | |
void | find_path_astar (long path_begin_idx, long path_end_idx=-1) |
Finds the shortest path between two indices using the A* algorithm. More... | |
void | find_path_dijkstra (long path_begin_idx, long path_end_idx=-1) |
Finds the shortest path between two nodes using Dijkstra's algorithm. More... | |
int | get_dim_index_by_voxel (long index, int dim) |
Get index of voxel in an axis. More... | |
std::vector< int > | get_neighbor_idx_offsets (double neighbor_radius=-1) |
const PathMapHeader * | get_path_map_header () const |
Returns a read-only pointer to the header of the map. More... | |
PathMapHeader * | get_path_map_header_writable () |
Returns a pointer to the header of the map in a writable version. More... | |
void | get_tile_values (float **output, int *nx, int *ny, int *nz, int value_type=PM_TILE_COST, std::pair< float, float > bounds=std::pair< float, float >({std::numeric_limits< float >::min(), std::numeric_limits< float >::max()}), const std::string &feature_name="") |
Retrieves the values of the tiles in the path map. More... | |
std::vector< PathMapTile > & | get_tiles () |
std::vector < IMP::algebra::Vector4D > | get_xyz_density () |
Get the XYZ density of the path map. This function returns a vector of IMP::algebra::Vector4D objects representing the XYZ density of the path map. More... | |
void | get_xyz_density (double **output, int *n_output1, int *n_output2) |
Get the XYZ density of the path map. This function returns the XYZ density of the path map as a 2D array. More... | |
void | resize (unsigned int nvox) |
Resizes the PathMap object. More... | |
void | sample_obstacles (double extra_radius=0.0) |
Resamples the obstacles in the path map. More... | |
void | set_data (double *input, int n_input, float obstacle_threshold=-1, bool binarize=true, float obstacle_penalty=TILE_PENALTY_DEFAULT) |
Sets the data for the path map. More... | |
void | set_path_map_header (PathMapHeader &path_map_header, float resolution=-1.0) |
Set the path map header. More... | |
void | update_tiles (float obstacle_threshold=-1.0, bool binarize=true, float obstacle_penalty=TILE_PENALTY_DEFAULT, bool reset_tile_edges=true) |
Updates the tiles in the path map. More... | |
Public Member Functions inherited from IMP::em::SampledDensityMap | |
SampledDensityMap (KernelType kt=GAUSSIAN) | |
Creates a new density map for sampled map. More... | |
SampledDensityMap (const DensityHeader &header, KernelType kt=GAUSSIAN) | |
The size of the map is determined by the header and the data is allocated. More... | |
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. More... | |
KernelParameters * | get_kernel_params () |
float | get_minimum_resampled_value () |
Get minimum density value between voxels that correspond to particles. More... | |
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. More... | |
virtual void | resample () |
Resample beads on an EM grid. More... | |
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 More... | |
void | update_resolution (Float res) |
Update the simulation resolution. More... | |
Public Member Functions inherited from IMP::em::DensityMap | |
DensityMap (std::string name="DensityMap%1%") | |
DensityMap (const DensityHeader &header, std::string name="DensityMap%1%") | |
Construct a density map as instructed in the input header. More... | |
void | add (const DensityMap *other) |
Sums two grids; the result is kept in the map. More... | |
void | add (Float d) |
Add a number to every voxel in the map. More... | |
void | calc_all_voxel2loc () |
Calculates the coordinates that correspond to all voxels. More... | |
double | calcRMS () |
Calculates RMSD and mean of a map values as stored in the header. More... | |
void | copy_map (const DensityMap *other) |
Copy map into this map. More... | |
algebra::Vector3D | get_centroid (double threshold=0.0) const |
Get the centroid of all voxels with density above a given threshold. More... | |
DensityMap * | get_cropped (float threshold) |
Create and return a new cropped map. More... | |
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. More... | |
DensityMap * | get_cropped (const algebra::BoundingBox3D &bb) |
Create and return a new cropped map with the given bounding box extent. More... | |
int | get_dim_index_by_location (const algebra::Vector3D &v, int ind) const |
Calculate dimension index of a given location. More... | |
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. More... | |
DensityHeader * | get_header_writable () |
Returns a pointer to the header of the map in a writable version. More... | |
algebra::Vector3D | get_location_by_voxel (long index) const |
Calculate the location of a given voxel. More... | |
float | get_location_in_dim_by_voxel (long index, int dim) const |
Calculate the location of a given voxel in a given dimension. More... | |
std::string | get_locations_string (float t) |
Print the locations of all voxels with value above a given threshold. More... | |
double | get_max_value () const |
Returns the value of the voxel with the highest density. More... | |
float | get_maximum_value_in_xy_plane (int z_ind) |
Get the maximum value in a XY plane indicated by a Z index. More... | |
float | get_maximum_value_in_xz_plane (int y_ind) |
Get the maximum value in a XZ plane indicated by a Y index. More... | |
float | get_maximum_value_in_yz_plane (int x_ind) |
Get the maximum value in a YZ plane indicated by a X index. More... | |
double | get_min_value () const |
Returns the value of the voxel with the lowest density. More... | |
long | get_number_of_voxels () const |
Get the number of map voxels. More... | |
algebra::Vector3D | get_origin () const |
bool | get_rms_calculated () const |
Float | get_spacing () const |
Get the voxel size of the map. More... | |
algebra::Vector3D | get_top () const |
virtual std::string | get_type_name () const override |
double | get_value (float x, float y, float z) const |
Gets the value of the voxel located at (x,y,z) More... | |
double | get_value (const algebra::Vector3D &point) const |
double | get_value (long index) const |
Gets the value of the voxel at a given index. More... | |
virtual ::IMP::VersionInfo | get_version_info () const override |
Get information about the module and version of the object. More... | |
long | get_voxel_by_location (float x, float y, float z) const |
Calculate the voxel of a given location. More... | |
long | get_voxel_by_location (const algebra::Vector3D &v) const |
Calculate the voxel of a given location. More... | |
bool | is_normalized () const |
bool | is_part_of_volume (float x, float y, float z) const |
Checks whether a given point is in the grid. More... | |
bool | is_part_of_volume (const algebra::Vector3D &v) const |
Checks whether a given point is in the grid. More... | |
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. More... | |
void | pad (int nx, int ny, int nz, float val=0.0) |
Increase the dimension of the map. More... | |
DensityMap * | pad_margin (int mrg_x, int mrg_y, int mrg_z, float val=0.0) |
Create a new padded map. More... | |
void | pick_max (const DensityMap *other) |
Pick the max value between two corresponding voxels between two maps. More... | |
void | reset_data (float value=0.0) |
Set the density voxels to some value and reset the management flags. More... | |
bool | same_dimensions (const DensityMap *other) const |
Checks if two maps have the same dimensions. More... | |
bool | same_origin (const DensityMap *other) const |
Checks if two maps have the same origin. More... | |
bool | same_voxel_size (const DensityMap *other) const |
Checks if two maps have the same voxel size. More... | |
void | set_origin (float x, float y, float z) |
Sets the origin of the header. More... | |
void | set_origin (const IMP::algebra::Vector3D &v) |
void | set_value (long index, double value) |
Set the value of the voxel at a given index. More... | |
void | set_value (float x, float y, float z, double value) |
Set the value of the voxel at given coordinates. More... | |
void | set_void_map (int nx, int ny, int nz) |
Set the map dimension and reset all voxels to 0. More... | |
void | std_normalize () |
Normalize the density voxels according to standard deviation (stdv). More... | |
void | update_voxel_size (float new_apix) |
Update the voxel size of the map. More... | |
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. More... | |
Public Member Functions inherited from IMP::Object | |
virtual void | clear_caches () |
CheckLevel | get_check_level () const |
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. More... | |
void | set_was_used (bool tf) const |
void | show (std::ostream &out=std::cout) const |
const std::string & | get_name () const |
void | set_name (std::string name) |
Protected Member Functions | |
std::vector< PathMapTileEdge > & | get_edges (int tile_idx) |
Protected Member Functions inherited from IMP::em::SampledDensityMap | |
IMP::algebra::BoundingBoxD< 3 > | calculate_particles_bounding_box (const Particles &ps) |
Calculate the parameters of the particles bounding box. More... | |
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 More... | |
Protected Member Functions inherited from IMP::Object | |
Object (std::string name) | |
Construct an object with the given name. More... | |
virtual void | do_destroy () |
Protected Attributes | |
std::vector< int > | offsets_ |
PathMapHeader | pathMapHeader_ |
std::vector< PathMapTile > | tiles |
Protected Attributes inherited from IMP::em::SampledDensityMap | |
KernelParameters | kernel_params_ |
kernel handling More... | |
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 More... | |
bool | normalized_ |
bool | rms_calculated_ |
boost::scoped_array< float > | x_loc_ |
boost::scoped_array< float > | y_loc_ |
boost::scoped_array< float > | z_loc_ |
Related Functions | |
(Note that these are not member functions.) | |
std::vector< float > | get_tile_values (int value_type=PM_TILE_COST, std::pair< float, float > bounds=std::pair< float, float >({std::numeric_limits< float >::min(), std::numeric_limits< float >::max()}), const std::string &feature_name="") |
Get the values of all tiles. More... | |
Related Functions inherited from IMP::em::DensityMap | |
void | add_to_map (DensityMap *dm, const Particles &pis) |
Rasterize the particles into an existing density map. More... | |
DensityMap * | create_density_map (algebra::DenseGrid3D< float > &grid) |
Return a density map with the values taken from the grid. More... | |
DensityMap * | create_density_map (algebra::DenseGrid3D< double > &grid) |
Return a density map with the values taken from the grid. More... | |
DensityMap * | get_binarized_interior (DensityMap *dmap) |
Return a binarized map with 1 for voxels that are internal in the input map. More... | |
double | get_density (const DensityMap *m, const algebra::Vector3D &v) |
Get density value at point v, interpolating linearly from the sample values. More... | |
DensityMap * | get_resampled (DensityMap *input, double scaling) |
Get a resampled version of the map. More... | |
DensityMap * | get_transformed (const DensityMap *input, const algebra::Transformation3D &tr, double threshold) |
Return a new density map containing a rotated version of the old one. More... | |
DensityMap * | get_transformed (DensityMap *input, const algebra::Transformation3D &tr) |
Return a new density map containing a rotated version of the old one. More... | |
void | get_transformed_into (const DensityMap *source, const algebra::Transformation3D &tr, DensityMap *into, bool calc_rms=true) |
Rotate a density map into another map. More... | |
DensityMap * | read_map (std::string filename, MapReaderWriter *reader) |
Read a density map from a file (using the given reader) and return it. More... | |
DensityMap * | read_map (std::string filename) |
Read a density map from a file and return it. More... | |
void | write_map (DensityMap *m, std::string filename, MapReaderWriter *writer) |
Write a density map to a file using the given writer. More... | |
void | write_map (DensityMap *m, std::string filename) |
Write a density map to a file. More... | |
|
explicit |
Constructs a PathMap object.
header | The PathMapHeader object. |
name | The name of the PathMap. |
kt | The kernel type. |
resolution | The resolution of the PathMap. |
void IMP::bff::PathMap::fill_sphere | ( | IMP::algebra::Vector3D | r0, |
double | radius, | ||
double | value, | ||
bool | inverse = true |
||
) |
Change the value of a density inside or outside of a sphere.
Changes the value of the density inside or outside of a sphere. The density is used in the path-search (i.e., the accessible volume calculation
r0 | location of the sphere |
radius | radius of the sphere |
value | value inside or outside of the sphere |
inverse | if set to true (default) the values outside of the sphere are modified. If false the values inside of the sphere are modified. |
void IMP::bff::PathMap::find_path | ( | long | path_begin_idx, |
long | path_end_idx = -1 , |
||
int | heuristic_mode = 0 |
||
) |
Finds a path between two indices in the path map.
This function finds a path between the specified path begin index and path end index in the path map. If the path end index is not specified, the function will find a path from the path begin index to the last index in the path map. The heuristic mode parameter determines the heuristic function to be used for path finding.
path_begin_idx | The index of the path begin point in the path map. |
path_end_idx | The index of the path end point in the path map. Default value is -1, which means the last index in the path map. |
heuristic_mode | The mode of the heuristic function to be used for path finding. Default value is 0. |
void IMP::bff::PathMap::find_path_astar | ( | long | path_begin_idx, |
long | path_end_idx = -1 |
||
) |
Finds the shortest path between two indices using the A* algorithm.
This function uses the A* algorithm to find the shortest path between two indices in the path map. The path is stored in the path member variable.
path_begin_idx | The index of the starting point of the path. |
path_end_idx | The index of the ending point of the path. If not provided, the function will use the last index in the path map. |
void IMP::bff::PathMap::find_path_dijkstra | ( | long | path_begin_idx, |
long | path_end_idx = -1 |
||
) |
Finds the shortest path between two nodes using Dijkstra's algorithm.
This function finds the shortest path between two nodes in the path map using Dijkstra's algorithm. The path is calculated from the node at index path_begin_idx to the node at index path_end_idx. If path_end_idx is not provided, the function will calculate the path to the last node in the map.
path_begin_idx | The index of the starting node. |
path_end_idx | The index of the ending node (optional). |
int IMP::bff::PathMap::get_dim_index_by_voxel | ( | long | index, |
int | dim | ||
) |
Get index of voxel in an axis.
Returns the index of a voxel on a grid in a certain dimension.
index | voxel index |
dim | dimension |
std::vector<int> IMP::bff::PathMap::get_neighbor_idx_offsets | ( | double | neighbor_radius = -1 | ) |
Returns a vector of neighbor index offsets within a given radius.
neighbor_radius | The radius within which to find neighbors. If negative, the radius is obtained from the path map header. |
Definition at line 121 of file PathMap.h.
const PathMapHeader* IMP::bff::PathMap::get_path_map_header | ( | ) | const |
PathMapHeader* IMP::bff::PathMap::get_path_map_header_writable | ( | ) |
void IMP::bff::PathMap::get_tile_values | ( | float ** | output, |
int * | nx, | ||
int * | ny, | ||
int * | nz, | ||
int | value_type = PM_TILE_COST , |
||
std::pair< float, float > | bounds = std::pair< float, float >({std::numeric_limits< float >::min(), std::numeric_limits< float >::max()}) , |
||
const std::string & | feature_name = "" |
||
) |
Retrieves the values of the tiles in the path map.
This function retrieves the values of the tiles in the path map and stores them in the output array.
output | A pointer to a 2D array of floats where the tile values will be stored. |
nx | A pointer to an integer that will store the number of tiles in the x-direction. |
ny | A pointer to an integer that will store the number of tiles in the y-direction. |
nz | A pointer to an integer that will store the number of tiles in the z-direction. |
value_type | The type of value to retrieve for each tile. Defaults to PM_TILE_COST. |
bounds | A pair of floats representing the lower and upper bounds for the tile values. Defaults to the minimum and maximum float values. |
feature_name | The name of the feature for which to retrieve the tile values. Defaults to an empty string. |
std::vector<PathMapTile>& IMP::bff::PathMap::get_tiles | ( | ) |
Values of tiles
std::vector<IMP::algebra::Vector4D> IMP::bff::PathMap::get_xyz_density | ( | ) |
Get the XYZ density of the path map. This function returns a vector of IMP::algebra::Vector4D objects representing the XYZ density of the path map.
void IMP::bff::PathMap::get_xyz_density | ( | double ** | output, |
int * | n_output1, | ||
int * | n_output2 | ||
) |
Get the XYZ density of the path map. This function returns the XYZ density of the path map as a 2D array.
output | A pointer to a 2D array to store the XYZ density. |
n_output1 | A pointer to an integer to store the number of rows in the output array. |
n_output2 | A pointer to an integer to store the number of columns in the output array. |
void IMP::bff::PathMap::resize | ( | unsigned int | nvox | ) |
void IMP::bff::PathMap::sample_obstacles | ( | double | extra_radius = 0.0 | ) |
Resamples the obstacles in the path map.
This function resamples the obstacles in the path map, updating their positions and sizes.
extra_radius | The extra radius to add to the obstacles (optional, default is 0.0). |
void IMP::bff::PathMap::set_data | ( | double * | input, |
int | n_input, | ||
float | obstacle_threshold = -1 , |
||
bool | binarize = true , |
||
float | obstacle_penalty = TILE_PENALTY_DEFAULT |
||
) |
Sets the data for the path map.
This function sets the input data for the path map. The input data is a 1D array of doubles representing the map.
input | Pointer to the input data array. |
n_input | Number of elements in the input data array. |
obstacle_threshold | The threshold value for considering a cell as an obstacle. Default value is -1. |
binarize | Flag indicating whether to binarize the input data. Default value is true. |
obstacle_penalty | The penalty value for obstacle cells. Default value is TILE_PENALTY_DEFAULT. |
void IMP::bff::PathMap::set_path_map_header | ( | PathMapHeader & | path_map_header, |
float | resolution = -1.0 |
||
) |
Set the path map header.
This function sets the path map header for the path map.
path_map_header | The path map header to set. |
resolution | The resolution of the path map. Default value is -1.0. |
void IMP::bff::PathMap::update_tiles | ( | float | obstacle_threshold = -1.0 , |
bool | binarize = true , |
||
float | obstacle_penalty = TILE_PENALTY_DEFAULT , |
||
bool | reset_tile_edges = true |
||
) |
Updates the tiles in the path map.
This function updates the tiles in the path map based on the given parameters.
obstacle_threshold | The threshold value for considering a cell as an obstacle. Default value is -1.0. |
binarize | A flag indicating whether to binarize the path map. Default value is true. |
obstacle_penalty | The penalty value for obstacle cells. Default value is TILE_PENALTY_DEFAULT. |
reset_tile_edges | A flag indicating whether to reset the edges of the tiles. Default value is true. |
|
related |
Get the values of all tiles.
A tile in a path map contains information on the penalty for visiting a tile, the cost of a path from the origin of a path search to the tile, the density of the tile, and other user-defined information.
When getting information from a tile, the returned values can be cropped to a specified range.
value_type | Specifies the type of the returned information (see: PathMapTileOutputs). Depending on the value type, the output can be the penalty for visiting the tile, the total cost of a path to the tile, or the density of the tile. Additional user-defined content can also be accessed. |
bounds | Bound for cropping the output values. |
feature_name | Name of a feature when accessing additional information. |