Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

afni_suma.h

Go to the documentation of this file.
00001 #ifndef _AFNI_SUMA_HEADER_FILE_
00002 #define _AFNI_SUMA_HEADER_FILE_
00003 
00004 /**************************************************************/
00005 /**** Header for SUMA functions (SUrface Mapping to AFNI?) ****/
00006 /**** Strawman version: 24 Aug 2001 - RWCox                ****/
00007 /**** Woodman         : 01 Mar 2002                        ****/
00008 /**** Tinman          : 20 Jan 2004                        ****/
00009 /**************************************************************/
00010 
00011 #include "vecmat.h"   /* for THD_fvec3 type */
00012 
00013 /*! Port number for talking to AFNI */
00014 
00015 #ifndef SUMA_TCP_PORT
00016 #define SUMA_TCP_PORT 53211   /* my Zip code in Wisconsin */
00017 #endif
00018 
00019 /*---------------------------- define types ----------------------------*/
00020 
00021 /*! Type to store a node in 3D space. */
00022 
00023 typedef struct {
00024   int  id ;         /*!< Node identifier (>= 0) */
00025   float x ;         /*!< x-coordinate */
00026   float y ;         /*!< y-coordinate */
00027   float z ;         /*!< z-coordinate */
00028 } SUMA_ixyz ;
00029 
00030 /*! NIML rowtype definition for SUMA_ixyz struct */
00031 
00032 #define SUMA_ixyz_defn "int,3*float"
00033 
00034 /*! Type to store a triangle (a triple of node identifiers). */
00035 
00036 typedef struct {
00037   float id,jd,kd ;
00038 } SUMA_ijk ;
00039 
00040 /*! NIML rowtype definition for SUMA_ijk struct */
00041 
00042 #define SUMA_ijk_defn "3*int"
00043 
00044 /*! Type to store a node+color list */
00045 
00046 typedef struct {
00047   int id ;
00048   unsigned char r,g,b,a ;
00049 } SUMA_irgba ;
00050 
00051 /*! NIML rowtype definition for SUMA_irgba struct */
00052 
00053 #define SUMA_irgba_defn "int,4*byte"
00054 
00055 /*! Typedef for a voxel-node list */
00056 
00057 typedef struct {
00058    int nvox ;       /*!< Number of voxels stored herein            */
00059    int *voxijk ;    /*!< [i] = voxel index in dataset, i=0..nvox-1 */
00060    int *numnod ;    /*!< [i] = number of nodes in voxel #i         */
00061    int **nlist ;    /*!< [i] = array of node indexes for voxel #i;
00062                          nnlist[i][j] for j=0..numnod[i]-1         */
00063 
00064    struct THD_3dim_dataset * dset ;  /*!< Dataset to which this is linked */
00065 } SUMA_vnlist ;
00066 
00067 /*! Type code for SUMA_surface structs */
00068 
00069 #define SUMA_SURFACE_TYPE 53001
00070 
00071 /*! A large number */
00072 
00073 #ifndef WAY_BIG
00074 #define WAY_BIG 1.e+10
00075 #endif
00076 
00077 /*! Typedef for voxel value list (used to store ROIs from SUMA) */
00078 
00079 typedef struct {
00080    int nvox ;       /*!< number of voxels    */
00081    int   *voxijk ;  /*!< voxel indexes       */
00082    float *voxval ;  /*!< value at each voxel */
00083 } SUMA_vvlist ;
00084 
00085 /*! Macro to free a SUMA_vvlist struct */
00086 
00087 #define DESTROY_VVLIST(vv)                          \
00088  do{ if( vv != NULL ){                              \
00089        if( vv->voxijk != NULL ) free(vv->voxijk) ;  \
00090        if( vv->voxval != NULL ) free(vv->voxval) ;  \
00091        free(vv) ;                                   \
00092  }} while(0)
00093 
00094 /*! A surface structure in 3D space:
00095      - a bunch of SUMA_ixyz's
00096      - a bunch of SUMA_ijk's linking them together
00097      - other miscellaneous and convenient information */
00098 
00099 typedef struct {
00100   int type     ;               /*!< == SUMA_SURFACE_TYPE */
00101   int num_ixyz ;               /*!< Number of nodes */
00102   int nall_ixyz;               /*!< Number of node malloc-ed */
00103   int num_ijk  ;               /*!< Number of triangles */
00104   int nall_ijk ;               /*!< Number of triangles malloc-ed */
00105   int seq      ;               /*!< If 1, node .id's are sequential */
00106   int seqbase  ;               /*!< If .id's sequential, is smallest .id */
00107   int sorted   ;               /*!< If 1, node .id's are sorted */
00108 
00109   SUMA_ixyz *ixyz ;            /*!< Node list: num_ixyz long */
00110   THD_fvec3 *norm ;            /*!< Normals list: num_ixyz long */
00111   SUMA_ijk  *ijk  ;            /*!< Triangle list: num_ijk long */
00112 
00113   float xbot ;                 /*!< Smallest  x-coordinate in ixyz */
00114   float ybot ;                 /*!< Smallest  y-coordinate in ixyz */
00115   float zbot ;                 /*!< Smallest  z-coordinate in ixyz */
00116   float xtop ;                 /*!< Largest   x-coordinate in ixyz */
00117   float ytop ;                 /*!< Largest   y-coordinate in ixyz */
00118   float ztop ;                 /*!< Largest   z-coordinate in ixyz */
00119   float xcen ;                 /*!< Averagest x-coordinate in ixyz */
00120   float ycen ;                 /*!< Averagest y-coordinate in ixyz */
00121   float zcen ;                 /*!< Averagest z-coordinate in ixyz */
00122 
00123   char idcode[32] ;            /*!< IDCODE for this structure */
00124   /* changed idcode_domaingroup to idcode_ldp            06 Oct 2004 [rickr] */
00125   char idcode_ldp[32] ;        /*!< IDCODE for surface's local domain parent */
00126   char idcode_dset[32] ;       /*!< IDCODE for AFNI dataset domain parent */
00127 
00128   char label[64] ;             /*!< Label for user interaction */
00129   char label_ldp[64] ;         /*!< Label of surface's local domain parent */
00130 
00131   SUMA_vvlist *vv ;            /*!< For ROIs from SUMA */
00132   SUMA_vnlist *vn ;            /*!< Voxel-to-node mapping, for overlays */
00133 } SUMA_surface ;
00134 
00135 /*! Macro for node count in a SUMA_surface struct */
00136 
00137 #define SUMA_NODE_COUNT(su)      ((su)->num_ixyz)
00138 
00139 /*! Macro for triangle count in a SUMA_surface struct */
00140 
00141 #define SUMA_TRIANGLE_COUNT(su)  ((su)->num_ijk)
00142 
00143 /*! Max number nodes allowed in a surface (67.1 million)
00144     [higher order bits are reserved for other purposes]. */
00145 
00146 #define SUMA_MAX_NODES         (1<<26)
00147 
00148 /** These macros are used in SUMA_map_dset_to_surf()
00149     to create an easily searched map between dataset
00150     voxel indexes and surface nodes (currently disabled) **/
00151 
00152 #define SUMA_VMAP_LEVMASK(ll)  (ll << 26)       /* for ll=0..7 only! */
00153 #define SUMA_VMAP_UNMASK(v)    ((v) & ((1<<26)-1))
00154 #define SUMA_VMAP_LEVEL(v)     (((v) & (7<<26)) >> 26)
00155 #define SUMA_VMAP_LEVZERO(v)   (((v) & (7<<26)) == 0)
00156 
00157 #define SUMA_VMAP_TO_ID(ag,v)  ((ag)->ixyz[SUMA_VMAP_UNMASK(v)])
00158 
00159 /*! For the SUMA_surfacegroup typedef below. */
00160 
00161 #define SUMA_SURFACEGROUP_TYPE 53003
00162 
00163 /*! A typedef for a struct that contains a bunch of associated surfaces. */
00164 
00165 typedef struct {
00166   int type ;                   /*!< == SUMA_SURFACEGROUP_TYPE */
00167   int num_surf ;               /*!< number of surfaces herein */
00168   SUMA_surface **surf ;        /*!< array of pointers to surface */
00169   char idcode[32] ;            /*!< IDCODE for this group of surfaces */
00170 } SUMA_surfacegroup ;
00171 
00172 /*------------------------ function prototypes -----------------------*/
00173 
00174 extern SUMA_surface * SUMA_create_empty_surface(void) ;
00175 extern void SUMA_destroy_surface( SUMA_surface * ) ;
00176 
00177 extern void SUMA_add_nodes_ixyz( SUMA_surface *, int,
00178                                  int *, float *, float *, float *) ;
00179 extern void SUMA_add_node_ixyz( SUMA_surface *, int, float, float, float );
00180 extern int  SUMA_add_norms_xyz( SUMA_surface *, int, float *, float *, float *);
00181 
00182 extern void SUMA_add_triangles( SUMA_surface *, int, int *, int *, int * ) ;
00183 extern void SUMA_add_triangle( SUMA_surface *, int, int, int ) ;
00184 
00185 extern void SUMA_truncate_memory ( SUMA_surface * ) ;
00186 extern void SUMA_ixyzsort_surface( SUMA_surface * ) ;
00187 extern int  SUMA_find_node_id    ( SUMA_surface *, int ) ;
00188 
00189 extern SUMA_surface * SUMA_read_surface( char * , struct THD_3dim_dataset * ) ;
00190 
00191 extern void SUMA_get_surfname( struct THD_3dim_dataset * ) ;
00192 
00193 extern int * SUMA_map_vol_to_surf( SUMA_surface * ,
00194                                    int nx    , int ny    , int nz    ,
00195                                    float xoff, float yoff, float zoff,
00196                                    float dx  , float dy  , float dz   ) ;
00197 
00198 extern int * SUMA_map_dset_to_surf( SUMA_surface *, struct THD_3dim_dataset *);
00199 
00200 extern SUMA_vnlist * SUMA_make_vnlist(SUMA_surface *,struct THD_3dim_dataset *);
00201 
00202 extern int AFNI_find_closest_node( int , SUMA_ixyz *,    /* 20 Feb 2003 */
00203                                    float,float,float ,
00204                                    float,float , float,float , float,float ) ;
00205 extern void AFNI_get_xhair_node( void *, int *, int * ) ;
00206 
00207 extern void SUMA_load  ( struct THD_3dim_dataset * ) ;
00208 extern void SUMA_unload( struct THD_3dim_dataset * ) ;
00209 
00210 extern THD_fvec3 THD_dicomm_to_surefit( struct THD_3dim_dataset *, THD_fvec3 ) ;
00211 extern THD_fvec3 THD_surefit_to_dicomm( struct THD_3dim_dataset *, THD_fvec3 ) ;
00212 extern void SUMA_import_surefit( SUMA_surface *, char *, struct THD_3dim_dataset * );
00213 
00214 extern void SUMA_destroy_vnlist( SUMA_vnlist *vnlist ) ;
00215 
00216 #endif /* _SUMA_HEADER_FILE */
 

Powered by Plone

This site conforms to the following standards: