aimsdata  5.0.5
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>
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 
142  static Motion talairach( const Graph & g );
150  static void storeTalairach( Graph & g, const Motion & m,
151  bool force_old_attributes=false);
159  static bool hasOldTalairachTransform( const Graph & g );
164  static bool buckets2Volume( Graph & g );
169  static bool volume2Buckets( Graph & g, CreateBucketFunc f = 0 );
170  static GraphElementCode &
171  graphElementCode( Graph &, const std::string & syntax,
172  const std::string & id );
173  static GraphElementCode &
174  graphElementCodeByAtt( Graph &, const std::string & syntax,
175  const std::string & attrib );
181  template<typename T>
182  static void storeAims( Graph & graph, GraphObject* vertex,
183  const std::string & attribute,
184  carto::rc_ptr<T> obj );
186  template <typename T>
187  static Graph* graphFromVolume( const AimsData<T> & vol,
188  T background = 0,
189  std::map<T, std::string> *trans = 0 );
191  template <typename T>
192  static void graphFromVolume( const AimsData<T> & vol , Graph & g,
193  T background = 0,
194  std::map<T,std::string> *trans = 0,
195  bool automaticBackgroundSearch = true );
196  static void setAttributeColor( Graph & graph, const std::string & att,
197  const AimsRGB & );
198  static void setAttributeColor( Graph & graph, const std::string & att,
199  const AimsRGBA & );
200  static void setAttributeColor( Graph & graph, const std::string & att,
201  const std::vector<int> & );
202  std::vector<int> attributeColor( const Graph & graph,
203  const std::string & att );
207  static void completeGraph( Graph & );
208 
209  //Merge two graph
210  //If they contain some mesh, they can be
211  //either merged
212  //or just copied
213  //invNormal enable to inverse the mesh normal
214  static Graph* mergeGraph( const std::string &, Graph &, Graph &,
215  bool mergeMesh = true, bool invNormal = false);
216  static void printGraphElementTable( const Graph &,
217  std::ostream & ostr = std::cout );
218  static std::string
219  defaultExtensionForObjectType( const std::string & otype,
220  const std::string & dtype );
221  };
222 
223 }
224 
225 
226 namespace carto
227 {
228 
229  template<> inline
230  std::string DataTypeCode<aims::GraphElementCode>::dataType()
231  {
232  return "GraphElementCode";
233  }
234 
235 #define _TMP_ rc_ptr<std::map<std::string,std::map<std::string,aims::GraphElementCode> > >
237 #undef _TMP_
238 
239 } // namespace carto
240 
241 #endif
242 
#define DECLARE_GENERIC_OBJECT_TYPE(T)
carto::PropertySet & getHeader(T &obj)
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<GraphElemen...
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
The class for EcatSino data write operation.
Definition: border.h:44
GraphElementCode & operator=(const GraphElementCode &x)
std::string attribute
attribute found in graph objects, this attribute is a reference-counting pointer (carto::rc_ptr<T>) t...
Definition: graphmanip.h:84
#define _TMP_
Definition: graphmanip.h:235
std::string global_attribute
Definition: graphmanip.h:93
std::string objectType
object type as in aims Finder: "Volume", "Bucket", "Mesh", ...
Definition: graphmanip.h:86
aims::AffineTransformation3d Motion
Definition: graphmanip.h:48
Various manipulations on graphs.
Definition: graphmanip.h:123
std::string id
ID for object: filename (globals) or attribute for filename (locals)
Definition: graphmanip.h:80
void adjustVoxelSize(T &, const T &)
utility function to copy voxel sizes from an object to another (if applicable)
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
void setHeaderInfo(T &obj, const carto::GenericObject &srcheader)