1 #ifndef _AFNI_SUMA_HEADER_FILE_ 2 #define _AFNI_SUMA_HEADER_FILE_ 3 4 /**************************************************************/ 5 /**** Header for SUMA functions (SUrface Mapping to AFNI?) ****/ 6 /**** Strawman version: 24 Aug 2001 - RWCox ****/ 7 /**** Woodman : 01 Mar 2002 ****/ 8 /**** Tinman : 20 Jan 2004 ****/ 9 /**************************************************************/ 10 11 #include "vecmat.h" /* for THD_fvec3 type */ 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /*! Port number for talking to AFNI */ 18 19 #ifndef SUMA_TCP_PORT 20 #define SUMA_TCP_PORT 53211 /* my Zip code in Wisconsin */ 21 #endif 22 23 /*---------------------------- define types ----------------------------*/ 24 25 /*! Type to store a node in 3D space. */ 26 27 typedef struct { 28 int id ; /*!< Node identifier (>= 0) */ 29 float x ; /*!< x-coordinate */ 30 float y ; /*!< y-coordinate */ 31 float z ; /*!< z-coordinate */ 32 } SUMA_ixyz ; 33 34 /*! NIML rowtype definition for SUMA_ixyz struct */ 35 36 #define SUMA_ixyz_defn "int,3*float" 37 38 /*! Type to store a triangle (a triple of node identifiers). */ 39 40 typedef struct { 41 float id,jd,kd ; 42 } SUMA_ijk ; 43 44 /*! NIML rowtype definition for SUMA_ijk struct */ 45 46 #define SUMA_ijk_defn "3*int" 47 48 /*! Type to store a node+color list */ 49 50 typedef struct { 51 int id ; 52 unsigned char r,g,b,a ; 53 } SUMA_irgba ; 54 55 /*! NIML rowtype definition for SUMA_irgba struct */ 56 57 #define SUMA_irgba_defn "int,4*byte" 58 59 /*! Typedef for a voxel-node list */ 60 61 typedef struct { 62 int nvox ; /*!< Number of voxels stored herein */ 63 int *voxijk ; /*!< [i] = voxel index in dataset, i=0..nvox-1 */ 64 int *numnod ; /*!< [i] = number of nodes in voxel #i */ 65 int **nlist ; /*!< [i] = array of node indexes for voxel #i; 66 nnlist[i][j] for j=0..numnod[i]-1 */ 67 68 struct THD_3dim_dataset * dset ; /*!< Dataset to which this is linked */ 69 } SUMA_vnlist ; 70 71 /*! Type code for SUMA_surface structs */ 72 73 #define SUMA_SURFACE_TYPE 53001 74 75 /*! A large number */ 76 77 #ifndef WAY_BIG 78 #define WAY_BIG 1.e+10 79 #endif 80 81 /*! Typedef for voxel value list (used to store ROIs from SUMA) */ 82 83 typedef struct { 84 int nvox ; /*!< number of voxels */ 85 int *voxijk ; /*!< voxel indexes */ 86 float *voxval ; /*!< value at each voxel */ 87 } SUMA_vvlist ; 88 89 /*! Macro to free a SUMA_vvlist struct */ 90 91 #define DESTROY_VVLIST(vv) \ 92 do{ if( vv != NULL ){ \ 93 if( vv->voxijk != NULL ) free(vv->voxijk) ; \ 94 if( vv->voxval != NULL ) free(vv->voxval) ; \ 95 free(vv) ; \ 96 }} while(0) 97 98 struct SUMA_mask ; /* incomplete type definition for use below */ 99 100 /*! A surface structure in 3D space: 101 - a bunch of SUMA_ixyz's 102 - a bunch of SUMA_ijk's linking them together 103 - other miscellaneous and convenient information */ 104 105 typedef struct { 106 int type ; /*!< == SUMA_SURFACE_TYPE */ 107 int num_ixyz ; /*!< Number of nodes */ 108 int nall_ixyz; /*!< Number of node malloc-ed */ 109 int num_ijk ; /*!< Number of triangles */ 110 int nall_ijk ; /*!< Number of triangles malloc-ed */ 111 int seq ; /*!< If 1, node .id's are sequential */ 112 int seqbase ; /*!< If .id's sequential, is smallest .id */ 113 int sorted ; /*!< If 1, node .id's are sorted */ 114 115 SUMA_ixyz *ixyz ; /*!< Node list: num_ixyz long */ 116 THD_fvec3 *norm ; /*!< Normals list: num_ixyz long */ 117 SUMA_ijk *ijk ; /*!< Triangle list: num_ijk long */ 118 119 float xbot ; /*!< Smallest x-coordinate in ixyz */ 120 float ybot ; /*!< Smallest y-coordinate in ixyz */ 121 float zbot ; /*!< Smallest z-coordinate in ixyz */ 122 float xtop ; /*!< Largest x-coordinate in ixyz */ 123 float ytop ; /*!< Largest y-coordinate in ixyz */ 124 float ztop ; /*!< Largest z-coordinate in ixyz */ 125 float xcen ; /*!< Averagest x-coordinate in ixyz */ 126 float ycen ; /*!< Averagest y-coordinate in ixyz */ 127 float zcen ; /*!< Averagest z-coordinate in ixyz */ 128 129 char idcode[32] ; /*!< IDCODE for this structure */ 130 /* changed idcode_domaingroup to idcode_ldp 06 Oct 2004 [rickr] */ 131 char idcode_ldp[32] ; /*!< IDCODE for surface's local domain parent */ 132 char idcode_dset[32] ; /*!< IDCODE for AFNI dataset domain parent */ 133 134 char label[64] ; /*!< Label for user interaction */ 135 char label_ldp[64] ; /*!< Label of surface's local domain parent */ 136 137 char spec_file[256] ; /*!< suma spec file name 8 Aug 2006 [rickr] */ 138 139 SUMA_vvlist *vv ; /*!< For ROIs from SUMA */ 140 SUMA_vnlist *vn ; /*!< Voxel-to-node mapping, for overlays */ 141 142 int mask_code ; /*!< 0 if not part of a mask */ 143 char mask_parent_idcode[32]; /*!< idcode of the SUMA_mask owner */ 144 struct SUMA_mask *mask ; /*!< pointer to SUMA_mask owner */ 145 char line_color[32] ; /*!< line color set from SUMA */ 146 char box_color[32] ; /*!< box color set from SUMA */ 147 int line_width ; /*!< line width set from SUMA */ 148 int parent_type ; 149 void *parent ; /*!< pointer to enclosing object */ 150 } SUMA_surface ; 151 152 /*! Macro for node count in a SUMA_surface struct */ 153 154 #define SUMA_NODE_COUNT(su) ((su)->num_ixyz) 155 156 /*! Macro for triangle count in a SUMA_surface struct */ 157 158 #define SUMA_TRIANGLE_COUNT(su) ((su)->num_ijk) 159 160 /*! Max number nodes allowed in a surface (67.1 million) 161 [higher order bits are reserved for other purposes]. */ 162 163 #define SUMA_MAX_NODES (1<<26) 164 165 /** These macros are used in SUMA_map_dset_to_surf() 166 to create an easily searched map between dataset 167 voxel indexes and surface nodes (currently disabled) **/ 168 169 #define SUMA_VMAP_LEVMASK(ll) (ll << 26) /* for ll=0..7 only! */ 170 #define SUMA_VMAP_UNMASK(v) ((v) & ((1<<26)-1)) 171 #define SUMA_VMAP_LEVEL(v) (((v) & (7<<26)) >> 26) 172 #define SUMA_VMAP_LEVZERO(v) (((v) & (7<<26)) == 0) 173 174 #define SUMA_VMAP_TO_ID(ag,v) ((ag)->ixyz[SUMA_VMAP_UNMASK(v)]) 175 176 /*! For the SUMA_surfacegroup typedef below. */ 177 178 #define SUMA_SURFACEGROUP_TYPE 53003 179 180 /*! A typedef for a struct that contains a bunch of associated surfaces. */ 181 182 typedef struct { 183 int type ; /*!< == SUMA_SURFACEGROUP_TYPE */ 184 int num_surf ; /*!< number of surfaces herein */ 185 SUMA_surface **surf ; /*!< array of pointers to surface */ 186 char idcode[32] ; /*!< IDCODE for this group of surfaces */ 187 } SUMA_surfacegroup ; 188 189 /*! type for a SUMA_mask [04 Apr 2014 -- RWCox] */ 190 191 #define SUMA_MASK_TYPE 53005 192 193 typedef struct SUMA_mask { 194 int type ; /*!< better be SUMA_MASK_TYPE */ 195 char idcode[32] ; /*!< idcode of this mask */ 196 int num_surf ; /*!< number of surfaces contained herein */ 197 char **idcode_surf ; /*|< idcodes for each surface */ 198 SUMA_surface **surf ; /*!< pointers to each surface */ 199 THD_fvec3 init_cen ; /*!< DICOM xyz for initial center */ 200 THD_fvec3 show_cen ; /*!< DICOM xyz for displayed center */ 201 int parent_type ; /*!< probably a session */ 202 void *parent ; /*!< pointer to enclosing object */ 203 } SUMA_mask ; 204 205 /*------------------------ function prototypes -----------------------*/ 206 207 extern SUMA_mask * SUMA_create_empty_mask(void) ; 208 void SUMA_destroy_mask( SUMA_mask *msk , int kill_surfaces_too ) ; 209 210 extern SUMA_surface * SUMA_create_empty_surface(void) ; 211 extern void SUMA_destroy_surface( SUMA_surface * ) ; 212 213 extern void SUMA_add_nodes_ixyz( SUMA_surface *, int, 214 int *, float *, float *, float *) ; 215 extern void SUMA_add_node_ixyz( SUMA_surface *, int, float, float, float ); 216 extern int SUMA_add_norms_xyz( SUMA_surface *, int, float *, float *, float *); 217 218 extern void SUMA_add_triangles( SUMA_surface *, int, int *, int *, int * ) ; 219 extern void SUMA_add_triangle( SUMA_surface *, int, int, int ) ; 220 221 extern void SUMA_truncate_memory ( SUMA_surface * ) ; 222 extern void SUMA_ixyzsort_surface( SUMA_surface * ) ; 223 extern int SUMA_find_node_id ( SUMA_surface *, int ) ; 224 225 extern void SUMA_clear_triangles( SUMA_surface *ag ) ; /* Apr 2014 */ 226 extern void SUMA_clear_normals ( SUMA_surface *ag ) ; 227 228 extern SUMA_surface * SUMA_read_surface( char * , struct THD_3dim_dataset * ) ; 229 230 extern void SUMA_get_surfname( struct THD_3dim_dataset * ) ; 231 232 extern int * SUMA_map_vol_to_surf( SUMA_surface * , 233 int nx , int ny , int nz , 234 float xoff, float yoff, float zoff, 235 float dx , float dy , float dz ) ; 236 237 extern int * SUMA_map_dset_to_surf( SUMA_surface *, struct THD_3dim_dataset *); 238 239 extern SUMA_vnlist * SUMA_make_vnlist(SUMA_surface *,struct THD_3dim_dataset *); 240 241 extern int AFNI_find_closest_node( int , SUMA_ixyz *, /* 20 Feb 2003 */ 242 float,float,float , 243 float,float , float,float , float,float ) ; 244 extern void AFNI_get_xhair_node( void *, int *, int * ) ; 245 246 extern void SUMA_load ( struct THD_3dim_dataset * ) ; 247 extern void SUMA_unload( struct THD_3dim_dataset * ) ; 248 249 extern THD_fvec3 THD_dicomm_to_surefit( struct THD_3dim_dataset *, THD_fvec3 ) ; 250 extern THD_fvec3 THD_surefit_to_dicomm( struct THD_3dim_dataset *, THD_fvec3 ) ; 251 extern void SUMA_import_surefit( SUMA_surface *, char *, struct THD_3dim_dataset * ); 252 253 extern void SUMA_destroy_vnlist( SUMA_vnlist *vnlist ) ; 254 255 #ifdef __cplusplus 256 } 257 #endif 258 259 #endif /* _SUMA_HEADER_FILE */ 260