A.I.M.S


graphmanip.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef AIMS_GRAPH_GRAPHMANIP_H
35 #define AIMS_GRAPH_GRAPHMANIP_H
36 
37 #include <aims/rgb/rgb.h>
39 #include <cartobase/type/types.h>
41 
42 class Graph;
43 class GraphObject;
44 namespace aims
45 {
46 class AffineTransformation3d;
47 }
49 class Void;
50 template<typename T> class AimsData;
51 
52 namespace aims
53 {
54 
55  template<typename T> class BucketMap;
56 
65  {
67  {
71  };
72 
75  GraphElementCode( const std::string & attrib, const std::string & ot,
76  const std::string & dt, StorageType st );
78 
80  std::string id;
84  std::string attribute;
86  std::string objectType;
88  std::string dataType;
90  std::string local_file_attribute;
92  std::string global_filename;
93  std::string global_attribute;
95  std::string syntax;
96  };
97 
100  typedef std::map<std::string, std::map<std::string,GraphElementCode> >
102 
103 
104  namespace DataManip
105  {
106 
109  template <typename T> void adjustVoxelSize( T &, const T & );
110 
113  template <typename T>
114  void insertElement( T & dest, int index, const T & src );
115  template <typename T>
116  carto::PropertySet & getHeader( T & obj );
117  template <typename T>
118  void setHeaderInfo( T & obj, const carto::GenericObject & srcheader );
119  }
120 
121 
124  {
125  public:
126  typedef BucketMap<Void>*
127  (*CreateBucketFunc)( GraphObject*, const std::string & );
128 
130  static Motion talairach( const Graph & g );
132  static void storeTalairach( Graph & g, const Motion & m );
137  static bool buckets2Volume( Graph & g );
142  static bool volume2Buckets( Graph & g, CreateBucketFunc f = 0 );
143  static GraphElementCode &
144  graphElementCode( Graph &, const std::string & syntax,
145  const std::string & id );
146  static GraphElementCode &
147  graphElementCodeByAtt( Graph &, const std::string & syntax,
148  const std::string & attrib );
154  template<typename T>
155  static void storeAims( Graph & graph, GraphObject* vertex,
156  const std::string & attribute,
157  carto::rc_ptr<T> obj );
159  template <typename T>
160  static Graph* graphFromVolume( const AimsData<T> & vol,
161  T background = 0,
162  std::map<T, std::string> *trans = 0 );
164  template <typename T>
165  static void graphFromVolume( const AimsData<T> & vol , Graph & g,
166  T background = 0,
167  std::map<T,std::string> *trans = 0,
168  bool automaticBackgroundSearch = true );
169  static void setAttributeColor( Graph & graph, const std::string & att,
170  const AimsRGB & );
171  static void setAttributeColor( Graph & graph, const std::string & att,
172  const AimsRGBA & );
173  static void setAttributeColor( Graph & graph, const std::string & att,
174  const std::vector<int> & );
175  std::vector<int> attributeColor( const Graph & graph,
176  const std::string & att );
180  static void completeGraph( Graph & );
181 
182  //Merge two graph
183  //If they contain some mesh, they can be
184  //either merged
185  //or just copied
186  //invNormal enable to inverse the mesh normal
187  static Graph* mergeGraph( const std::string &, Graph &, Graph &,
188  bool mergeMesh = true, bool invNormal = false);
189  static void printGraphElementTable( const Graph &,
190  std::ostream & ostr = std::cout );
191  static std::string
192  defaultExtensionForObjectType( const std::string & otype,
193  const std::string & dtype );
194  };
195 
196 }
197 
198 
199 namespace carto
200 {
201 
202  template<> inline
204  {
205  return "GraphElementCode";
206  }
207 
208 #define _TMP_ rc_ptr<std::map<std::string,std::map<std::string,aims::GraphElementCode> > >
210 #undef _TMP_
211 
212 } // namespace carto
213 
214 #endif
215 
#define DECLARE_GENERIC_OBJECT_TYPE(T)
static GraphElementCode & graphElementCodeByAtt(Graph &, const std::string &syntax, const std::string &attrib)
std::vector< int > attributeColor(const Graph &graph, const std::string &att)
std::string dataType()
carto::PropertySet & getHeader(T &obj)
BucketMap< Void > *(* CreateBucketFunc)(GraphObject *, const std::string &)
Definition: graphmanip.h:127
std::string local_file_attribute
Definition: graphmanip.h:90
StorageType storageType
Definition: graphmanip.h:89
std::string syntax
syntactic attribute of attributed objects
Definition: graphmanip.h:95
std::string dataType
data type as in Aims Finder: "S16", "U8", "FLOAT", ...
Definition: graphmanip.h:88
std::map< std::string, std::map< std::string, GraphElementCode > > GraphElementTable
GraphElementCode table, stored in graphs in attribute "aims_objects_table" (carto::rc_ptr
Definition: graphmanip.h:101
Describe how Aims objects are stored in graph objects.
Definition: graphmanip.h:64
std::string global_index_attribute
Definition: graphmanip.h:91
GraphElementCode & operator=(const GraphElementCode &x)
std::string attribute
attribute found in graph objects, this attribute is a reference-counting pointer (carto::rc_ptr) t...
Definition: graphmanip.h:84
static Graph * mergeGraph(const std::string &, Graph &, Graph &, bool mergeMesh=true, bool invNormal=false)
#define _TMP_
Definition: graphmanip.h:208
std::string global_attribute
Definition: graphmanip.h:93
static bool volume2Buckets(Graph &g, CreateBucketFunc f=0)
converts internal representations of graph nodes from volume to buckets.
std::string objectType
object type as in aims Finder: "Volume", "Bucket", "Mesh", ...
Definition: graphmanip.h:86
aims::AffineTransformation3d Motion
Definition: graphmanip.h:48
static Motion talairach(const Graph &g)
extract Talairach transformation (graph -> Talairach)
static Graph * graphFromVolume(const AimsData< T > &vol, T background=0, std::map< T, std::string > *trans=0)
builds a ROI graph from a volume of labels
static void printGraphElementTable(const Graph &, std::ostream &ostr=std::cout)
Various manipulations on graphs.
Definition: graphmanip.h:123
static void storeTalairach(Graph &g, const Motion &m)
stores Talairach transformation in graph
static GraphElementCode & graphElementCode(Graph &, const std::string &syntax, const std::string &id)
std::string id
ID for object: filename (globals) or attribute for filename (locals)
Definition: graphmanip.h:80
static void completeGraph(Graph &)
Completes folds graph information.
void adjustVoxelSize(T &, const T &)
utility function to copy voxel sizes from an object to another (if applicable)
static void setAttributeColor(Graph &graph, const std::string &att, const AimsRGB &)
static bool buckets2Volume(Graph &g)
converts internal representations of graph nodes from buckets to volume
static std::string defaultExtensionForObjectType(const std::string &otype, const std::string &dtype)
void insertElement(T &dest, int index, const T &src)
insert a sub-element in a container data (time bucket/mesh/texture, or volume of labels...)
Affine 3D transformation.
std::string global_filename
Definition: graphmanip.h:92
static void storeAims(Graph &graph, GraphObject *vertex, const std::string &attribute, carto::rc_ptr< T > obj)
This template function stores the given object in the given Vertex / Edge of the graph and takes care...
Definition: graphmanip_d.h:46
void setHeaderInfo(T &obj, const carto::GenericObject &srcheader)