IMP logo
IMP Reference Guide  2.18.0
The Integrative Modeling Platform
SurfaceShellDensityMap.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em/SurfaceShellDensityMap.h
3  * \brief Represent a molecule as shells of distance from the surface
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEM_SURFACE_SHELL_DENSITY_MAP_H
10 #define IMPEM_SURFACE_SHELL_DENSITY_MAP_H
11 
12 #include <IMP/em/em_config.h>
13 #include "exp.h"
14 #include "SampledDensityMap.h"
15 #include "DensityHeader.h"
16 #include "def.h"
17 #include <vector>
18 
19 IMPEM_BEGIN_NAMESPACE
20 
21 #define IMP_DEFAULT_NUM_SHELLS 5
22 #define IMP_SIG_CUTOFF 3
23 
24 //! The class represents a molecule as shells of distance from the surface
25 /**
26  */
27 class IMPEMEXPORT SurfaceShellDensityMap : public SampledDensityMap {
28 #define IMP_BACKGROUND_VAL 0.0
29 #define IMP_SURFACE_VAL 1.0
30  public:
31  //! Creates a new density map.
32  /** The header of the map is not determined and no data is being allocated
33  */
35 
36  //! Creates a new density map.
37  //! The size of the map is determined by the header and the data is allocated.
39 
40  //! Generate a surface shell density map from the input particles.
41  /** \param[in] ps particles with XYZ, radius and weight attributes
42  \param[in] voxel_size the voxel size.
43  \param[in] mass_key key to use to weight particles
44  \param[in] num_shells number of shells
45  \note the voxel size and the number of shells determines
46  the resolution/accuracy of the surface rasterization.
47  */
48  SurfaceShellDensityMap(const ParticlesTemp &ps, float voxel_size,
49  IMP::FloatKey mass_key =
51  int num_shells = IMP_DEFAULT_NUM_SHELLS);
52 
53  //! Resample the grid to consist of density shells of a model
54  /**
55  All voxels that are outside of the model defined by the particles will be
56  set to zero.
57  Voxels on the surface between the model and the background
58  will be set of 1.
59  The interior voxels will be assign value according to their
60  corresponding shell ( the value increases as the voxel is further away
61  from the surface).
62  */
63  void resample() override;
64  //! Set the value of the map voxels as either scene or background
65  /**
66  \param[in] scene_val all voxels corresponding to particles will
67  be set to this value
68  */
69  void binarize(float scene_val);
70 
71  //! Checks if the one of the neighbors of the voxel is a background voxel
72  /**
73  \param[in] voxel_ind the index of the voxel
74  \return true if at least one of the neighbors of the voxel is
75  in the background
76  */
77  bool has_background_neighbor(long voxel_ind) const;
79 
80  protected:
81  //! Finds all of the voxels that are part of the surface
82  //! (i.e, separate background from scene)
83  /**
84  \param[in] shell indexes of all of the surface particles
85  will be stored here.
86  */
87  void set_surface_shell(std::vector<long> *shell);
88  void set_kernel();
89  void set_neighbor_mask();
90  float surface_val_;
91  std::vector<long> neighbor_shift_;
92  std::vector<double> neighbor_dist_;
93  int num_shells_;
94 };
95 
97 IMPEM_END_NAMESPACE
98 
99 #endif /* IMPEM_SURFACE_SHELL_DENSITY_MAP_H */
static FloatKey get_mass_key()
Definitions for EMBED.
DensityMap * binarize(DensityMap *orig_map, float threshold, bool reverse=false)
Return a map with 0 for all voxels below the threshold and 1 for those above.
Metadata for a density file.
virtual void resample()
Resample beads on an EM grid.
#define IMP_REF_COUNTED_DESTRUCTOR(Name)
Ref counted objects should have private destructors.
An approximation of the exponential function.
Class for sampling a density map from particles.
The class represents a molecule as shells of distance from the surface.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
Sampled density map.