aimsdata  5.0.5
Neuroimaging data handling
ciftitools.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_SPARSEMATRIX_CIFTITOOLS_H
35 #define AIMS_SPARSEMATRIX_CIFTITOOLS_H
36 
37 #include <cartobase/smart/rcptr.h>
38 #include <map>
39 #include <vector>
40 #include <string>
41 #include <list>
42 
43 template <typename T> class TimeTexture;
44 class Void;
45 template <int D, typename T> class AimsTimeSurface;
46 
47 namespace carto
48 {
49  class Object;
50 }
51 
52 
53 namespace aims
54 {
55  class SparseOrDenseMatrix;
56 
69  class CiftiTools
70  {
71  public:
72  typedef std::map<std::string, int> BrainStuctureToMeshMap;
73  typedef std::vector<carto::rc_ptr<TimeTexture<int> > > RoiTextureList;
74  typedef std::vector<carto::rc_ptr<TimeTexture<float> > > TextureList;
75 
76  CiftiTools(
78  const BrainStuctureToMeshMap & smap = BrainStuctureToMeshMap() );
79  ~CiftiTools();
80 
82  { return _matrix; }
84  { return _matrix; }
85  void setMatrix( carto::rc_ptr<SparseOrDenseMatrix> matrix );
86  const BrainStuctureToMeshMap & brainStructureMap() const
87  { return _smap; }
88  BrainStuctureToMeshMap & brainStructureMap()
89  { return _smap; }
90  void setBrainStructureMap( const BrainStuctureToMeshMap & smap )
91  { _smap = smap; }
103  RoiTextureList *roiTextureFromDimension( int dim ) const;
119  TextureList *expandedValueTextureFromDimension(
120  int dim,
121  const std::vector<int> & dim_indices_pos,
122  TextureList* existing_tex_list = 0 ) const;
123 
124  // intermediate
129  static BrainStuctureToMeshMap defaultBrainStructureToMeshMap();
130  int valuesDimNum() const;
131  static int valuesDimNum( carto::Object cifti_info );
132  static size_t valuesDimSize( const SparseOrDenseMatrix & mat,
133  int value_dim );
134  static std::string dimensionType( carto::Object cifti_info, int dim );
135  std::string dimensionType( int dim ) const;
136 
137  // lower-level (could probably be private)
138  carto::Object getDimensionObject( int dim ) const;
139 
142  template <typename T>
143  void buildDimensionObjectFromLabelsTexture( int dim,
144  const TimeTexture<T> & tex );
145 
146  static void getLabelsInfo( carto::Object cifti_info, RoiTextureList & );
147  static void getSeriesInfo( carto::Object cifti_info, RoiTextureList & );
148  void getParcelsInfo( carto::Object cifti_info, RoiTextureList & ) const;
149  void getBrainModelsInfo( carto::Object cifti_info,
150  RoiTextureList & ) const;
151  void getBrainModelsTexture(
152  carto::Object cifti_info, TextureList & texlist, int dim,
153  const std::vector<int> & dim_indices_pos ) const;
154  void getParcelsTexture(
155  carto::Object cifti_info, TextureList & texlist, int dim,
156  const std::vector<int> & dim_indices_pos ) const;
157  std::list<std::string> getBrainStructures( int dim,
158  bool keepSurfaces = true,
159  bool keepVoxels = true ) const;
162  std::vector<int> getIndicesForBrainStructure(
163  int dim, const std::string & struct_name ) const;
167  std::vector<int> getIndicesForSurfaceIndices(
168  int dim, int surface_num, const std::vector<int> & roi_indices ) const;
169  size_t getBrainStructureMeshNumberOfNodes(
170  int dim, const std::string & struct_name ) const;
177  bool isMatchingSurface( int dim, const AimsTimeSurface<3, Void> & mesh,
178  std::list<std::string> & brainmodels,
179  int & surf_index, int surf_hint = 0 ) const
180  {
181  return isMatchingSurfaceOrTexture( dim, mesh, brainmodels, surf_index,
182  surf_hint );
183  }
190  template <typename T>
191  bool isMatchingTexture( int dim, const TimeTexture<T> & tex,
192  std::list<std::string> & brainmodels,
193  int & surf_index, int surf_hint = 0 ) const
194  {
195  return isMatchingSurfaceOrTexture( dim, tex, brainmodels, surf_index,
196  surf_hint );
197  }
198  bool isMatchingSurfaceOrTexture( int dim, size_t nvertices,
199  const carto::Object header,
200  std::list<std::string> & brainmodels,
201  int & surf_index,
202  int surf_hint = 0 ) const;
203 
204  private:
205  template <typename T> bool
206  isMatchingSurfaceOrTexture( int dim, const T & mesh,
207  std::list<std::string> & brainmodels,
208  int & surf_index, int surf_hint = 0 ) const;
209  void getSurfaceModelTexture(
210  carto::Object surf, TextureList & texlist,
211  const BrainStuctureToMeshMap & smap,
212  SparseOrDenseMatrix & mat, int dim,
213  const std::vector<int> & dim_indices_pos,
214  unsigned nsurfaces ) const;
215 
216  struct Private;
217 
218  Private *d;
219  mutable carto::rc_ptr<SparseOrDenseMatrix> _matrix;
220  BrainStuctureToMeshMap _smap;
221  };
222 
223 }
224 
225 #endif
226 
BrainStuctureToMeshMap & brainStructureMap()
Definition: ciftitools.h:88
std::vector< carto::rc_ptr< TimeTexture< int > > > RoiTextureList
Definition: ciftitools.h:73
const BrainStuctureToMeshMap & brainStructureMap() const
Definition: ciftitools.h:86
std::vector< carto::rc_ptr< TimeTexture< float > > > TextureList
Definition: ciftitools.h:74
The class for EcatSino data write operation.
Definition: border.h:44
std::map< std::string, int > BrainStuctureToMeshMap
Definition: ciftitools.h:72
bool isMatchingTexture(int dim, const TimeTexture< T > &tex, std::list< std::string > &brainmodels, int &surf_index, int surf_hint=0) const
checks if the given texture matches a surface description in the given dimension of the Cifti matrix...
Definition: ciftitools.h:191
carto::rc_ptr< SparseOrDenseMatrix > matrix()
Definition: ciftitools.h:83
The template class to manage a mesh with time if needed.
Definition: surface.h:290
void setBrainStructureMap(const BrainStuctureToMeshMap &smap)
Definition: ciftitools.h:90
bool isMatchingSurface(int dim, const AimsTimeSurface< 3, Void > &mesh, std::list< std::string > &brainmodels, int &surf_index, int surf_hint=0) const
checks if the given mesh matches a surface description in the given dimension of the Cifti matrix...
Definition: ciftitools.h:177
CIFTI-2 shaped matrices manipulation tools.
Definition: ciftitools.h:69
const carto::rc_ptr< SparseOrDenseMatrix > matrix() const
Definition: ciftitools.h:81