aimsdata  5.1.2
Neuroimaging data handling
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>
40 #include <cartobase/type/types.h>
42 
43 class Graph;
44 class GraphObject;
45 class Vertex;
46 class Edge;
47 
48 namespace aims
49 {
50  class AffineTransformation3d;
51 }
52 class Void;
53 
54 namespace aims
55 {
56 
57  template<typename T> class BucketMap;
58 
67  {
69  {
73  };
74 
77  GraphElementCode( const std::string & attrib, const std::string & ot,
78  const std::string & dt, StorageType st );
80 
82  std::string id;
86  std::string attribute;
88  std::string objectType;
90  std::string dataType;
92  std::string local_file_attribute;
94  std::string global_filename;
95  std::string global_attribute;
97  std::string syntax;
98  };
99 
102  typedef std::map<std::string, std::map<std::string,GraphElementCode> >
104 
105 
106  namespace DataManip
107  {
108 
111  template <typename T> void adjustVoxelSize( T &, const T & );
112 
115  template <typename T>
116  void insertElement( T & dest, int index, const T & src );
117  template <typename T>
119  template <typename T>
120  void setHeaderInfo( T & obj, const carto::GenericObject & srcheader );
121  }
122 
123 
126  {
127  public:
128  typedef BucketMap<Void>*
129  (*CreateBucketFunc)( GraphObject*, const std::string & );
130 
152  static void storeTalairach( Graph & g, const AffineTransformation3d & m,
153  bool force_old_attributes=false);
161  static bool hasOldTalairachTransform( const Graph & g );
183  static bool buckets2Volume( Graph & g );
188  static bool volume2Buckets( Graph & g, CreateBucketFunc f = 0 );
189  static GraphElementCode &
190  graphElementCode( Graph &, const std::string & syntax,
191  const std::string & id );
192  static GraphElementCode &
193  graphElementCodeByAtt( Graph &, const std::string & syntax,
194  const std::string & attrib );
200  template<typename T>
201  static void storeAims( Graph & graph, GraphObject* vertex,
202  const std::string & attribute,
203  carto::rc_ptr<T> obj );
205  template <typename T>
207  const carto::rc_ptr<carto::Volume<T> > & vol,
208  T background = 0,
209  std::map<T, std::string> *trans = 0 );
211  template <typename T>
212  static void graphFromVolume( const carto::rc_ptr<carto::Volume<T> > & vol ,
213  Graph & g,
214  T background = 0,
215  std::map<T,std::string> *trans = 0,
216  bool automaticBackgroundSearch = true );
217  static void setAttributeColor( Graph & graph, const std::string & att,
218  const AimsRGB & );
219  static void setAttributeColor( Graph & graph, const std::string & att,
220  const AimsRGBA & );
221  static void setAttributeColor( Graph & graph, const std::string & att,
222  const std::vector<int> & );
223  std::vector<int> attributeColor( const Graph & graph,
224  const std::string & att );
228  static void completeGraph( Graph & );
229 
230  //Merge two graph
231  //If they contain some mesh, they can be
232  //either merged
233  //or just copied
234  //invNormal enable to inverse the mesh normal
235  static Graph* mergeGraph( const std::string &, Graph &, Graph &,
236  bool mergeMesh = true, bool invNormal = false);
237  static void printGraphElementTable( const Graph &,
238  std::ostream & ostr = std::cout );
239  static std::string
240  defaultExtensionForObjectType( const std::string & otype,
241  const std::string & dtype );
242 
249  static std::list<Edge *> getPath( const Vertex *from, const Vertex *to );
250  };
251 
252 }
253 
254 
255 namespace carto
256 {
257 
258  template<> inline
260  {
261  return "GraphElementCode";
262  }
263 
264 #define _TMP_ rc_ptr<std::map<std::string,std::map<std::string,aims::GraphElementCode> > >
266 #undef _TMP_
267 
268 } // namespace carto
269 
270 #endif
271 
Various manipulations on graphs.
Definition: graphmanip.h:126
static AffineTransformation3d getICBMTransform(const Graph &g)
Extract the transformation to the MNI ICBM152 space.
static void setAttributeColor(Graph &graph, const std::string &att, const std::vector< int > &)
static bool buckets2Volume(Graph &g)
converts internal representations of graph nodes from buckets to volume
static AffineTransformation3d talairach(const Graph &g)
Extract Talairach transformation (graph -> Talairach)
static void graphFromVolume(const carto::rc_ptr< carto::Volume< T > > &vol, Graph &g, T background=0, std::map< T, std::string > *trans=0, bool automaticBackgroundSearch=true)
builds a ROI graph from a volume of labels
BucketMap< Void > *(* CreateBucketFunc)(GraphObject *, const std::string &)
Definition: graphmanip.h:129
static bool volume2Buckets(Graph &g, CreateBucketFunc f=0)
converts internal representations of graph nodes from volume to buckets.
static void completeGraph(Graph &)
Completes folds graph information.
static AffineTransformation3d getICBM2009cTemplateTransform(const Graph &g)
Extract the transformation to the MNI ICBM152 space, shifted to the "most standard" field of view of ...
static Graph * graphFromVolume(const carto::rc_ptr< carto::Volume< T > > &vol, T background=0, std::map< T, std::string > *trans=0)
builds a ROI graph from a volume of labels
std::vector< int > attributeColor(const Graph &graph, const std::string &att)
static std::list< Edge * > getPath(const Vertex *from, const Vertex *to)
Get edges path from a vertex to another one.
static Graph * mergeGraph(const std::string &, Graph &, Graph &, bool mergeMesh=true, bool invNormal=false)
static void setAttributeColor(Graph &graph, const std::string &att, const AimsRGB &)
static bool hasOldTalairachTransform(const Graph &g)
Test if a Graph has the old Talairach attributes.
static void printGraphElementTable(const Graph &, std::ostream &ostr=std::cout)
static std::string defaultExtensionForObjectType(const std::string &otype, const std::string &dtype)
static GraphElementCode & graphElementCode(Graph &, const std::string &syntax, const std::string &id)
static void setAttributeColor(Graph &graph, const std::string &att, const AimsRGBA &)
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
static void storeTalairach(Graph &g, const AffineTransformation3d &m, bool force_old_attributes=false)
Store Talairach transformation in graph.
static GraphElementCode & graphElementCodeByAtt(Graph &, const std::string &syntax, const std::string &attrib)
std::string dataType()
#define _TMP_
Definition: graphmanip.h:264
carto::PropertySet & getHeader(T &obj)
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....
void adjustVoxelSize(T &, const T &)
utility function to copy voxel sizes from an object to another (if applicable)
void setHeaderInfo(T &obj, const carto::GenericObject &srcheader)
The class for EcatSino data write operation.
Definition: borderfiller.h:13
std::map< std::string, std::map< std::string, GraphElementCode > > GraphElementTable
GraphElementCode table, stored in graphs in attribute "aims_objects_table" (carto::rc_ptr<GraphElemen...
Definition: graphmanip.h:103
#define DECLARE_GENERIC_OBJECT_TYPE(T)
Describe how Aims objects are stored in graph objects.
Definition: graphmanip.h:67
std::string attribute
attribute found in graph objects, this attribute is a reference-counting pointer (carto::rc_ptr<T>) t...
Definition: graphmanip.h:86
std::string global_filename
Definition: graphmanip.h:94
std::string objectType
object type as in aims Finder: "Volume", "Bucket", "Mesh", ...
Definition: graphmanip.h:88
StorageType storageType
Definition: graphmanip.h:91
std::string syntax
syntactic attribute of attributed objects
Definition: graphmanip.h:97
GraphElementCode(const std::string &attrib, const std::string &ot, const std::string &dt, StorageType st)
GraphElementCode(const GraphElementCode &x)
std::string global_index_attribute
Definition: graphmanip.h:93
std::string id
ID for object: filename (globals) or attribute for filename (locals)
Definition: graphmanip.h:82
std::string dataType
data type as in Aims Finder: "S16", "U8", "FLOAT", ...
Definition: graphmanip.h:90
std::string local_file_attribute
Definition: graphmanip.h:92
std::string global_attribute
Definition: graphmanip.h:95
GraphElementCode & operator=(const GraphElementCode &x)