Doxygen Source Code Documentation
thd_dsetatr.c File Reference
#include "mrilib.h"
#include "thd.h"
Go to the source code of this file.
Defines | |
#define | IFILL_DIM 100 |
#define | FFILL_DIM (MAPPING_LINEAR_FSIZE*20) |
#define | IFILL -999 |
#define | FFILL -999999.0 |
#define | ITFILL(p, q) for(ii=p;ii<q;ii++) itemp[ii] = IFILL |
#define | FTFILL(p, q) for(ii=p;ii<q;ii++) ftemp[ii] = FFILL |
#define | NFPER 5 |
#define | TF(i, j) vtag[(i)*NFPER+(j)] |
Functions | |
void | THD_anonymize_write (int uu) |
void | THD_set_dataset_attributes (THD_3dim_dataset *dset) |
Variables | |
int | anonymize = 0 |
Define Documentation
|
Definition at line 18 of file thd_dsetatr.c. Referenced by THD_set_dataset_attributes(). |
|
Definition at line 15 of file thd_dsetatr.c. Referenced by THD_set_dataset_attributes(). |
|
Definition at line 21 of file thd_dsetatr.c. Referenced by THD_set_dataset_attributes(). |
|
Definition at line 17 of file thd_dsetatr.c. |
|
Definition at line 14 of file thd_dsetatr.c. Referenced by THD_set_dataset_attributes(). |
|
Definition at line 20 of file thd_dsetatr.c. Referenced by THD_set_dataset_attributes(). |
|
|
|
|
Function Documentation
|
Definition at line 24 of file thd_dsetatr.c. References anonymize. Referenced by main().
00024 { anonymize = uu; } |
|
Set attributes from the dataset to the datablock, preparing for output to someplace or other. Adapted from elements of the earlier editions of THD_write_3dim_dataset() and THD_write_datablock() -- 09 Mar 2005. --------------------------------------------------------------------- Definition at line 33 of file thd_dsetatr.c. References THD_marker_set::aflags, AFMALL, THD_3dim_dataset::anat_parent_idcode, THD_3dim_dataset::anat_parent_name, ATRNAME_ANATOMY_PARENT, ATRNAME_BRICK_FLTFAC, ATRNAME_BRICK_KEYWORDS, ATRNAME_BRICK_LABS, ATRNAME_BRICK_STATAUX, ATRNAME_BRICK_STATS, ATRNAME_BRICK_TYPES, ATRNAME_DATANAME, ATRNAME_DATASET_DIMENSIONS, ATRNAME_DATASET_RANK, ATRNAME_DELTA, ATRNAME_IDANATPAR, ATRNAME_IDDATE, ATRNAME_IDSTRING, ATRNAME_IDWARPPAR, ATRNAME_KEYWORDS, ATRNAME_LABEL1, ATRNAME_LABEL2, ATRNAME_MARKSFLAG, ATRNAME_MARKSHELP, ATRNAME_MARKSLAB, ATRNAME_MARKSXYZ, ATRNAME_ORIENT_SPECIFIC, ATRNAME_ORIGIN, ATRNAME_SCENE_TYPE, ATRNAME_STAT_AUX, ATRNAME_TAGSET_FLOATS, ATRNAME_TAGSET_LABELS, ATRNAME_TAGSET_NUM, ATRNAME_TAXIS_FLOATS, ATRNAME_TAXIS_NUMS, ATRNAME_TAXIS_OFFSETS, ATRNAME_TYPESTRING, ATRNAME_WARP_DATA, ATRNAME_WARP_PARENT, ATRNAME_WARP_TYPE, ATRSIZE_DATASET_DIMENSIONS, ATRSIZE_DATASET_RANK, ATRSIZE_DELTA, ATRSIZE_MARKSFLAG, ATRSIZE_MARKSHELP, ATRSIZE_MARKSLAB, ATRSIZE_MARKSXYZ, ATRSIZE_ORIENT_SPECIFIC, ATRSIZE_ORIGIN, ATRSIZE_SCENE_TYPE, ATRSIZE_TAXIS_FLOATS, ATRSIZE_TAXIS_NUMS, ATRSIZE_WARP_TYPE, THD_datablock::brick_fac, THD_datablock::brick_keywords, THD_datablock::brick_lab, THD_datablock::brick_stataux, THD_datablock::brick_statcode, THD_statistics::bstat, calloc, COPY_FROM_STRUCT, MCW_idcode::date, THD_3dim_dataset::daxes, THD_3dim_dataset::dblk, DBLK_BRICK_TYPE, THD_diskptr::dimsizes, THD_datablock::diskptr, DSET_FIX_NAMES, THD_timeaxis::dz_sl, ENTRY, far, FFILL, FFILL_DIM, free, FTFILL, FUNC_IS_STAT, THD_3dim_dataset::func_type, THD_marker_set::help, THD_3dim_dataset::idcode, IFILL_DIM, ilen, ISVALID_3DIM_DATASET, ISVALID_DATABLOCK, ISVALID_DISKPTR, ISVALID_STATISTIC, ISZERO_IDCODE, ITFILL, THD_3dim_dataset::keywords, THD_usertag::label, THD_marker_set::label, THD_3dim_dataset::label1, THD_3dim_dataset::label2, malloc, MAPPING_LINEAR_FSIZE, MAPPING_LINEAR_FSTART, THD_3dim_dataset::markers, MARKS_MAXNUM, THD_brick_stats::max, MAX_STAT_AUX, THD_brick_stats::min, THD_statistics::nbstat, NI_stat_encode(), THD_timeaxis::nsl, THD_timeaxis::ntt, THD_usertaglist::num, THD_diskptr::nvals, THD_datablock::nvals, nz, THD_diskptr::rank, realloc, THD_talairach_12_warp::resam_type, THD_affine_warp::resam_type, THD_3dim_dataset::self_name, THD_usertag::set, THD_3dim_dataset::stat_aux, THD_3dim_dataset::stats, MCW_idcode::str, THD_usertaglist::tag, THD_3dim_dataset::tagset, THD_3dim_dataset::taxis, THD_anonymize_dset(), THD_erase_one_atr(), THD_set_char_atr(), THD_set_float_atr(), THD_set_int_atr(), THD_set_string_atr, THD_usertag::ti, THD_timeaxis::toff_sl, THD_timeaxis::ttdel, THD_timeaxis::ttdur, THD_timeaxis::ttorg, THD_warp::type, THD_3dim_dataset::type, THD_timeaxis::units_type, THD_usertag::val, THD_marker_set::valid, THD_3dim_dataset::view_type, THD_talairach_12_warp::warp, THD_affine_warp::warp, THD_3dim_dataset::warp, WARP_AFFINE_TYPE, THD_3dim_dataset::warp_parent_idcode, THD_3dim_dataset::warp_parent_name, WARP_TALAIRACH_12_SIZE, WARP_TALAIRACH_12_TYPE, THD_usertag::x, THD_dataxes::xxdel, THD_dataxes::xxorg, THD_dataxes::xxorient, THD_marker_set::xyz, THD_usertag::y, THD_dataxes::yydel, THD_dataxes::yyorg, THD_dataxes::yyorient, THD_usertag::z, THD_timeaxis::zorg_sl, THD_dataxes::zzdel, THD_dataxes::zzorg, and THD_dataxes::zzorient. Referenced by THD_nimlize_dsetatr(), and THD_write_3dim_dataset().
00034 { 00035 THD_datablock *blk ; 00036 THD_dataxes *daxes ; 00037 THD_diskptr *dkptr ; 00038 00039 int itemp[IFILL_DIM] , ii ; 00040 float ftemp[FFILL_DIM] ; 00041 00042 int id , nx , ny , nz , nv , nxy , nxyz , ibr , nb ; 00043 int atrank[ATRSIZE_DATASET_RANK] , atdims[ATRSIZE_DATASET_DIMENSIONS] ; 00044 MRI_IMAGE *im ; 00045 int save_order ; 00046 00047 ENTRY("THD_set_dataset_attributes") ; 00048 00049 /*-- sanity checks --*/ 00050 00051 if( ! ISVALID_3DIM_DATASET(dset) || 00052 ! ISVALID_DATABLOCK(dset->dblk) || 00053 ! ISVALID_DISKPTR(dset->dblk->diskptr) ) EXRETURN ; 00054 00055 blk = dset->dblk ; daxes = dset->daxes ; /* always used fixed daxes */ 00056 dkptr = blk->diskptr ; 00057 00058 /******/ 00059 /****** These attributes used to be set in THD_write_3dim_dataset() *****/ 00060 /******/ 00061 00062 /*----- write TYPESTRING attribute -----*/ 00063 00064 THD_set_string_atr( blk , ATRNAME_TYPESTRING , 00065 DATASET_typestr[dset->type] ) ; 00066 00067 /*----- write IDCODE attributes -----*/ 00068 00069 THD_set_string_atr( blk , ATRNAME_IDSTRING , dset->idcode.str ) ; 00070 THD_set_string_atr( blk , ATRNAME_IDDATE , dset->idcode.date ) ; 00071 00072 if( ! ISZERO_IDCODE(dset->anat_parent_idcode) ) 00073 THD_set_string_atr( blk, ATRNAME_IDANATPAR, dset->anat_parent_idcode.str ); 00074 else 00075 THD_erase_one_atr ( blk, ATRNAME_IDANATPAR ) ; 00076 00077 if( ! ISZERO_IDCODE(dset->warp_parent_idcode) ) 00078 THD_set_string_atr( blk, ATRNAME_IDWARPPAR, dset->warp_parent_idcode.str ); 00079 else 00080 THD_erase_one_atr ( blk, ATRNAME_IDWARPPAR ) ; 00081 00082 /*----- write SCENE_TYPE attribute -----*/ 00083 00084 itemp[0] = dset->view_type ; 00085 itemp[1] = dset->func_type ; 00086 itemp[2] = dset->type ; 00087 00088 ITFILL(3,ATRSIZE_SCENE_TYPE) ; 00089 THD_set_int_atr( blk , ATRNAME_SCENE_TYPE , 00090 ATRSIZE_SCENE_TYPE , itemp ) ; 00091 00092 /*----- write data labels -----*/ 00093 00094 if( strlen(dset->self_name) == 0 ) DSET_FIX_NAMES(dset) ; 00095 00096 THD_set_string_atr( blk , ATRNAME_LABEL1 , dset->label1 ) ; 00097 THD_set_string_atr( blk , ATRNAME_LABEL2 , dset->label2 ) ; 00098 THD_set_string_atr( blk , ATRNAME_DATANAME , dset->self_name ) ; 00099 00100 if( dset->keywords != NULL ) 00101 THD_set_string_atr( blk , ATRNAME_KEYWORDS , dset->keywords ) ; 00102 else 00103 THD_erase_one_atr ( blk , ATRNAME_KEYWORDS ) ; 00104 00105 /*----- write parent names, if they exist -----*/ 00106 00107 if( strlen(dset->warp_parent_name) > 0 ) 00108 THD_set_string_atr( blk , ATRNAME_WARP_PARENT , 00109 dset->warp_parent_name ) ; 00110 else 00111 THD_erase_one_atr ( blk , ATRNAME_WARP_PARENT ) ; 00112 00113 if( strlen(dset->anat_parent_name) > 0 ) 00114 THD_set_string_atr( blk , ATRNAME_ANATOMY_PARENT , 00115 dset->anat_parent_name ) ; 00116 else 00117 THD_erase_one_atr ( blk , ATRNAME_ANATOMY_PARENT ) ; 00118 00119 /*----- write axes orientation -----*/ 00120 00121 itemp[0] = daxes->xxorient ; 00122 itemp[1] = daxes->yyorient ; 00123 itemp[2] = daxes->zzorient ; 00124 00125 ITFILL(3,ATRSIZE_ORIENT_SPECIFIC) ; 00126 THD_set_int_atr( blk , ATRNAME_ORIENT_SPECIFIC , 00127 ATRSIZE_ORIENT_SPECIFIC , itemp ) ; 00128 00129 /*----- write axes origin -----*/ 00130 00131 ftemp[0] = daxes->xxorg ; 00132 ftemp[1] = daxes->yyorg ; 00133 ftemp[2] = daxes->zzorg ; 00134 00135 FTFILL(3,ATRSIZE_ORIGIN) ; 00136 THD_set_float_atr( blk , ATRNAME_ORIGIN , 00137 ATRSIZE_ORIGIN , ftemp ) ; 00138 00139 /*----- write axes spacings -----*/ 00140 00141 ftemp[0] = daxes->xxdel ; 00142 ftemp[1] = daxes->yydel ; 00143 ftemp[2] = daxes->zzdel ; 00144 00145 FTFILL(3,ATRSIZE_DELTA) ; 00146 THD_set_float_atr( blk , ATRNAME_DELTA , 00147 ATRSIZE_DELTA , ftemp ) ; 00148 00149 /*----- write markers, if present -----*/ 00150 00151 if( dset->markers != NULL ){ 00152 00153 for( ii=0 ; ii < MARKS_MAXNUM ; ii++ ){ /* put bad data in */ 00154 if( !dset->markers->valid[ii] ) /* invalid markers */ 00155 dset->markers->xyz[ii][0] = 00156 dset->markers->xyz[ii][1] = 00157 dset->markers->xyz[ii][2] = FFILL ; 00158 } 00159 00160 THD_set_float_atr( blk , ATRNAME_MARKSXYZ , 00161 ATRSIZE_MARKSXYZ , 00162 &(dset->markers->xyz[0][0]) ) ; 00163 00164 THD_set_char_atr( blk , ATRNAME_MARKSLAB , 00165 ATRSIZE_MARKSLAB , 00166 &(dset->markers->label[0][0]) ) ; 00167 00168 THD_set_char_atr( blk , ATRNAME_MARKSHELP , 00169 ATRSIZE_MARKSHELP , 00170 &(dset->markers->help[0][0]) ) ; 00171 00172 THD_set_int_atr( blk , ATRNAME_MARKSFLAG , 00173 ATRSIZE_MARKSFLAG , 00174 &(dset->markers->aflags[0]) ) ; 00175 } else { 00176 THD_erase_one_atr( blk , ATRNAME_MARKSXYZ ) ; 00177 THD_erase_one_atr( blk , ATRNAME_MARKSLAB ) ; 00178 THD_erase_one_atr( blk , ATRNAME_MARKSHELP ) ; 00179 THD_erase_one_atr( blk , ATRNAME_MARKSFLAG ) ; 00180 } 00181 00182 /*----- write warp, if present -----*/ 00183 00184 if( dset->warp != NULL ){ 00185 int wdata_size = 0 ; 00186 00187 switch( dset->warp->type ){ 00188 00189 case WARP_AFFINE_TYPE:{ 00190 THD_affine_warp *ww = (THD_affine_warp *) dset->warp ; 00191 itemp[0] = WARP_AFFINE_TYPE ; 00192 itemp[1] = ww->resam_type ; 00193 00194 wdata_size = MAPPING_LINEAR_FSIZE ; 00195 COPY_FROM_STRUCT( ww->warp , 00196 MAPPING_LINEAR_FSTART , 00197 float , 00198 ftemp , 00199 MAPPING_LINEAR_FSIZE ) ; 00200 } 00201 break ; 00202 00203 case WARP_TALAIRACH_12_TYPE:{ 00204 THD_talairach_12_warp *ww = 00205 (THD_talairach_12_warp *) dset->warp ; 00206 int iw , ioff ; 00207 00208 itemp[0] = WARP_TALAIRACH_12_TYPE ; 00209 itemp[1] = ww->resam_type ; 00210 00211 wdata_size = WARP_TALAIRACH_12_SIZE ; 00212 00213 for( iw=0 ; iw < 12 ; iw++ ){ 00214 ioff = iw * MAPPING_LINEAR_FSIZE ; 00215 00216 COPY_FROM_STRUCT( ww->warp[iw] , 00217 MAPPING_LINEAR_FSTART , 00218 float , 00219 &(ftemp[ioff]) , 00220 MAPPING_LINEAR_FSIZE ) ; 00221 } 00222 } 00223 break ; 00224 } /* end of switch on warp type */ 00225 00226 ITFILL(2,ATRSIZE_WARP_TYPE) ; 00227 THD_set_int_atr( blk , ATRNAME_WARP_TYPE , 00228 ATRSIZE_WARP_TYPE , itemp ) ; 00229 00230 THD_set_float_atr( blk , ATRNAME_WARP_DATA , 00231 wdata_size , ftemp ) ; 00232 00233 } else { /* no warp exists */ 00234 00235 THD_erase_one_atr( blk , ATRNAME_WARP_TYPE ) ; 00236 THD_erase_one_atr( blk , ATRNAME_WARP_DATA ) ; 00237 00238 } /* end of if warp exists */ 00239 00240 /*----- if statistics exist, write them out (modern style of floats) -----*/ 00241 00242 if( ISVALID_STATISTIC(dset->stats) ){ 00243 float *tfil ; 00244 int qq ; 00245 00246 tfil = (float *) malloc( sizeof(float) * 2*blk->nvals ) ; 00247 if( tfil != NULL ){ 00248 for( qq=0 ; qq < dset->stats->nbstat ; qq++ ){ 00249 tfil[2*qq] = dset->stats->bstat[qq].min ; 00250 tfil[2*qq+1] = dset->stats->bstat[qq].max ; 00251 } 00252 THD_set_float_atr( blk, ATRNAME_BRICK_STATS, 00253 2*dset->stats->nbstat, tfil ) ; 00254 free( tfil ) ; 00255 } 00256 } else { 00257 THD_erase_one_atr( blk , ATRNAME_BRICK_STATS ) ; 00258 } 00259 00260 /*----- if auxiliary statistics data exists, write them out too -----*/ 00261 00262 for( ii=MAX_STAT_AUX-1; ii>=0 && dset->stat_aux[ii]==0.0; ii-- ) ; /* nada */ 00263 00264 if( ii >= 0 ){ /* ii = largest index where stat_aux != 0 */ 00265 ii++ ; /* number of stat_aux values to save */ 00266 00267 THD_set_float_atr( blk , ATRNAME_STAT_AUX , ii , dset->stat_aux ) ; 00268 } else { 00269 THD_erase_one_atr( blk , ATRNAME_STAT_AUX ) ; 00270 } 00271 00272 /*----- if time-dependent data, write that stuff out too -----*/ 00273 00274 if( dset->taxis != NULL ){ 00275 itemp[0] = dset->taxis->ntt ; 00276 itemp[1] = dset->taxis->nsl ; 00277 itemp[2] = dset->taxis->units_type ; /* 21 Oct 1996 */ 00278 00279 ITFILL(3,ATRSIZE_TAXIS_NUMS) ; 00280 THD_set_int_atr( blk , ATRNAME_TAXIS_NUMS , 00281 ATRSIZE_TAXIS_NUMS , itemp ) ; 00282 00283 ftemp[0] = dset->taxis->ttorg ; 00284 ftemp[1] = dset->taxis->ttdel ; 00285 ftemp[2] = dset->taxis->ttdur ; 00286 ftemp[3] = dset->taxis->zorg_sl ; 00287 ftemp[4] = dset->taxis->dz_sl ; 00288 00289 FTFILL(5,ATRSIZE_TAXIS_FLOATS) ; 00290 THD_set_float_atr( blk , ATRNAME_TAXIS_FLOATS , 00291 ATRSIZE_TAXIS_FLOATS , ftemp ) ; 00292 00293 if( dset->taxis->toff_sl != NULL ) 00294 THD_set_float_atr( blk , ATRNAME_TAXIS_OFFSETS , 00295 dset->taxis->nsl , dset->taxis->toff_sl ) ; 00296 } else { 00297 THD_erase_one_atr( blk , ATRNAME_TAXIS_NUMS ) ; 00298 THD_erase_one_atr( blk , ATRNAME_TAXIS_FLOATS ) ; 00299 THD_erase_one_atr( blk , ATRNAME_TAXIS_OFFSETS ) ; 00300 } 00301 00302 /*----- 23 Oct 1998: write out tagset, if present -----*/ 00303 00304 #undef NFPER 00305 #define NFPER 5 00306 #define TF(i,j) vtag[(i)*NFPER+(j)] 00307 if( dset->tagset != NULL && dset->tagset->num > 0 ){ 00308 int ii , ntag=dset->tagset->num , tlen,ilen,jj ; 00309 float *vtag = (float *) malloc( sizeof(float) * (NFPER*ntag) ) ; 00310 char *ctag ; 00311 00312 /* set the counts */ 00313 00314 itemp[0] = ntag ; 00315 itemp[1] = NFPER ; 00316 THD_set_int_atr( blk , ATRNAME_TAGSET_NUM , 2 , itemp ) ; 00317 00318 /* set the values */ 00319 00320 for( ii=0 ; ii < ntag ; ii++ ){ 00321 TF(ii,0) = dset->tagset->tag[ii].x ; 00322 TF(ii,1) = dset->tagset->tag[ii].y ; 00323 TF(ii,2) = dset->tagset->tag[ii].z ; 00324 TF(ii,3) = dset->tagset->tag[ii].val ; 00325 if( dset->tagset->tag[ii].set ) TF(ii,4) = dset->tagset->tag[ii].ti ; 00326 else TF(ii,4) = -1.0 ; 00327 } 00328 THD_set_float_atr( blk , ATRNAME_TAGSET_FLOATS , NFPER*ntag , vtag ) ; 00329 free(vtag) ; 00330 00331 /* set the labels */ 00332 00333 tlen = 4 ; /* a little slop space */ 00334 for( ii=0 ; ii < ntag ; ii++ ) 00335 tlen += strlen( dset->tagset->tag[ii].label ) + 1; /* +1 for the '\0' */ 00336 00337 ctag = (char *) malloc( sizeof(char) * tlen ) ; /* to hold all labels */ 00338 jj = 0 ; 00339 for( ii=0 ; ii < ntag ; ii++ ){ 00340 ilen = strlen( dset->tagset->tag[ii].label ) + 1 ; 00341 memcpy( ctag+jj , dset->tagset->tag[ii].label , ilen ) ; 00342 jj += ilen ; 00343 } 00344 THD_set_char_atr( blk , ATRNAME_TAGSET_LABELS , tlen , ctag ) ; 00345 free(ctag) ; 00346 } else { 00347 THD_erase_one_atr( blk , ATRNAME_TAGSET_NUM ) ; 00348 THD_erase_one_atr( blk , ATRNAME_TAGSET_LABELS ) ; 00349 THD_erase_one_atr( blk , ATRNAME_TAGSET_FLOATS ) ; 00350 } 00351 #undef NFPER 00352 #undef TF 00353 00354 /******/ 00355 /****** These attributes used to be set in THD_write_datablock() *****/ 00356 /******/ 00357 00358 /* dataset dimensions */ 00359 00360 atrank[0] = dkptr->rank ; /* should always be 3 */ 00361 atrank[1] = dkptr->nvals ; 00362 for( id=2 ; id < ATRSIZE_DATASET_RANK ; id++ ) atrank[id] = 0 ; 00363 00364 THD_set_int_atr( blk , ATRNAME_DATASET_RANK , 00365 ATRSIZE_DATASET_RANK , atrank ) ; 00366 00367 for( id=0 ; id < ATRSIZE_DATASET_DIMENSIONS ; id++ ) 00368 atdims[id] = (id < dkptr->rank) ? dkptr->dimsizes[id] : 0 ; 00369 00370 THD_set_int_atr( blk , ATRNAME_DATASET_DIMENSIONS , 00371 ATRSIZE_DATASET_DIMENSIONS , atdims ) ; 00372 00373 /* sub-brick types */ 00374 00375 { int *datum_type ; 00376 datum_type = AFMALL(int, sizeof(int) * blk->nvals ) ; 00377 for( id=0 ; id < blk->nvals ; id++ ) 00378 datum_type[id] = DBLK_BRICK_TYPE(blk,id) ; 00379 THD_set_int_atr( blk , ATRNAME_BRICK_TYPES , blk->nvals , datum_type ) ; 00380 free( datum_type ) ; 00381 } 00382 THD_set_float_atr( blk, ATRNAME_BRICK_FLTFAC, blk->nvals, blk->brick_fac ) ; 00383 00384 /** 30 Nov 1997: write out brick labels **/ 00385 00386 if( blk->brick_lab != NULL ){ 00387 00388 int ibr , nch , ipos , ll ; 00389 char *car ; 00390 00391 for( ibr=0,nch=0 ; ibr < blk->nvals ; ibr++ ) /* total length */ 00392 nch += strlen(blk->brick_lab[ibr]) + 1 ; /* of all labels */ 00393 00394 car = (char *) malloc( sizeof(char) * nch ) ; /* space for all labels */ 00395 00396 for( ibr=0,ipos=0 ; ibr < blk->nvals ; ibr++ ){ /* put all labels */ 00397 ll = strlen(blk->brick_lab[ibr]) + 1 ; /* together */ 00398 memcpy( car+ipos , blk->brick_lab[ibr] , ll ) ; 00399 ipos += ll ; 00400 } 00401 00402 THD_set_char_atr( blk , ATRNAME_BRICK_LABS , nch , car ) ; 00403 free(car) ; 00404 } else { 00405 THD_erase_one_atr( blk , ATRNAME_BRICK_LABS ) ; 00406 } 00407 00408 /** and write out brick keywords **/ 00409 00410 if( blk->brick_keywords != NULL ){ 00411 00412 int ibr , nch , ipos , ll ; 00413 char *car ; 00414 00415 for( ibr=0,nch=0 ; ibr < blk->nvals ; ibr++ ){ 00416 if( blk->brick_keywords[ibr] != NULL ) 00417 nch += strlen(blk->brick_keywords[ibr]) + 1 ; 00418 else 00419 nch += 1 ; 00420 } 00421 00422 car = (char *) malloc( sizeof(char) * nch ) ; 00423 00424 for( ibr=0,ipos=0 ; ibr < blk->nvals ; ibr++ ){ 00425 if( blk->brick_keywords[ibr] != NULL ){ 00426 ll = strlen(blk->brick_keywords[ibr]) + 1 ; 00427 memcpy( car+ipos , blk->brick_keywords[ibr] , ll ) ; 00428 ipos += ll ; 00429 } else { 00430 car[ipos++] = '\0' ; 00431 } 00432 } 00433 00434 THD_set_char_atr( blk , ATRNAME_BRICK_KEYWORDS , nch , car ) ; 00435 free(car) ; 00436 } else { 00437 THD_erase_one_atr( blk , ATRNAME_BRICK_KEYWORDS ) ; 00438 } 00439 00440 /* and write out brick stataux parameters */ 00441 00442 if( blk->brick_statcode != NULL && /* write out brick stataux */ 00443 blk->brick_stataux != NULL ){ /* stuff, if it exists. */ 00444 00445 int ibr , nfl , jv , ipos , iv ; 00446 float *far ; 00447 00448 for( ibr=0,nfl=0 ; ibr < blk->nvals ; ibr++ ){ /* compute total */ 00449 jv = blk->brick_statcode[ibr] ; /* space needed */ 00450 if( FUNC_IS_STAT(jv) ) nfl += FUNC_need_stat_aux[jv] + 3 ; 00451 } 00452 00453 if( nfl > 0 ){ 00454 far = (float *) malloc( sizeof(float) * nfl ) ; 00455 00456 for( ibr=0,ipos=0 ; ibr < blk->nvals ; ibr++ ){ 00457 jv = blk->brick_statcode[ibr] ; 00458 if( FUNC_IS_STAT(jv) ){ 00459 far[ipos++] = ibr ; /* save index */ 00460 far[ipos++] = jv ; /* save statcode */ 00461 far[ipos++] = FUNC_need_stat_aux[jv] ; /* save # of params */ 00462 00463 if( blk->brick_stataux[ibr] != NULL ){ /* if have params, save */ 00464 for( iv=0 ; iv < FUNC_need_stat_aux[jv] ; iv++ ) 00465 far[ipos++] = blk->brick_stataux[ibr][iv] ; 00466 } else { /* should never be used */ 00467 for( iv=0 ; iv < FUNC_need_stat_aux[jv] ; iv++ ) 00468 far[ipos++] = 0.0 ; 00469 } 00470 } 00471 } 00472 00473 THD_set_float_atr( blk , ATRNAME_BRICK_STATAUX , nfl , far ) ; 00474 free(far) ; 00475 } else { 00476 THD_erase_one_atr( blk , ATRNAME_BRICK_STATAUX ) ; 00477 } 00478 } else { 00479 THD_erase_one_atr( blk , ATRNAME_BRICK_STATAUX ) ; 00480 } 00481 00482 /** 01 Jun 2005: save brick_stataux stuff in a different way **/ 00483 00484 if( blk->brick_statcode != NULL && /* write out brick stataux */ 00485 blk->brick_stataux != NULL ){ /* stuff, if it exists. */ 00486 00487 int ibr , jv ; 00488 00489 for( ibr=0 ; ibr < blk->nvals ; ibr++ ){ /* see if any bricks */ 00490 jv = blk->brick_statcode[ibr] ; /* have stat codes */ 00491 if( FUNC_IS_STAT(jv) ) break ; 00492 } 00493 00494 if( ibr < blk->nvals ){ /* got someone to save */ 00495 char *statsym=(char *)calloc(1,1), *sstr ; float p1,p2,p3 ; int np ; 00496 00497 for( ibr=0 ; ibr < blk->nvals ; ibr++ ){ 00498 jv = blk->brick_statcode[ibr] ; /* have stat codes */ 00499 if( FUNC_IS_STAT(jv) ){ 00500 p1 = p2 = p3 = 0.0f ; 00501 np = FUNC_need_stat_aux[jv] ; 00502 if( blk->brick_stataux[ibr] != NULL ){ 00503 if( np > 0 ) p1 = blk->brick_stataux[ibr][0] ; 00504 if( np > 1 ) p2 = blk->brick_stataux[ibr][1] ; 00505 if( np > 2 ) p3 = blk->brick_stataux[ibr][2] ; 00506 } 00507 sstr = NI_stat_encode( jv , p1,p2,p3 ) ; 00508 } else { 00509 sstr = strdup("none") ; 00510 } 00511 jv = strlen(sstr) + strlen(statsym) + 4 ; 00512 statsym = (char *)realloc( statsym , jv ) ; 00513 if( ibr > 0 ) strcat(statsym,";") ; 00514 strcat(statsym,sstr) ; free(sstr) ; 00515 } 00516 THD_set_string_atr( blk , "BRICK_STATSYM" , statsym ) ; 00517 free(statsym) ; 00518 } else { 00519 THD_erase_one_atr( blk , "BRICK_STATSYM" ) ; 00520 } 00521 } else { 00522 THD_erase_one_atr( blk , "BRICK_STATSYM" ) ; 00523 } 00524 00525 /******/ 00526 /****** N.B.: we do NOT set the byte order attribute here *****/ 00527 /******/ 00528 00529 if( anonymize ) THD_anonymize_dset(dset) ; /* 08 Jul 2005 */ 00530 00531 EXRETURN ; 00532 } |
Variable Documentation
|
Definition at line 23 of file thd_dsetatr.c. Referenced by THD_anonymize_write(). |